use of co.cask.cdap.api.flow.FlowSpecification in project cdap by caskdata.
the class DefaultStore method updateFlowletInstancesInAppSpec.
private static ApplicationSpecification updateFlowletInstancesInAppSpec(ApplicationSpecification appSpec, ProgramId id, String flowletId, int count) {
FlowSpecification flowSpec = getFlowSpecOrFail(id, appSpec);
FlowletDefinition flowletDef = getFlowletDefinitionOrFail(flowSpec, flowletId, id);
FlowletDefinition adjustedFlowletDef = new FlowletDefinition(flowletDef, count);
return replaceFlowletInAppSpec(appSpec, id, flowSpec, adjustedFlowletDef);
}
use of co.cask.cdap.api.flow.FlowSpecification in project cdap by caskdata.
the class DefaultStore method getFlowletInstances.
@Override
public int getFlowletInstances(ProgramId id, String flowletId) {
return Transactionals.execute(transactional, context -> {
ApplicationSpecification appSpec = getAppSpecOrFail(getAppMetadataStore(context), id);
FlowSpecification flowSpec = getFlowSpecOrFail(id, appSpec);
FlowletDefinition flowletDef = getFlowletDefinitionOrFail(flowSpec, flowletId, id);
return flowletDef.getInstances();
});
}
use of co.cask.cdap.api.flow.FlowSpecification in project cdap by caskdata.
the class ProgramLifecycleService method setFlowletInstances.
private void setFlowletInstances(ProgramId programId, String flowletId, int instances) throws ExecutionException, InterruptedException, BadRequestException {
int oldInstances = store.getFlowletInstances(programId, flowletId);
if (oldInstances != instances) {
FlowSpecification flowSpec = store.setFlowletInstances(programId, flowletId, instances);
ProgramRuntimeService.RuntimeInfo runtimeInfo = findRuntimeInfo(programId);
if (runtimeInfo != null) {
runtimeInfo.getController().command(ProgramOptionConstants.INSTANCES, ImmutableMap.of("flowlet", flowletId, "newInstances", String.valueOf(instances), "oldFlowSpec", GSON.toJson(flowSpec, FlowSpecification.class))).get();
}
}
}
use of co.cask.cdap.api.flow.FlowSpecification in project cdap by caskdata.
the class DefaultStoreTest method testLoadingProgram.
@Test
public void testLoadingProgram() throws Exception {
ApplicationSpecification appSpec = Specifications.from(new ToyApp());
ApplicationId appId = NamespaceId.DEFAULT.app(appSpec.getName());
store.addApplication(appId, appSpec);
ProgramDescriptor descriptor = store.loadProgram(appId.flow("ToyFlow"));
Assert.assertNotNull(descriptor);
FlowSpecification flowSpec = descriptor.getSpecification();
Assert.assertEquals("ToyFlow", flowSpec.getName());
}
use of co.cask.cdap.api.flow.FlowSpecification in project cdap by caskdata.
the class FlowVerificationTest method testValidFlow.
@Test
public void testValidFlow() throws Exception {
ApplicationSpecification appSpec = Specifications.from(new WebCrawlApp());
ApplicationSpecificationAdapter adapter = ApplicationSpecificationAdapter.create(new ReflectionSchemaGenerator());
ApplicationSpecification newSpec = adapter.fromJson(adapter.toJson(appSpec));
FlowVerification flowSpec = new FlowVerification();
for (Map.Entry<String, FlowSpecification> entry : newSpec.getFlows().entrySet()) {
VerifyResult result = flowSpec.verify(new ApplicationId("test", newSpec.getName()), entry.getValue());
Assert.assertTrue(result.getStatus() == VerifyResult.Status.SUCCESS);
}
}
Aggregations