Search in sources :

Example 1 with ProgramClient

use of co.cask.cdap.client.ProgramClient in project cdap by caskdata.

the class CLIMainTest method setUpClass.

@BeforeClass
public static void setUpClass() throws Exception {
    cliConfig = createCLIConfig(STANDALONE.getBaseURI());
    LaunchOptions launchOptions = new LaunchOptions(LaunchOptions.DEFAULT.getUri(), true, true, false);
    cliMain = new CLIMain(launchOptions, cliConfig);
    programClient = new ProgramClient(cliConfig.getClientConfig());
    queryClient = new QueryClient(cliConfig.getClientConfig());
    cli = cliMain.getCLI();
    testCommandOutputContains(cli, "connect " + STANDALONE.getBaseURI(), "Successfully connected");
    testCommandOutputNotContains(cli, "list apps", FakeApp.NAME);
    File appJarFile = createAppJarFile(FakeApp.class);
    testCommandOutputContains(cli, String.format("load artifact %s name %s version %s", appJarFile.getAbsolutePath(), FakeApp.NAME, V1), "Successfully added artifact");
    testCommandOutputContains(cli, "deploy app " + appJarFile.getAbsolutePath(), "Successfully deployed app");
    testCommandOutputContains(cli, String.format("create app %s version %s %s %s %s", FakeApp.NAME, V1_SNAPSHOT, FakeApp.NAME, V1, ArtifactScope.USER), "Successfully created application");
    File pluginJarFile = createPluginJarFile(FakePlugin.class);
    testCommandOutputContains(cli, String.format("load artifact %s config-file %s", pluginJarFile.getAbsolutePath(), createPluginConfig().getAbsolutePath()), "Successfully");
    if (!appJarFile.delete()) {
        LOG.warn("Failed to delete temporary app jar file: {}", appJarFile.getAbsolutePath());
    }
}
Also used : ProgramClient(co.cask.cdap.client.ProgramClient) File(java.io.File) QueryClient(co.cask.cdap.client.QueryClient) BeforeClass(org.junit.BeforeClass)

Example 2 with ProgramClient

use of co.cask.cdap.client.ProgramClient in project cdap by caskdata.

the class GenerateClientUsageExample method programClient.

public void programClient() throws Exception {
    // Construct the client used to interact with CDAP
    ProgramClient programClient = new ProgramClient(clientConfig);
    // Start a service in the WordCount example
    programClient.start(NamespaceId.DEFAULT.app("WordCount").service("RetrieveCounts"));
    // Fetch live information from the HelloWorld example
    // Live info includes the address of an component’s container host and the container’s debug port,
    // formatted in JSON
    programClient.getLiveInfo(NamespaceId.DEFAULT.app("HelloWorld").service("greet"));
    // Fetch program logs in the WordCount example
    programClient.getProgramLogs(NamespaceId.DEFAULT.app("WordCount").service("RetrieveCounts"), 0, Long.MAX_VALUE);
    // Scale a service in the HelloWorld example
    programClient.setServiceInstances(NamespaceId.DEFAULT.app("HelloWorld").service("greet"), 3);
    // Stop a service in the HelloWorld example
    programClient.stop(NamespaceId.DEFAULT.app("HelloWorld").service("greet"));
    // Start, scale, and stop a flow in the WordCount example
    programClient.start(NamespaceId.DEFAULT.app("WordCount").flow("WordCountFlow"));
    // Fetch the last 10 flow runs in the WordCount example
    programClient.getAllProgramRuns(NamespaceId.DEFAULT.app("WordCount").flow("WordCountFlow"), 0, Long.MAX_VALUE, 10);
    // Scale a flowlet in the WordCount example
    programClient.setFlowletInstances(NamespaceId.DEFAULT.app("WordCount").flow("WordCountFlow").flowlet("Tokenizer"), 3);
    // Stop a flow in the WordCount example
    programClient.stop(NamespaceId.DEFAULT.app("WordCount").flow("WordCountFlow"));
}
Also used : ProgramClient(co.cask.cdap.client.ProgramClient)

Aggregations

ProgramClient (co.cask.cdap.client.ProgramClient)2 QueryClient (co.cask.cdap.client.QueryClient)1 File (java.io.File)1 BeforeClass (org.junit.BeforeClass)1