use of co.cask.cdap.proto.id.FlowletId in project cdap by caskdata.
the class GetProgramInstancesCommand method perform.
@Override
@SuppressWarnings("deprecation")
public void perform(Arguments arguments, PrintStream output) throws Exception {
String[] programIdParts = arguments.get(elementType.getArgumentName().toString()).split("\\.");
ApplicationId appId = cliConfig.getCurrentNamespace().app(programIdParts[0]);
int instances;
switch(elementType) {
case FLOWLET:
if (programIdParts.length < 3) {
throw new CommandInputError(this);
}
String flowId = programIdParts[1];
String flowletName = programIdParts[2];
FlowletId flowlet = appId.flow(flowId).flowlet(flowletName);
instances = programClient.getFlowletInstances(flowlet);
break;
case WORKER:
if (programIdParts.length < 2) {
throw new CommandInputError(this);
}
String workerId = programIdParts[1];
ProgramId worker = appId.worker(workerId);
instances = programClient.getWorkerInstances(worker);
break;
case SERVICE:
if (programIdParts.length < 2) {
throw new CommandInputError(this);
}
String serviceName = programIdParts[1];
instances = programClient.getServiceInstances(appId.service(serviceName));
break;
default:
// TODO: remove this
throw new IllegalArgumentException("Unrecognized program element type for scaling: " + elementType);
}
output.println(instances);
}
use of co.cask.cdap.proto.id.FlowletId in project cdap by caskdata.
the class LineageDatasetTest method testOneRelation.
@Test
public void testOneRelation() throws Exception {
final LineageDataset lineageDataset = getLineageDataset("testOneRelation");
Assert.assertNotNull(lineageDataset);
TransactionExecutor txnl = dsFrameworkUtil.newInMemoryTransactionExecutor((TransactionAware) lineageDataset);
final RunId runId = RunIds.generate(10000);
final DatasetId datasetInstance = new DatasetId("default", "dataset1");
final ProgramId program = new ProgramId("default", "app1", ProgramType.FLOW, "flow1");
final FlowletId flowlet = program.flowlet("flowlet1");
final ProgramRunId run = program.run(runId.getId());
final long accessTimeMillis = System.currentTimeMillis();
txnl.execute(new TransactionExecutor.Subroutine() {
@Override
public void apply() throws Exception {
lineageDataset.addAccess(run, datasetInstance, AccessType.READ, accessTimeMillis, flowlet);
}
});
txnl.execute(new TransactionExecutor.Subroutine() {
@Override
public void apply() throws Exception {
Relation expected = new Relation(datasetInstance, program, AccessType.READ, runId, ImmutableSet.of(flowlet));
Set<Relation> relations = lineageDataset.getRelations(datasetInstance, 0, 100000, Predicates.<Relation>alwaysTrue());
Assert.assertEquals(1, relations.size());
Assert.assertEquals(expected, relations.iterator().next());
Assert.assertEquals(toSet(program, datasetInstance), lineageDataset.getEntitiesForRun(run));
Assert.assertEquals(ImmutableList.of(accessTimeMillis), lineageDataset.getAccessTimesForRun(run));
}
});
}
Aggregations