Search in sources :

Example 1 with DefaultClusterClientServiceLoader

use of org.apache.flink.client.deployment.DefaultClusterClientServiceLoader in project flink by apache.

the class CliFrontendRunTest method verifyCliFrontend.

// --------------------------------------------------------------------------------------------
public static void verifyCliFrontend(Configuration configuration, AbstractCustomCommandLine cli, String[] parameters, int expectedParallelism, boolean isDetached) throws Exception {
    RunTestingCliFrontend testFrontend = new RunTestingCliFrontend(configuration, new DefaultClusterClientServiceLoader(), cli, expectedParallelism, isDetached);
    // verifies the expected values (see below)
    testFrontend.run(parameters);
}
Also used : DefaultClusterClientServiceLoader(org.apache.flink.client.deployment.DefaultClusterClientServiceLoader)

Example 2 with DefaultClusterClientServiceLoader

use of org.apache.flink.client.deployment.DefaultClusterClientServiceLoader in project flink by apache.

the class RestClusterClientTest method testRESTManualConfigurationOverride.

/**
 * Tests that command line options override the configuration settings.
 */
@Test
public void testRESTManualConfigurationOverride() throws Exception {
    final String configuredHostname = "localhost";
    final int configuredPort = 1234;
    final Configuration configuration = new Configuration();
    configuration.setString(JobManagerOptions.ADDRESS, configuredHostname);
    configuration.setInteger(JobManagerOptions.PORT, configuredPort);
    configuration.setString(RestOptions.ADDRESS, configuredHostname);
    configuration.setInteger(RestOptions.PORT, configuredPort);
    final DefaultCLI defaultCLI = new DefaultCLI();
    final String manualHostname = "123.123.123.123";
    final int manualPort = 4321;
    final String[] args = { "-m", manualHostname + ':' + manualPort };
    CommandLine commandLine = defaultCLI.parseCommandLineOptions(args, false);
    final ClusterClientServiceLoader serviceLoader = new DefaultClusterClientServiceLoader();
    final Configuration executorConfig = defaultCLI.toConfiguration(commandLine);
    final ClusterClientFactory<StandaloneClusterId> clusterFactory = serviceLoader.getClusterClientFactory(executorConfig);
    checkState(clusterFactory != null);
    final ClusterDescriptor<StandaloneClusterId> clusterDescriptor = clusterFactory.createClusterDescriptor(executorConfig);
    final RestClusterClient<?> clusterClient = (RestClusterClient<?>) clusterDescriptor.retrieve(clusterFactory.getClusterId(executorConfig)).getClusterClient();
    URL webMonitorBaseUrl = clusterClient.getWebMonitorBaseUrl().get();
    assertThat(webMonitorBaseUrl.getHost(), equalTo(manualHostname));
    assertThat(webMonitorBaseUrl.getPort(), equalTo(manualPort));
}
Also used : Configuration(org.apache.flink.configuration.Configuration) DefaultClusterClientServiceLoader(org.apache.flink.client.deployment.DefaultClusterClientServiceLoader) TestRestServerEndpoint(org.apache.flink.runtime.rest.util.TestRestServerEndpoint) StandaloneClusterId(org.apache.flink.client.deployment.StandaloneClusterId) URL(java.net.URL) CommandLine(org.apache.commons.cli.CommandLine) DefaultCLI(org.apache.flink.client.cli.DefaultCLI) ClusterClientServiceLoader(org.apache.flink.client.deployment.ClusterClientServiceLoader) DefaultClusterClientServiceLoader(org.apache.flink.client.deployment.DefaultClusterClientServiceLoader) Test(org.junit.Test)

Example 3 with DefaultClusterClientServiceLoader

use of org.apache.flink.client.deployment.DefaultClusterClientServiceLoader in project flink by apache.

the class CliFrontendRunWithYarnTest method testRun.

@Test
public void testRun() throws Exception {
    String testJarPath = getTestJarPath("BatchWordCount.jar").getAbsolutePath();
    Configuration configuration = new Configuration();
    configuration.setString(JobManagerOptions.ADDRESS, "localhost");
    configuration.setInteger(JobManagerOptions.PORT, 8081);
    configuration.set(TaskManagerOptions.TOTAL_FLINK_MEMORY, MemorySize.parse("1g"));
    final ClusterClientServiceLoader testServiceLoader = new DefaultClusterClientServiceLoader();
    final FlinkYarnSessionCli yarnCLI = new FlinkYarnSessionCli(configuration, testServiceLoader, tmp.getRoot().getAbsolutePath(), "y", "yarn", true);
    // test detached mode
    {
        String[] parameters = { "-m", "yarn-cluster", "-p", "2", "-d", testJarPath };
        verifyCliFrontend(configuration, testServiceLoader, yarnCLI, parameters, 2, true);
    }
    // test detached mode
    {
        String[] parameters = { "-m", "yarn-cluster", "-p", "2", "-yd", testJarPath };
        verifyCliFrontend(configuration, testServiceLoader, yarnCLI, parameters, 2, true);
    }
}
Also used : Configuration(org.apache.flink.configuration.Configuration) DefaultClusterClientServiceLoader(org.apache.flink.client.deployment.DefaultClusterClientServiceLoader) DefaultClusterClientServiceLoader(org.apache.flink.client.deployment.DefaultClusterClientServiceLoader) ClusterClientServiceLoader(org.apache.flink.client.deployment.ClusterClientServiceLoader) FlinkYarnSessionCli(org.apache.flink.yarn.cli.FlinkYarnSessionCli) Test(org.junit.Test)

Example 4 with DefaultClusterClientServiceLoader

use of org.apache.flink.client.deployment.DefaultClusterClientServiceLoader in project flink by apache.

the class KubernetesClusterClientFactoryTest method testKubernetesClusterClientFactoryDiscoveryHelper.

private void testKubernetesClusterClientFactoryDiscoveryHelper(final String targetName) {
    final Configuration configuration = new Configuration();
    configuration.setString(DeploymentOptions.TARGET, targetName);
    final ClusterClientServiceLoader serviceLoader = new DefaultClusterClientServiceLoader();
    final ClusterClientFactory<String> factory = serviceLoader.getClusterClientFactory(configuration);
    assertTrue(factory instanceof KubernetesClusterClientFactory);
}
Also used : Configuration(org.apache.flink.configuration.Configuration) DefaultClusterClientServiceLoader(org.apache.flink.client.deployment.DefaultClusterClientServiceLoader) DefaultClusterClientServiceLoader(org.apache.flink.client.deployment.DefaultClusterClientServiceLoader) ClusterClientServiceLoader(org.apache.flink.client.deployment.ClusterClientServiceLoader)

Example 5 with DefaultClusterClientServiceLoader

use of org.apache.flink.client.deployment.DefaultClusterClientServiceLoader in project flink by apache.

the class YarnClusterClientFactoryTest method testYarnClusterClientFactoryDiscoveryHelper.

private void testYarnClusterClientFactoryDiscoveryHelper(final String targetName) {
    final Configuration configuration = new Configuration();
    configuration.setString(DeploymentOptions.TARGET, targetName);
    final ClusterClientServiceLoader serviceLoader = new DefaultClusterClientServiceLoader();
    final ClusterClientFactory<ApplicationId> factory = serviceLoader.getClusterClientFactory(configuration);
    assertTrue(factory instanceof YarnClusterClientFactory);
}
Also used : Configuration(org.apache.flink.configuration.Configuration) DefaultClusterClientServiceLoader(org.apache.flink.client.deployment.DefaultClusterClientServiceLoader) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) DefaultClusterClientServiceLoader(org.apache.flink.client.deployment.DefaultClusterClientServiceLoader) ClusterClientServiceLoader(org.apache.flink.client.deployment.ClusterClientServiceLoader)

Aggregations

DefaultClusterClientServiceLoader (org.apache.flink.client.deployment.DefaultClusterClientServiceLoader)5 ClusterClientServiceLoader (org.apache.flink.client.deployment.ClusterClientServiceLoader)4 Configuration (org.apache.flink.configuration.Configuration)4 Test (org.junit.Test)2 URL (java.net.URL)1 CommandLine (org.apache.commons.cli.CommandLine)1 DefaultCLI (org.apache.flink.client.cli.DefaultCLI)1 StandaloneClusterId (org.apache.flink.client.deployment.StandaloneClusterId)1 TestRestServerEndpoint (org.apache.flink.runtime.rest.util.TestRestServerEndpoint)1 FlinkYarnSessionCli (org.apache.flink.yarn.cli.FlinkYarnSessionCli)1 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)1