public void provisioned(ProgramRunId programRunId, ProgramOptions programOptions, ProgramDescriptor programDescriptor, String userId, Cluster cluster, URI secureKeysDir) { Map<String, String> properties = ImmutableMap.<String, String>builder() .put(ProgramOptionConstants.PROGRAM_RUN_ID, GSON.toJson(programRunId)) .put(ProgramOptionConstants.PROGRAM_DESCRIPTOR, GSON.toJson(programDescriptor)) .put(ProgramOptionConstants.USER_ID, userId) .put(ProgramOptionConstants.CLUSTER_STATUS, ProgramRunClusterStatus.PROVISIONED.name()) .put(ProgramOptionConstants.CLUSTER, GSON.toJson(cluster)) .put(ProgramOptionConstants.DEBUG_ENABLED, String.valueOf(programOptions.isDebug())) .put(ProgramOptionConstants.USER_OVERRIDES, GSON.toJson(programOptions.getUserArguments().asMap())) .put(ProgramOptionConstants.SYSTEM_OVERRIDES, GSON.toJson(programOptions.getArguments().asMap())) .put(ProgramOptionConstants.SECURE_KEYS_DIR, GSON.toJson(secureKeysDir)) .build(); publish(properties); }
public void provisioning(ProgramRunId programRunId, ProgramOptions programOptions, ProgramDescriptor programDescriptor, String userId) { publish(ImmutableMap.<String, String>builder() .put(ProgramOptionConstants.PROGRAM_RUN_ID, GSON.toJson(programRunId)) .put(ProgramOptionConstants.PROGRAM_DESCRIPTOR, GSON.toJson(programDescriptor)) .put(ProgramOptionConstants.USER_ID, userId) .put(ProgramOptionConstants.CLUSTER_STATUS, ProgramRunClusterStatus.PROVISIONING.name()) .put(ProgramOptionConstants.DEBUG_ENABLED, String.valueOf(programOptions.isDebug())) .put(ProgramOptionConstants.USER_OVERRIDES, GSON.toJson(programOptions.getUserArguments().asMap())) .put(ProgramOptionConstants.SYSTEM_OVERRIDES, GSON.toJson(programOptions.getArguments().asMap())) .put(ProgramOptionConstants.ARTIFACT_ID, GSON.toJson(programDescriptor.getArtifactId().toApiArtifactId())) .build()); }
public void provisioned(ProgramRunId programRunId, ProgramOptions programOptions, ProgramDescriptor programDescriptor, String userId, Cluster cluster, URI secureKeysDir) { Map<String, String> properties = ImmutableMap.<String, String>builder() .put(ProgramOptionConstants.PROGRAM_RUN_ID, GSON.toJson(programRunId)) .put(ProgramOptionConstants.PROGRAM_DESCRIPTOR, GSON.toJson(programDescriptor)) .put(ProgramOptionConstants.USER_ID, userId) .put(ProgramOptionConstants.CLUSTER_STATUS, ProgramRunClusterStatus.PROVISIONED.name()) .put(ProgramOptionConstants.CLUSTER, GSON.toJson(cluster)) .put(ProgramOptionConstants.DEBUG_ENABLED, String.valueOf(programOptions.isDebug())) .put(ProgramOptionConstants.USER_OVERRIDES, GSON.toJson(programOptions.getUserArguments().asMap())) .put(ProgramOptionConstants.SYSTEM_OVERRIDES, GSON.toJson(programOptions.getArguments().asMap())) .put(ProgramOptionConstants.SECURE_KEYS_DIR, GSON.toJson(secureKeysDir)) .build(); publish(properties); }
public void provisioning(ProgramRunId programRunId, ProgramOptions programOptions, ProgramDescriptor programDescriptor, String userId) { publish(ImmutableMap.<String, String>builder() .put(ProgramOptionConstants.PROGRAM_RUN_ID, GSON.toJson(programRunId)) .put(ProgramOptionConstants.PROGRAM_DESCRIPTOR, GSON.toJson(programDescriptor)) .put(ProgramOptionConstants.USER_ID, userId) .put(ProgramOptionConstants.CLUSTER_STATUS, ProgramRunClusterStatus.PROVISIONING.name()) .put(ProgramOptionConstants.DEBUG_ENABLED, String.valueOf(programOptions.isDebug())) .put(ProgramOptionConstants.USER_OVERRIDES, GSON.toJson(programOptions.getUserArguments().asMap())) .put(ProgramOptionConstants.SYSTEM_OVERRIDES, GSON.toJson(programOptions.getArguments().asMap())) .put(ProgramOptionConstants.ARTIFACT_ID, GSON.toJson(programDescriptor.getArtifactId().toApiArtifactId())) .build()); }
@Override public JsonElement serialize(ProgramOptions src, Type typeOfSrc, JsonSerializationContext context) { JsonObject json = new JsonObject(); json.add("programId", context.serialize(src.getProgramId(), ProgramId.class)); json.add("arguments", context.serialize(src.getArguments(), Arguments.class)); json.add("userArguments", context.serialize(src.getUserArguments(), Arguments.class)); json.addProperty("debug", src.isDebug()); return json; } }
@Override public JsonElement serialize(ProgramOptions src, Type typeOfSrc, JsonSerializationContext context) { JsonObject json = new JsonObject(); json.add("programId", context.serialize(src.getProgramId(), ProgramId.class)); json.add("arguments", context.serialize(src.getArguments(), Arguments.class)); json.add("userArguments", context.serialize(src.getUserArguments(), Arguments.class)); json.addProperty("debug", src.isDebug()); return json; } }
builder.put(ProgramOptionConstants.PLUGIN_DIR, tempDir.getAbsolutePath()); return new SimpleProgramOptions(options.getProgramId(), new BasicArguments(builder.build()), options.getUserArguments(), options.isDebug());
builder.put(ProgramOptionConstants.PLUGIN_DIR, tempDir.getAbsolutePath()); return new SimpleProgramOptions(options.getProgramId(), new BasicArguments(builder.build()), options.getUserArguments(), options.isDebug());
/** * Creates a new instance of {@link ProgramOptions} with artifact localization information and with * extra system arguments, while maintaining other fields of the given {@link ProgramOptions}. * * @param options the original {@link ProgramOptions}. * @param localizeResources a {@link Map} of {@link LocalizeResource} to be localized to the remote container * @param tempDir a local temporary directory for creating files for artifact localization. * @param extraSystemArgs a set of extra system arguments to be added/updated * @return a new instance of {@link ProgramOptions} * @throws IOException if failed to create local copy of artifact files */ private ProgramOptions updateProgramOptions(ProgramOptions options, Map<String, LocalizeResource> localizeResources, File tempDir, Map<String, String> extraSystemArgs) throws IOException { Arguments systemArgs = options.getArguments(); Map<String, String> newSystemArgs = new HashMap<>(systemArgs.asMap()); newSystemArgs.putAll(extraSystemArgs); if (systemArgs.hasOption(ProgramOptionConstants.PLUGIN_DIR)) { File localDir = new File(systemArgs.getOption(ProgramOptionConstants.PLUGIN_DIR)); File archiveFile = new File(tempDir, "artifacts.jar"); BundleJarUtil.createJar(localDir, archiveFile); // Localize plugins to two files, one expanded into a directory, one not. localizeResources.put("artifacts", new LocalizeResource(archiveFile, true)); localizeResources.put("artifacts_archive.jar", new LocalizeResource(archiveFile, false)); newSystemArgs.put(ProgramOptionConstants.PLUGIN_DIR, "artifacts"); newSystemArgs.put(ProgramOptionConstants.PLUGIN_ARCHIVE, "artifacts_archive.jar"); } return new SimpleProgramOptions(options.getProgramId(), new BasicArguments(newSystemArgs), options.getUserArguments(), options.isDebug()); }
/** * Creates a new instance of {@link ProgramOptions} with artifact localization information and with * extra system arguments, while maintaining other fields of the given {@link ProgramOptions}. * * @param options the original {@link ProgramOptions}. * @param localizeResources a {@link Map} of {@link LocalizeResource} to be localized to the remote container * @param tempDir a local temporary directory for creating files for artifact localization. * @param extraSystemArgs a set of extra system arguments to be added/updated * @return a new instance of {@link ProgramOptions} * @throws IOException if failed to create local copy of artifact files */ private ProgramOptions updateProgramOptions(ProgramOptions options, Map<String, LocalizeResource> localizeResources, File tempDir, Map<String, String> extraSystemArgs) throws IOException { Arguments systemArgs = options.getArguments(); Map<String, String> newSystemArgs = new HashMap<>(systemArgs.asMap()); newSystemArgs.putAll(extraSystemArgs); if (systemArgs.hasOption(ProgramOptionConstants.PLUGIN_DIR)) { File localDir = new File(systemArgs.getOption(ProgramOptionConstants.PLUGIN_DIR)); File archiveFile = new File(tempDir, "artifacts.jar"); BundleJarUtil.createJar(localDir, archiveFile); // Localize plugins to two files, one expanded into a directory, one not. localizeResources.put("artifacts", new LocalizeResource(archiveFile, true)); localizeResources.put("artifacts_archive.jar", new LocalizeResource(archiveFile, false)); newSystemArgs.put(ProgramOptionConstants.PLUGIN_DIR, "artifacts"); newSystemArgs.put(ProgramOptionConstants.PLUGIN_ARCHIVE, "artifacts_archive.jar"); } return new SimpleProgramOptions(options.getProgramId(), new BasicArguments(newSystemArgs), options.getUserArguments(), options.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()); }
/** * 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()); }
new BasicArguments(userArguments), options.isDebug());
new BasicArguments(userArguments), options.isDebug());
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()); } }
"task", taskType.toString().toLowerCase(), contextConfig.getProgramOptions().getUserArguments().asMap())), options.isDebug());
"task", taskType.toString().toLowerCase(), contextConfig.getProgramOptions().getUserArguments().asMap())), options.isDebug());