use of org.apache.flink.client.deployment.StandaloneClusterId 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));
}
use of org.apache.flink.client.deployment.StandaloneClusterId in project flink by apache.
the class BigUserProgramJobSubmitITCase method bigDataInMap.
/**
* Use a map function that references a 100MB byte array.
*/
@Test
public void bigDataInMap() throws Exception {
// 16 MB
final byte[] data = new byte[16 * 1024 * 1024];
// use random data so that Java does not optimise it away
rnd.nextBytes(data);
data[1] = 0;
data[3] = 0;
data[5] = 0;
CollectingSink resultSink = new CollectingSink();
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setParallelism(1);
DataStream<Integer> src = env.fromElements(1, 3, 5);
src.map(new MapFunction<Integer, String>() {
private static final long serialVersionUID = 1L;
@Override
public String map(Integer value) throws Exception {
return "x " + value + " " + data[value];
}
}).addSink(resultSink);
JobGraph jobGraph = StreamingJobGraphGenerator.createJobGraph(env.getStreamGraph());
final RestClusterClient<StandaloneClusterId> restClusterClient = new RestClusterClient<>(MINI_CLUSTER_RESOURCE.getClientConfiguration(), StandaloneClusterId.getInstance());
try {
submitJobAndWaitForResult(restClusterClient, jobGraph, getClass().getClassLoader());
List<String> expected = Arrays.asList("x 1 0", "x 3 0", "x 5 0");
List<String> result = CollectingSink.result;
Collections.sort(expected);
Collections.sort(result);
assertEquals(expected, result);
} finally {
restClusterClient.close();
}
}
Aggregations