@Override public String getName() { return delegate.getName(); }
@Override protected String getName(ApplicationSpecification input) { return input.getName(); } }
@Override protected String getName(ApplicationSpecification input) { return input.getName(); } }
@Override public String getName() { return delegate.getName(); }
/** * Delete the metrics for an application. * * @param applicationId the application to delete metrics for. */ private void deleteMetrics(ApplicationId applicationId) { ApplicationSpecification spec = this.store.getApplication(applicationId); long endTs = System.currentTimeMillis() / 1000; Map<String, String> tags = new LinkedHashMap<>(); tags.put(Constants.Metrics.Tag.NAMESPACE, applicationId.getNamespace()); // add or replace application name in the tagMap tags.put(Constants.Metrics.Tag.APP, spec.getName()); MetricDeleteQuery deleteQuery = new MetricDeleteQuery(0, endTs, Collections.emptySet(), tags, new ArrayList<>(tags.keySet())); metricStore.delete(deleteQuery); }
/** * Delete the metrics for an application. * * @param applicationId the application to delete metrics for. */ private void deleteMetrics(ApplicationId applicationId) { ApplicationSpecification spec = this.store.getApplication(applicationId); long endTs = System.currentTimeMillis() / 1000; Map<String, String> tags = new LinkedHashMap<>(); tags.put(Constants.Metrics.Tag.NAMESPACE, applicationId.getNamespace()); // add or replace application name in the tagMap tags.put(Constants.Metrics.Tag.APP, spec.getName()); MetricDeleteQuery deleteQuery = new MetricDeleteQuery(0, endTs, Collections.emptySet(), tags, new ArrayList<>(tags.keySet())); metricStore.delete(deleteQuery); }
@TransactionPolicy(TransactionControl.EXPLICIT) @Override public void destroy() { super.destroy(); ProgramStatus status = getContext().getState().getStatus(); WRAPPERLOGGER.info("Pipeline '{}' {}", getContext().getApplicationSpecification().getName(), status == ProgramStatus.COMPLETED ? "succeeded" : status.name().toLowerCase()); }
public SparkPipelineRuntime(SparkClientContext context) { super(context.getNamespace(), context.getApplicationSpecification().getName(), context.getLogicalStartTime(), new BasicArguments(context), context.getMetrics(), context, context, context, context, context); }
@PUT @Path("write/{data}") public void write(HttpServiceRequest request, HttpServiceResponder responder, @PathParam("data") String data) { String appName = getContext().getApplicationSpecification().getName(); KeyValueTable dataset = getContext().getDataset(tableName); dataset.write(appName + "." + data, data); responder.sendStatus(200); } }
public SparkPipelineRuntime(JavaSparkExecutionContext sec, long batchTime) { super(sec.getNamespace(), sec.getApplicationSpecification().getName(), batchTime, new BasicArguments(sec), sec.getMetrics(), sec.getPluginContext(), sec.getServiceDiscoverer(), sec.getSecureStore()); } }
private void addApplication(String namespace, Application app) { ApplicationSpecification appSpec = Specifications.from(app); store.addApplication(new ApplicationId(namespace, appSpec.getName()), appSpec); }
public DefaultStreamingContext(StageSpec stageSpec, JavaSparkExecutionContext sec, JavaStreamingContext jsc) { super(new PipelineRuntime(sec.getNamespace(), sec.getApplicationSpecification().getName(), sec.getLogicalStartTime(), new BasicArguments(sec), sec.getMetrics(), sec.getPluginContext(), sec.getServiceDiscoverer(), sec, sec, sec), stageSpec); this.sec = sec; this.jsc = jsc; this.admin = sec.getAdmin(); }
public PluginFunctionContext(StageSpec stageSpec, JavaSparkExecutionContext sec, Map<String, String> arguments, long logicalStartTime, StageStatisticsCollector collector) { this.namespace = sec.getNamespace(); this.pipelineName = sec.getApplicationSpecification().getName(); this.stageSpec = stageSpec; this.logicalStartTime = logicalStartTime; this.arguments = new BasicArguments(sec); this.pluginContext = sec.getPluginContext(); this.serviceDiscoverer = sec.getServiceDiscoverer(); this.metrics = sec.getMetrics(); this.secureStore = sec.getSecureStore(); this.dataTracer = sec.getDataTracer(stageSpec.getName()); this.pipelinePluginContext = getPluginContext(); this.collector = collector; }
@Test public void testServiceDeletion() { // Store the application specification AbstractApplication app = new AppWithServices(); ApplicationSpecification appSpec = Specifications.from(app); ApplicationId appId = NamespaceId.DEFAULT.app(appSpec.getName()); store.addApplication(appId, appSpec); AbstractApplication newApp = new AppWithNoServices(); // get the delete program specs after deploying AppWithNoServices List<ProgramSpecification> programSpecs = store.getDeletedProgramSpecifications(appId, Specifications.from(newApp)); //verify the result. Assert.assertEquals(1, programSpecs.size()); Assert.assertEquals("NoOpService", programSpecs.get(0).getName()); }
@Test public void testLoadingProgram() throws Exception { ApplicationSpecification appSpec = Specifications.from(new FooApp()); ApplicationId appId = NamespaceId.DEFAULT.app(appSpec.getName()); store.addApplication(appId, appSpec); ProgramDescriptor descriptor = store.loadProgram(appId.mr("mrJob1")); Assert.assertNotNull(descriptor); MapReduceSpecification mrSpec = descriptor.getSpecification(); Assert.assertEquals("mrJob1", mrSpec.getName()); Assert.assertEquals(FooMapReduceJob.class.getName(), mrSpec.getClassName()); }
@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); }
@Test public void testServiceInstances() { ApplicationSpecification appSpec = Specifications.from(new AppWithServices()); ApplicationId appId = NamespaceId.DEFAULT.app(appSpec.getName()); store.addApplication(appId, appSpec); // Test setting of service instances ProgramId programId = appId.program(ProgramType.SERVICE, "NoOpService"); int count = store.getServiceInstances(programId); Assert.assertEquals(1, count); store.setServiceInstances(programId, 10); count = store.getServiceInstances(programId); Assert.assertEquals(10, count); ApplicationSpecification newSpec = store.getApplication(appId); Assert.assertNotNull(newSpec); Map<String, ServiceSpecification> services = newSpec.getServices(); Assert.assertEquals(1, services.size()); ServiceSpecification serviceSpec = services.get("NoOpService"); Assert.assertEquals(10, serviceSpec.getInstances()); }
@Test public void testRemoveAllApplications() { ApplicationSpecification spec = Specifications.from(new AllProgramsApp()); NamespaceId namespaceId = new NamespaceId("account1"); ApplicationId appId = namespaceId.app(spec.getName()); store.addApplication(appId, spec); Assert.assertNotNull(store.getApplication(appId)); // removing all applications store.removeAllApplications(namespaceId); Assert.assertNull(store.getApplication(appId)); }
@Test public void testRemoveApplication() { ApplicationSpecification spec = Specifications.from(new AllProgramsApp()); NamespaceId namespaceId = new NamespaceId("account1"); ApplicationId appId = namespaceId.app(spec.getName()); store.addApplication(appId, spec); Assert.assertNotNull(store.getApplication(appId)); // removing application store.removeApplication(appId); Assert.assertNull(store.getApplication(appId)); }
/** * Good test */ @Test public void testGoodApplication() { ApplicationSpecification appSpec = Specifications.from(new AllProgramsApp()); ApplicationSpecificationAdapter adapter = ApplicationSpecificationAdapter.create(); ApplicationSpecification newSpec = adapter.fromJson(adapter.toJson(appSpec)); ApplicationVerification app = new ApplicationVerification(); VerifyResult result = app.verify(new ApplicationId("test", newSpec.getName()), newSpec); Assert.assertSame(result.getMessage(), result.getStatus(), VerifyResult.Status.SUCCESS); }