Search in sources :

Example 6 with ApplicationSpecification

use of io.cdap.cdap.api.app.ApplicationSpecification in project cdap by caskdata.

the class DistributedWorkerProgramRunner method setupLaunchConfig.

@Override
protected void setupLaunchConfig(ProgramLaunchConfig launchConfig, Program program, ProgramOptions options, CConfiguration cConf, Configuration hConf, File tempDir) {
    ApplicationSpecification appSpec = program.getApplicationSpecification();
    WorkerSpecification workerSpec = appSpec.getWorkers().get(program.getName());
    String instances = options.getArguments().getOption(ProgramOptionConstants.INSTANCES, String.valueOf(workerSpec.getInstances()));
    launchConfig.addRunnable(workerSpec.getName(), new WorkerTwillRunnable(workerSpec.getName()), Integer.parseInt(instances), options.getUserArguments().asMap(), workerSpec.getResources());
}
Also used : ApplicationSpecification(io.cdap.cdap.api.app.ApplicationSpecification) WorkerSpecification(io.cdap.cdap.api.worker.WorkerSpecification)

Example 7 with ApplicationSpecification

use of io.cdap.cdap.api.app.ApplicationSpecification in project cdap by caskdata.

the class ProgramLifecycleHttpHandlerTest method testProgramList.

/**
 * Tests for program list calls
 */
@Test
public void testProgramList() throws Exception {
    // test initial state
    testListInitialState(TEST_NAMESPACE2, ProgramType.MAPREDUCE);
    testListInitialState(TEST_NAMESPACE1, ProgramType.WORKFLOW);
    testListInitialState(TEST_NAMESPACE2, ProgramType.SPARK);
    testListInitialState(TEST_NAMESPACE1, ProgramType.SERVICE);
    // deploy AllProgramsApp in namespace1 and verify
    deploy(AllProgramsApp.class, 200, Constants.Gateway.API_VERSION_3_TOKEN, TEST_NAMESPACE1);
    // deploy AppWithServices in namespace2 and verify
    deploy(AppWithServices.class, 200, Constants.Gateway.API_VERSION_3_TOKEN, TEST_NAMESPACE2);
    ApplicationSpecification allProgramSpec = Specifications.from(new AllProgramsApp());
    // verify list by namespace
    for (io.cdap.cdap.api.app.ProgramType type : io.cdap.cdap.api.app.ProgramType.values()) {
        Set<String> programsByType = allProgramSpec.getProgramsByType(type);
        verifyProgramList(TEST_NAMESPACE1, ProgramType.valueOf(type.name()), programsByType.size());
    }
    verifyProgramList(TEST_NAMESPACE2, ProgramType.SERVICE, 1);
    // verify list by app
    for (io.cdap.cdap.api.app.ProgramType type : io.cdap.cdap.api.app.ProgramType.values()) {
        Set<String> programsByType = allProgramSpec.getProgramsByType(type);
        verifyProgramList(TEST_NAMESPACE1, AllProgramsApp.NAME, ProgramType.valueOf(type.name()), programsByType.size());
    }
    verifyProgramList(TEST_NAMESPACE2, AppWithServices.NAME, ProgramType.SERVICE, 1);
    // verify invalid namespace
    Assert.assertEquals(404, getAppFDetailResponseCode(TEST_NAMESPACE1, AppWithServices.SERVICE_NAME));
    // verify invalid app
    Assert.assertEquals(404, getAppFDetailResponseCode(TEST_NAMESPACE1, "random"));
}
Also used : ApplicationSpecification(io.cdap.cdap.api.app.ApplicationSpecification) AllProgramsApp(io.cdap.cdap.AllProgramsApp) Test(org.junit.Test)

Example 8 with ApplicationSpecification

use of io.cdap.cdap.api.app.ApplicationSpecification in project cdap by caskdata.

the class ApplicationVerificationTest method testGoodApplication.

/**
 * 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);
}
Also used : ApplicationSpecification(io.cdap.cdap.api.app.ApplicationSpecification) ApplicationSpecificationAdapter(io.cdap.cdap.internal.app.ApplicationSpecificationAdapter) AllProgramsApp(io.cdap.cdap.AllProgramsApp) VerifyResult(io.cdap.cdap.app.verification.VerifyResult) ApplicationId(io.cdap.cdap.proto.id.ApplicationId) Test(org.junit.Test)

Example 9 with ApplicationSpecification

use of io.cdap.cdap.api.app.ApplicationSpecification in project cdap by caskdata.

the class PreferencesHttpHandlerInternalTest method addApplication.

private void addApplication(String namespace, Application app) {
    ApplicationSpecification appSpec = Specifications.from(app);
    store.addApplication(new ApplicationId(namespace, appSpec.getName()), appSpec);
}
Also used : ApplicationSpecification(io.cdap.cdap.api.app.ApplicationSpecification) ApplicationId(io.cdap.cdap.proto.id.ApplicationId)

Example 10 with ApplicationSpecification

use of io.cdap.cdap.api.app.ApplicationSpecification in project cdap by caskdata.

the class WorkflowVerificationTest method testGoodWorkflow.

@Test
public void testGoodWorkflow() throws Exception {
    ApplicationSpecification appSpec = Specifications.from(new GoodWorkflowApp());
    verifyGoodWorkflowSpecifications(appSpec);
    verifyAnotherGoodWorkflowSpecification(appSpec);
    verifyWorkflowWithLocalDatasetSpecification(appSpec);
    ApplicationSpecificationAdapter adapter = ApplicationSpecificationAdapter.create();
    ApplicationSpecification newSpec = adapter.fromJson(adapter.toJson(appSpec));
    verifyGoodWorkflowSpecifications(newSpec);
    verifyAnotherGoodWorkflowSpecification(newSpec);
    verifyWorkflowWithLocalDatasetSpecification(newSpec);
}
Also used : ApplicationSpecification(io.cdap.cdap.api.app.ApplicationSpecification) ApplicationSpecificationAdapter(io.cdap.cdap.internal.app.ApplicationSpecificationAdapter) GoodWorkflowApp(io.cdap.cdap.GoodWorkflowApp) Test(org.junit.Test)

Aggregations

ApplicationSpecification (io.cdap.cdap.api.app.ApplicationSpecification)228 ApplicationId (io.cdap.cdap.proto.id.ApplicationId)114 ProgramId (io.cdap.cdap.proto.id.ProgramId)90 Test (org.junit.Test)90 AllProgramsApp (io.cdap.cdap.AllProgramsApp)54 ProgramRunId (io.cdap.cdap.proto.id.ProgramRunId)52 ProgramType (io.cdap.cdap.proto.ProgramType)50 ArrayList (java.util.ArrayList)42 HashMap (java.util.HashMap)40 NamespaceId (io.cdap.cdap.proto.id.NamespaceId)38 ArtifactId (io.cdap.cdap.api.artifact.ArtifactId)32 NotFoundException (io.cdap.cdap.common.NotFoundException)30 ProgramDescriptor (io.cdap.cdap.app.program.ProgramDescriptor)28 Map (java.util.Map)28 CConfiguration (io.cdap.cdap.common.conf.CConfiguration)24 IOException (java.io.IOException)24 HashSet (java.util.HashSet)22 RunId (org.apache.twill.api.RunId)22 ApplicationNotFoundException (io.cdap.cdap.common.ApplicationNotFoundException)20 DefaultApplicationSpecification (io.cdap.cdap.internal.app.DefaultApplicationSpecification)20