@Nullable @Override public Object convert(Object source) { return source instanceof Option ? ((Option<?>) source).getOrElse(alternative) : source; } }
@Override public Optional<String> name() { try { return Optional.ofNullable(accumulatorV2.name().getOrElse(new AbstractFunction0<String>() { @Override public String apply() { return null; } })); } catch (IllegalAccessError e) { return Optional.empty(); } }
private final io.trane.ndbc.DataSource<P, R> current() { return currentTransaction.apply().getOrElse(() -> underlying); }
public static Result route(Application app, FakeRequest fakeRequest) { final scala.Option<play.api.mvc.Result> opt = play.api.test.Helpers.jRoute(app.getWrappedApplication(), fakeRequest.fake); final play.api.mvc.Result r = opt.getOrElse(null); if(r != null){ return new Result() { public play.api.mvc.Result getWrappedResult(){ return r; } }; } return null; }
retryBackoff.run(fetchMetadataOperation, onExceptionRetryOperation).getOrElse(fallbackOperation); return result;
@Override public void apply(KToken k) { sb.append("\\dv{"); convert(k.sort(), false); sb.append("}("); if (module.sortAttributesFor().get(k.sort()).getOrElse(() -> Att.empty()).getOptional("hook").orElse("").equals("STRING.String")) { sb.append(k.s()); } else { sb.append(StringUtil.enquoteKString(k.s())); } sb.append(")"); }
public void fastCueAndPlayFromMediaHandle(MediaHandle<Animation> handle) { Animation anim = null; try{ anim = handle.getMedia().getOrElse(null); }catch(Exception ex){} // TODO: Get a proper performance set up for monitor + cancel, possibly based on the Media.Framed type.handle if(anim == null){ // anim = new Animation(); // Channel c = new Channel(100, "waist"); // MotionPath mp = new MotionPath(); // mp.addPoint(0, 0.5); // mp.addPoint(1500, 1.0); // mp.addPoint(3000, 0.5); // mp.addPoint(4500, 0.0); // mp.addPoint(6000, 0.5); // c.addPath(mp); // anim.addChannel(c); return; } FancyPerformance perf = null; launchFullAnimJobNow(anim, perf); }
public static <T> Result route(Application app, FakeRequest fakeRequest, byte[] body) { final play.api.mvc.Result r = play.api.test.Helpers.jRoute(app.getWrappedApplication(), fakeRequest.getWrappedRequest(), body).getOrElse(null); if(r != null){ return new Result() { public play.api.mvc.Result getWrappedResult(){ return r; } }; } return null; }
/** Creates a GrpcClientSettings from the given HTTP/2 endpoint and ActorSystem. */ public static GrpcClientSettings grpcClientSettings( final ServerEndpoint http2Endpoint, final ActorSystem actorSystem ) { final ServerEndpoint.ClientSsl clientSsl = http2Endpoint.ssl().getOrElse(func(() -> { throw new IllegalArgumentException( "GrpcClientSettings requires a server endpoint with ssl, but non provided"); })); return grpcClientSettings(http2Endpoint, clientSsl.sslContext(), actorSystem); }
public void fastCueAndPlayFromMediaHandle(MediaHandle<Animation> handle) { Animation anim = null; try{ anim = handle.getMedia().getOrElse(null); }catch(Exception ex){} // TODO: Get a proper performance set up for monitor + cancel, possibly based on the Media.Framed type.handle if(anim == null){ // anim = new Animation(); // Channel c = new Channel(100, "waist"); // MotionPath mp = new MotionPath(); // mp.addPoint(0, 0.5); // mp.addPoint(1500, 1.0); // mp.addPoint(3000, 0.5); // mp.addPoint(4500, 0.0); // mp.addPoint(6000, 0.5); // c.addPath(mp); // anim.addChannel(c); return; } FancyPerformance perf = null; launchFullAnimJobNow(anim, perf); }
@Override public void apply(KApply k) { String hook = module.attributesFor().get(k.klabel()).getOrElse(() -> Att.empty()).getOptional("hook").orElse(""); if (hook.equals("SET.element") || hook.equals("LIST.element") || hook.equals("LIST.concat") || hook.equals("MAP.concat") || hook.equals("SET.concat")) { return; } if (hook.equals("MAP.element")) { apply(k.items().get(1)); return; } super.apply(k); } }.apply(term);
/** Creates a GrpcClientSettings from the given HTTP/2 endpoint and ActorSystem. */ public static GrpcClientSettings grpcClientSettings( final ServerEndpoint http2Endpoint, final ActorSystem actorSystem ) { final ServerEndpoint.ClientSsl clientSsl = http2Endpoint.ssl().getOrElse(func(() -> { throw new IllegalArgumentException( "GrpcClientSettings requires a server endpoint with ssl, but non provided"); })); return grpcClientSettings(http2Endpoint, clientSsl.sslContext(), actorSystem); }
/** * Creates the {@link SamzaApplication} object from the task or application class name specified in {@code config} * * @param config the configuration of the application * @return the {@link SamzaApplication} object */ public static SamzaApplication fromConfig(Config config) { String appClassName = new ApplicationConfig(config).getAppClass(); if (StringUtils.isNotBlank(appClassName)) { // app.class is configured try { Class<SamzaApplication> appClass = (Class<SamzaApplication>) Class.forName(appClassName); if (StreamApplication.class.isAssignableFrom(appClass) || TaskApplication.class.isAssignableFrom(appClass)) { return appClass.newInstance(); } } catch (IllegalAccessException | InstantiationException | ClassNotFoundException e) { throw new ConfigException(String.format("Loading app.class %s failed. The user application has to implement " + "StreamApplication or TaskApplication.", appClassName), e); } } // no app.class defined. It has to be a legacy application with task.class configuration Option<String> taskClassOption = new TaskConfig(config).getTaskClass(); if (!taskClassOption.isDefined() || !StringUtils.isNotBlank(taskClassOption.getOrElse(null))) { // no task.class defined either. This is wrong. throw new ConfigException("Legacy task applications must set a non-empty task.class in configuration."); } return new LegacyTaskApplication(taskClassOption.get()); } }
/** * Creates the {@link SamzaApplication} object from the task or application class name specified in {@code config} * * @param config the configuration of the application * @return the {@link SamzaApplication} object */ public static SamzaApplication fromConfig(Config config) { String appClassName = new ApplicationConfig(config).getAppClass(); if (StringUtils.isNotBlank(appClassName)) { // app.class is configured try { Class<SamzaApplication> appClass = (Class<SamzaApplication>) Class.forName(appClassName); if (StreamApplication.class.isAssignableFrom(appClass) || TaskApplication.class.isAssignableFrom(appClass)) { return appClass.newInstance(); } } catch (IllegalAccessException | InstantiationException | ClassNotFoundException e) { throw new ConfigException(String.format("Loading app.class %s failed. The user application has to implement " + "StreamApplication or TaskApplication.", appClassName), e); } } // no app.class defined. It has to be a legacy application with task.class configuration Option<String> taskClassOption = new TaskConfig(config).getTaskClass(); if (!taskClassOption.isDefined() || !StringUtils.isNotBlank(taskClassOption.getOrElse(null))) { // no task.class defined either. This is wrong. throw new ConfigException("Legacy task applications must set a non-empty task.class in configuration."); } return new LegacyTaskApplication(taskClassOption.get()); } }
/** * Creates the {@link SamzaApplication} object from the task or application class name specified in {@code config} * * @param config the configuration of the application * @return the {@link SamzaApplication} object */ public static SamzaApplication fromConfig(Config config) { String appClassName = new ApplicationConfig(config).getAppClass(); if (StringUtils.isNotBlank(appClassName)) { // app.class is configured try { Class<SamzaApplication> appClass = (Class<SamzaApplication>) Class.forName(appClassName); if (StreamApplication.class.isAssignableFrom(appClass) || TaskApplication.class.isAssignableFrom(appClass)) { return appClass.newInstance(); } } catch (IllegalAccessException | InstantiationException | ClassNotFoundException e) { throw new ConfigException(String.format("Loading app.class %s failed. The user application has to implement " + "StreamApplication or TaskApplication.", appClassName), e); } } // no app.class defined. It has to be a legacy application with task.class configuration Option<String> taskClassOption = new TaskConfig(config).getTaskClass(); if (!taskClassOption.isDefined() || !StringUtils.isNotBlank(taskClassOption.getOrElse(null))) { // no task.class defined either. This is wrong. throw new ConfigException("Legacy task applications must set a non-empty task.class in configuration."); } return new LegacyTaskApplication(taskClassOption.get()); } }
/** * Creates the {@link SamzaApplication} object from the task or application class name specified in {@code config} * * @param config the configuration of the application * @return the {@link SamzaApplication} object */ public static SamzaApplication fromConfig(Config config) { String appClassName = new ApplicationConfig(config).getAppClass(); if (StringUtils.isNotBlank(appClassName)) { // app.class is configured try { Class<SamzaApplication> appClass = (Class<SamzaApplication>) Class.forName(appClassName); if (StreamApplication.class.isAssignableFrom(appClass) || TaskApplication.class.isAssignableFrom(appClass)) { return appClass.newInstance(); } } catch (IllegalAccessException | InstantiationException | ClassNotFoundException e) { throw new ConfigException(String.format("Loading app.class %s failed. The user application has to implement " + "StreamApplication or TaskApplication.", appClassName), e); } } // no app.class defined. It has to be a legacy application with task.class configuration Option<String> taskClassOption = new TaskConfig(config).getTaskClass(); if (!taskClassOption.isDefined() || !StringUtils.isNotBlank(taskClassOption.getOrElse(null))) { // no task.class defined either. This is wrong. throw new ConfigException("Legacy task applications must set a non-empty task.class in configuration."); } return new LegacyTaskApplication(taskClassOption.get()); } }
/** * Creates the {@link SamzaApplication} object from the task or application class name specified in {@code config} * * @param config the configuration of the application * @return the {@link SamzaApplication} object */ public static SamzaApplication fromConfig(Config config) { String appClassName = new ApplicationConfig(config).getAppClass(); if (StringUtils.isNotBlank(appClassName)) { // app.class is configured try { Class<SamzaApplication> appClass = (Class<SamzaApplication>) Class.forName(appClassName); if (StreamApplication.class.isAssignableFrom(appClass) || TaskApplication.class.isAssignableFrom(appClass)) { return appClass.newInstance(); } } catch (IllegalAccessException | InstantiationException | ClassNotFoundException e) { throw new ConfigException(String.format("Loading app.class %s failed. The user application has to implement " + "StreamApplication or TaskApplication.", appClassName), e); } } // no app.class defined. It has to be a legacy application with task.class configuration Option<String> taskClassOption = new TaskConfig(config).getTaskClass(); if (!taskClassOption.isDefined() || !StringUtils.isNotBlank(taskClassOption.getOrElse(null))) { // no task.class defined either. This is wrong. throw new ConfigException("Legacy task applications must set a non-empty task.class in configuration."); } return new LegacyTaskApplication(taskClassOption.get()); } }
@Override public void onApplicationStart(SparkListenerApplicationStart applicationStart) { try { header = header.cloneAndOverride(Header.newBuilder() .withApplicationID(applicationStart.appId().getOrElse(emptyStringScala)) .withAttemptID(applicationStart.appAttemptId().getOrElse(emptyStringScala)) .withApplicationName(applicationStart.appName()) .build()) .toSerializeHeader(); } catch (Throwable t) { LOGGER.warn("Failed to send event for onApplicationStart", t); } }
@Override public void onStageSubmitted(SparkListenerStageSubmitted stageSubmitted) { try { long submissionTime = stageSubmitted.stageInfo().submissionTime().getOrElse(currentTimeLongScala); String name = stageSubmitted.stageInfo().name(); String stageId = String.valueOf(stageSubmitted.stageInfo().stageId()); String attemptId = String.valueOf(stageSubmitted.stageInfo().attemptId()); int numTasks = stageSubmitted.stageInfo().numTasks(); sendStageStateEvent(submissionTime, State.BEGIN, name, stageId, attemptId, numTasks); } catch (Throwable t) { LOGGER.warn("Failed to send event for onStageSubmitted", t); } }
String hookAtt = mod.sortAttributesFor().get(expectedSort).getOrElse(() -> Att()).getOptional("hook").orElse(""); if (hookAtt.equals("MAP.Map") || hookAtt.equals("SET.Set") || hookAtt.equals("LIST.List")) { for (KLabel collectionLabel : collectionFor.keySet()) {