@Override public JsonElement serialize(ApplicationSpecification src, Type typeOfSrc, JsonSerializationContext context) { JsonObject jsonObj = new JsonObject(); jsonObj.add("name", new JsonPrimitive(src.getName())); jsonObj.add("appVersion", new JsonPrimitive(src.getAppVersion())); if (src.getConfiguration() != null) { jsonObj.add("configuration", new JsonPrimitive(src.getConfiguration())); } jsonObj.add("artifactId", context.serialize(src.getArtifactId())); jsonObj.add("description", new JsonPrimitive(src.getDescription())); jsonObj.add("datasetModules", serializeMap(src.getDatasetModules(), context, String.class)); jsonObj.add("datasetInstances", serializeMap(src.getDatasets(), context, DatasetCreationSpec.class)); jsonObj.add("mapReduces", serializeMap(src.getMapReduce(), context, MapReduceSpecification.class)); jsonObj.add("sparks", serializeMap(src.getSpark(), context, SparkSpecification.class)); jsonObj.add("workflows", serializeMap(src.getWorkflows(), context, WorkflowSpecification.class)); jsonObj.add("services", serializeMap(src.getServices(), context, ServiceSpecification.class)); jsonObj.add("programSchedules", serializeMap(src.getProgramSchedules(), context, ScheduleCreationSpec.class)); jsonObj.add("workers", serializeMap(src.getWorkers(), context, WorkerSpecification.class)); jsonObj.add("plugins", serializeMap(src.getPlugins(), context, Plugin.class)); return jsonObj; }
private Iterable<ProgramSpecification> getProgramSpecs(ApplicationId appId) { ApplicationSpecification appSpec = store.getApplication(appId); return Iterables.concat(appSpec.getMapReduce().values(), appSpec.getServices().values(), appSpec.getSpark().values(), appSpec.getWorkers().values(), appSpec.getWorkflows().values()); }
@Override public String getName() { return delegate.getName(); }
@Override public Map<String, String> getSystemPropertiesToAdd() { ImmutableMap.Builder<String, String> properties = ImmutableMap.builder(); properties.put(ENTITY_NAME_KEY, appSpec.getName()); properties.put(VERSION_KEY, appId.getVersion()); String description = appSpec.getDescription(); if (!Strings.isNullOrEmpty(description)) { properties.put(DESCRIPTION_KEY, description); } if (!existing) { properties.put(CREATION_TIME_KEY, String.valueOf(System.currentTimeMillis())); } addPrograms(properties); addSchedules(properties); // appSpec.getPlugins() returns all instances of all plugins, so there may be duplicates. // we only store unique plugins right now Set<PluginClass> existingPluginClasses = new HashSet<>(); for (Plugin plugin : appSpec.getPlugins().values()) { if (!existingPluginClasses.contains(plugin.getPluginClass())) { addPlugin(plugin.getPluginClass(), null, properties); existingPluginClasses.add(plugin.getPluginClass()); } } return properties.build(); }
Map<ApplicationId, ApplicationSpecification> appSpecs = new HashMap<>(); for (ApplicationSpecification appSpec : store.getAllApplications(namespace)) { appSpecs.put(namespace.app(appSpec.getName(), appSpec.getAppVersion()), appSpec); ArtifactId artifactId = appSpec.getArtifactId(); ArtifactSummary artifactSummary = artifactId == null ? new ArtifactSummary(appSpec.getName(), null) : ArtifactSummary.from(artifactId); ApplicationRecord record = new ApplicationRecord(artifactSummary, appId, appSpec.getDescription(), ownerAdmin.getOwnerPrincipal(appId)); if (predicate.apply(record)) {
@Override public Map<String, Plugin> getPlugins() { return delegate.getPlugins(); } }
@Test public void testWorkerInstances() { ApplicationSpecification spec = Specifications.from(new AppWithWorker()); ApplicationId appId = NamespaceId.DEFAULT.app(spec.getName()); store.addApplication(appId, spec); ProgramId programId = appId.worker(AppWithWorker.WORKER); int instancesFromSpec = spec.getWorkers().get(AppWithWorker.WORKER).getInstances(); Assert.assertEquals(1, instancesFromSpec); int instances = store.getWorkerInstances(programId); Assert.assertEquals(instancesFromSpec, instances); store.setWorkerInstances(programId, 9); instances = store.getWorkerInstances(programId); Assert.assertEquals(9, instances); }
@Override public Map<String, SparkSpecification> getSpark() { return delegate.getSpark(); }
@Override public Map<String, ServiceSpecification> getServices() { return delegate.getServices(); }
@Override public Map<String, WorkflowSpecification> getWorkflows() { return delegate.getWorkflows(); }
@Override public Map<String, WorkerSpecification> getWorkers() { return delegate.getWorkers(); }
@Override public Map<String, MapReduceSpecification> getMapReduce() { return delegate.getMapReduce(); }
ArtifactId currentArtifact = currentSpec.getArtifactId(); currentSpec.getConfiguration() : new Gson().toJson(requestedConfigObj);
@Override public ArtifactId getArtifactId() { return delegate.getArtifactId(); }
private Iterable<ProgramSpecification> getProgramSpecs(ApplicationId appId) { ApplicationSpecification appSpec = store.getApplication(appId); return Iterables.concat(appSpec.getFlows().values(), appSpec.getMapReduce().values(), appSpec.getServices().values(), appSpec.getSpark().values(), appSpec.getWorkers().values(), appSpec.getWorkflows().values()); }
@Override protected String getName(ApplicationSpecification input) { return input.getName(); } }
@Override public Map<String, String> getSystemPropertiesToAdd() { ImmutableMap.Builder<String, String> properties = ImmutableMap.builder(); properties.put(ENTITY_NAME_KEY, appSpec.getName()); properties.put(VERSION_KEY, appId.getVersion()); String description = appSpec.getDescription(); if (!Strings.isNullOrEmpty(description)) { properties.put(DESCRIPTION_KEY, description); } properties.put(CREATION_TIME_KEY, creationTime); addPrograms(properties); addSchedules(properties); // appSpec.getPlugins() returns all instances of all plugins, so there may be duplicates. // we only store unique plugins right now Set<PluginClass> existingPluginClasses = new HashSet<>(); for (Plugin plugin : appSpec.getPlugins().values()) { if (!existingPluginClasses.contains(plugin.getPluginClass())) { SystemMetadataProvider.addPlugin(plugin.getPluginClass(), null, properties); existingPluginClasses.add(plugin.getPluginClass()); } } return properties.build(); }
Map<ApplicationId, ApplicationSpecification> appSpecs = new HashMap<>(); for (ApplicationSpecification appSpec : store.getAllApplications(namespace)) { appSpecs.put(namespace.app(appSpec.getName(), appSpec.getAppVersion()), appSpec); ArtifactId artifactId = appSpec.getArtifactId(); ArtifactSummary artifactSummary = artifactId == null ? new ArtifactSummary(appSpec.getName(), null) : ArtifactSummary.from(artifactId); ApplicationRecord record = new ApplicationRecord(artifactSummary, appId, appSpec.getDescription(), ownerAdmin.getOwnerPrincipal(appId)); if (predicate.apply(record)) {
@Override public Map<String, Plugin> getPlugins() { return delegate.getPlugins(); }
@Override public Map<String, SparkSpecification> getSpark() { return delegate.getSpark(); }