@Override public JsonElement serialize(Arguments src, Type typeOfSrc, JsonSerializationContext context) { return context.serialize(src.asMap(), MAP_STRING_STRING_TYPE); } }
/** * Returns the {@link Resources} based on configurations in the given arguments. * * Same as calling {@link #getResources(Map, Resources)} with first argument from {@link Arguments#asMap()}. */ public static Resources getResources(Arguments args, @Nullable Resources defaultResources) { return getResources(args.asMap(), defaultResources); }
/** * Returns the {@link Resources} based on configurations in the given arguments. * * Same as calling {@link #getResources(Map, Resources)} with first argument from {@link Arguments#asMap()}. */ public static Resources getResources(Arguments args, @Nullable Resources defaultResources) { return getResources(args.asMap(), defaultResources); }
@Override public JsonElement serialize(Arguments src, Type typeOfSrc, JsonSerializationContext context) { return context.serialize(src.asMap(), MAP_STRING_STRING_TYPE); } }
/** * Validates the options for the program. * Subclasses can override this to also validate the options for their sub-programs. */ protected void validateOptions(Program program, ProgramOptions options) { // this will throw an exception if the custom tx timeout is invalid SystemArguments.validateTransactionTimeout(options.getUserArguments().asMap(), cConf); }
/** * Set the log level for the {@link LogAppenderInitializer}. * * @param args the arguments to use for looking up resources configurations * @param initializer the LogAppenderInitializer which will be used to set up the log level */ public static void setLogLevel(Arguments args, LogAppenderInitializer initializer) { initializer.setLogLevels(getLogLevels(args.asMap())); }
/** * Set the log level for the {@link LogAppenderInitializer}. * * @param args the arguments to use for looking up resources configurations * @param initializer the LogAppenderInitializer which will be used to set up the log level */ public static void setLogLevel(Arguments args, LogAppenderInitializer initializer) { initializer.setLogLevels(getLogLevels(args.asMap())); }
private ProgramOptions createComponentOptions(int instanceId, int instances, RunId runId, ProgramOptions options) { Map<String, String> systemOptions = Maps.newHashMap(); systemOptions.putAll(options.getArguments().asMap()); systemOptions.put(ProgramOptionConstants.INSTANCE_ID, Integer.toString(instanceId)); systemOptions.put(ProgramOptionConstants.INSTANCES, Integer.toString(instances)); systemOptions.put(ProgramOptionConstants.RUN_ID, runId.getId()); systemOptions.put(ProgramOptionConstants.HOST, host); return new SimpleProgramOptions(options.getProgramId(), new BasicArguments(systemOptions), options.getUserArguments()); }
private ProgramOptions createComponentOptions(int instanceId, int instances, RunId runId, ProgramOptions options) { Map<String, String> systemOptions = Maps.newHashMap(); systemOptions.putAll(options.getArguments().asMap()); systemOptions.put(ProgramOptionConstants.INSTANCE_ID, Integer.toString(instanceId)); systemOptions.put(ProgramOptionConstants.INSTANCES, Integer.toString(instances)); systemOptions.put(ProgramOptionConstants.RUN_ID, runId.getId()); systemOptions.put(ProgramOptionConstants.HOST, host); return new SimpleProgramOptions(options.getProgramId(), new BasicArguments(systemOptions), options.getUserArguments()); }
private ProgramOptions createFlowletOptions(int instanceId, int instances, ProgramOptions options) { Map<String, String> systemArgs = new HashMap<>(); systemArgs.putAll(options.getArguments().asMap()); systemArgs.put(ProgramOptionConstants.INSTANCE_ID, Integer.toString(instanceId)); systemArgs.put(ProgramOptionConstants.INSTANCES, Integer.toString(instances)); return new SimpleProgramOptions(options.getProgramId(), new BasicArguments(systemArgs), options.getUserArguments()); }
/** * Creates a {@link ProfileMetricService} for the profile being used for the given program run. */ private ProfileMetricService createProfileMetricsService(ProgramRunId programRunId, ProgramOptions programOptions, Cluster cluster) { Optional<ProfileId> profile = SystemArguments.getProfileIdFromArgs(programRunId.getNamespaceId(), programOptions.getArguments().asMap()); ProfileId profileId = profile.orElseThrow( () -> new IllegalStateException("Missing profile information for program run " + programRunId)); return new ProfileMetricService(metricsCollectionService, programRunId, profileId, cluster.getNodes().size(), monitorScheduler); }
private ProgramOptions resolveFlowletOptions(ProgramOptions options, String flowlet) { Map<String, String> systemArgs = new HashMap<>(options.getArguments().asMap()); systemArgs.put(ProgramOptionConstants.FLOWLET_NAME, flowlet); return new SimpleProgramOptions(options.getProgramId(), new BasicArguments(systemArgs), new BasicArguments(RuntimeArguments.extractScope( FlowUtils.FLOWLET_SCOPE, flowlet, options.getUserArguments().asMap()))); }
@Override protected void validateOptions(Program program, ProgramOptions options) { super.validateOptions(program, options); FlowSpecification spec = program.getApplicationSpecification().getFlows().get(program.getName()); for (String flowlet : spec.getFlowlets().keySet()) { SystemArguments.validateTransactionTimeout(options.getUserArguments().asMap(), cConf, "flowlet", flowlet); } }
private boolean programOptionsEquals(ProgramOptions opt1, ProgramOptions opt2) { return Objects.equals(opt1.getProgramId(), opt2.getProgramId()) && opt1.isDebug() == opt2.isDebug() && Objects.equals(opt1.getArguments().asMap(), opt2.getArguments().asMap()) && Objects.equals(opt1.getUserArguments().asMap(), opt2.getUserArguments().asMap()); } }
@Override protected void setupLaunchConfig(ProgramLaunchConfig launchConfig, Program program, ProgramOptions options, CConfiguration cConf, Configuration hConf, File tempDir) { ApplicationSpecification appSpec = program.getApplicationSpecification(); WorkerSpecification workerSpec = appSpec.getWorkers().get(program.getName()); String instances = options.getArguments().getOption(ProgramOptionConstants.INSTANCES, String.valueOf(workerSpec.getInstances())); launchConfig.addRunnable(workerSpec.getName(), new WorkerTwillRunnable(workerSpec.getName()), Integer.parseInt(instances), options.getUserArguments().asMap(), workerSpec.getResources()); } }
@Override protected void setupLaunchConfig(ProgramLaunchConfig launchConfig, Program program, ProgramOptions options, CConfiguration cConf, Configuration hConf, File tempDir) { ApplicationSpecification appSpec = program.getApplicationSpecification(); WorkerSpecification workerSpec = appSpec.getWorkers().get(program.getName()); String instances = options.getArguments().getOption(ProgramOptionConstants.INSTANCES, String.valueOf(workerSpec.getInstances())); launchConfig.addRunnable(workerSpec.getName(), new WorkerTwillRunnable(workerSpec.getName()), Integer.parseInt(instances), options.getUserArguments().asMap(), workerSpec.getResources()); } }
/** * Creates a {@link ProgramOptions} by deserializing the given json file. */ private ProgramOptions createProgramOptions(File programOptionsFile) throws IOException { ProgramOptions original = readJsonFile(programOptionsFile, ProgramOptions.class); // Overwrite them with environmental information Map<String, String> arguments = new HashMap<>(original.getArguments().asMap()); arguments.putAll(getExtraSystemArguments()); // Use the name passed in by the constructor as the program name to construct the ProgramId return new SimpleProgramOptions(original.getProgramId(), new BasicArguments(arguments), resolveScope(original.getUserArguments()), original.isDebug()); }
/** * Creates a {@link ProgramOptions} by deserializing the given json file. */ private ProgramOptions createProgramOptions(File programOptionsFile) throws IOException { ProgramOptions original = readJsonFile(programOptionsFile, ProgramOptions.class); // Overwrite them with environmental information Map<String, String> arguments = new HashMap<>(original.getArguments().asMap()); arguments.putAll(getExtraSystemArguments()); // Use the name passed in by the constructor as the program name to construct the ProgramId return new SimpleProgramOptions(original.getProgramId(), new BasicArguments(arguments), resolveScope(original.getUserArguments()), original.isDebug()); }
@Override protected void setupLaunchConfig(ProgramLaunchConfig launchConfig, Program program, ProgramOptions options, CConfiguration cConf, Configuration hConf, File tempDir) { ApplicationSpecification appSpec = program.getApplicationSpecification(); ServiceSpecification serviceSpec = appSpec.getServices().get(program.getName()); // Add a runnable for the service handler launchConfig.addRunnable(serviceSpec.getName(), new ServiceTwillRunnable(serviceSpec.getName()), serviceSpec.getInstances(), options.getUserArguments().asMap(), serviceSpec.getResources()); } }
@Override protected void setupLaunchConfig(ProgramLaunchConfig launchConfig, Program program, ProgramOptions options, CConfiguration cConf, Configuration hConf, File tempDir) { ApplicationSpecification appSpec = program.getApplicationSpecification(); ServiceSpecification serviceSpec = appSpec.getServices().get(program.getName()); // Add a runnable for the service handler launchConfig.addRunnable(serviceSpec.getName(), new ServiceTwillRunnable(serviceSpec.getName()), serviceSpec.getInstances(), options.getUserArguments().asMap(), serviceSpec.getResources()); } }