Java Code Examples for org.apache.flink.client.deployment.StandaloneClusterId#getInstance()

The following examples show how to use org.apache.flink.client.deployment.StandaloneClusterId#getInstance() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CliFrontendSavepointTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testTriggerSavepointFailureIllegalJobID() throws Exception {
	replaceStdOutAndStdErr();

	try {
		CliFrontend frontend = new MockedCliFrontend(new RestClusterClient<>(getConfiguration(), StandaloneClusterId.getInstance()));

		String[] parameters = { "invalid job id" };
		try {
			frontend.savepoint(parameters);
			fail("Should have failed.");
		} catch (CliArgsException e) {
			assertThat(e.getMessage(), Matchers.containsString("Cannot parse JobID"));
		}
	}
	finally {
		restoreStdOutAndStdErr();
	}
}
 
Example 2
Source File: CliFrontendSavepointTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testTriggerSavepointFailureIllegalJobID() throws Exception {
	replaceStdOutAndStdErr();

	try {
		CliFrontend frontend = new MockedCliFrontend(new RestClusterClient<>(getConfiguration(), StandaloneClusterId.getInstance()));

		String[] parameters = { "invalid job id" };
		try {
			frontend.savepoint(parameters);
			fail("Should have failed.");
		} catch (CliArgsException e) {
			assertThat(e.getMessage(), Matchers.containsString("Cannot parse JobID"));
		}
	}
	finally {
		restoreStdOutAndStdErr();
	}
}
 
Example 3
Source File: CliFrontendSavepointTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testTriggerSavepointFailureIllegalJobID() throws Exception {
	replaceStdOutAndStdErr();

	try {
		CliFrontend frontend = new MockedCliFrontend(new RestClusterClient<>(getConfiguration(), StandaloneClusterId.getInstance()));

		String[] parameters = { "invalid job id" };
		try {
			frontend.savepoint(parameters);
			fail("Should have failed.");
		} catch (CliArgsException e) {
			assertThat(e.getMessage(), Matchers.containsString("Cannot parse JobID"));
		}
	}
	finally {
		restoreStdOutAndStdErr();
	}
}
 
Example 4
Source File: CliFrontendSavepointTest.java    From flink with Apache License 2.0 5 votes vote down vote up
DisposeSavepointClusterClient(
	Function<String, CompletableFuture<Acknowledge>> disposeSavepointFunction,
	Configuration configuration) throws Exception {
	super(configuration, StandaloneClusterId.getInstance());

	this.disposeSavepointFunction = Preconditions.checkNotNull(disposeSavepointFunction);
}
 
Example 5
Source File: RestClusterClientSavepointTriggerTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
private RestClusterClient<StandaloneClusterId> createRestClusterClient(final int port) throws Exception {
	final Configuration clientConfig = new Configuration(REST_CONFIG);
	clientConfig.setInteger(RestOptions.PORT, port);
	return new RestClusterClient<>(
		clientConfig,
		new RestClient(RestClientConfiguration.fromConfiguration(REST_CONFIG), executor),
		StandaloneClusterId.getInstance(),
		(attempt) -> 0,
		null);
}
 
Example 6
Source File: RestClusterClientTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
private RestClusterClient<StandaloneClusterId> createRestClusterClient(final int port) throws Exception {
	final Configuration clientConfig = new Configuration(restConfig);
	clientConfig.setInteger(RestOptions.PORT, port);
	return new RestClusterClient<>(
		clientConfig,
		createRestClient(),
		StandaloneClusterId.getInstance(),
		(attempt) -> 0,
		null);
}
 
Example 7
Source File: RestClusterClientTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private RestClusterClient<StandaloneClusterId> createRestClusterClient(final int port) throws Exception {
	final Configuration clientConfig = new Configuration(restConfig);
	clientConfig.setInteger(RestOptions.PORT, port);
	return new RestClusterClient<>(
		clientConfig,
		createRestClient(),
		StandaloneClusterId.getInstance(),
		(attempt) -> 0);
}
 
Example 8
Source File: CliFrontendSavepointTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
DisposeSavepointClusterClient(
	Function<String, CompletableFuture<Acknowledge>> disposeSavepointFunction,
	Configuration configuration) throws Exception {
	super(configuration, StandaloneClusterId.getInstance());

	this.disposeSavepointFunction = Preconditions.checkNotNull(disposeSavepointFunction);
}
 
Example 9
Source File: JobRetrievalITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
	final Configuration clientConfig = new Configuration();
	clientConfig.setInteger(RestOptions.RETRY_MAX_ATTEMPTS, 0);
	clientConfig.setLong(RestOptions.RETRY_DELAY, 0);
	clientConfig.addAll(CLUSTER.getClientConfiguration());

	client = new RestClusterClient<>(
		clientConfig,
		StandaloneClusterId.getInstance()
	);
}
 
Example 10
Source File: RestClusterClientSavepointTriggerTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private RestClusterClient<StandaloneClusterId> createRestClusterClient(final int port) throws Exception {
	final Configuration clientConfig = new Configuration(REST_CONFIG);
	clientConfig.setInteger(RestOptions.PORT, port);
	return new RestClusterClient<>(
		clientConfig,
		new RestClient(RestClientConfiguration.fromConfiguration(REST_CONFIG), executor),
		StandaloneClusterId.getInstance(),
		(attempt) -> 0);
}
 
Example 11
Source File: JobRetrievalITCase.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
	final Configuration clientConfig = new Configuration();
	clientConfig.setInteger(RestOptions.RETRY_MAX_ATTEMPTS, 0);
	clientConfig.setLong(RestOptions.RETRY_DELAY, 0);
	clientConfig.addAll(CLUSTER.getClientConfiguration());

	client = new RestClusterClient<>(
		clientConfig,
		StandaloneClusterId.getInstance()
	);
}
 
Example 12
Source File: RestClusterClientSavepointTriggerTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private RestClusterClient<StandaloneClusterId> createRestClusterClient(final int port) throws Exception {
	final Configuration clientConfig = new Configuration(REST_CONFIG);
	clientConfig.setInteger(RestOptions.PORT, port);
	return new RestClusterClient<>(
		clientConfig,
		new RestClient(RestClientConfiguration.fromConfiguration(REST_CONFIG), executor),
		StandaloneClusterId.getInstance(),
		(attempt) -> 0,
		null);
}
 
Example 13
Source File: RestClusterClientTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private RestClusterClient<StandaloneClusterId> createRestClusterClient(final int port) throws Exception {
	final Configuration clientConfig = new Configuration(restConfig);
	clientConfig.setInteger(RestOptions.PORT, port);
	return new RestClusterClient<>(
		clientConfig,
		createRestClient(),
		StandaloneClusterId.getInstance(),
		(attempt) -> 0,
		null);
}
 
Example 14
Source File: CliFrontendSavepointTest.java    From flink with Apache License 2.0 5 votes vote down vote up
DisposeSavepointClusterClient(
	Function<String, CompletableFuture<Acknowledge>> disposeSavepointFunction,
	Configuration configuration) throws Exception {
	super(configuration, StandaloneClusterId.getInstance());

	this.disposeSavepointFunction = Preconditions.checkNotNull(disposeSavepointFunction);
}
 
Example 15
Source File: JobRetrievalITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
	final Configuration clientConfig = new Configuration();
	clientConfig.setInteger(RestOptions.RETRY_MAX_ATTEMPTS, 0);
	clientConfig.setLong(RestOptions.RETRY_DELAY, 0);
	clientConfig.addAll(CLUSTER.getClientConfiguration());

	client = new RestClusterClient<>(
		clientConfig,
		StandaloneClusterId.getInstance()
	);
}
 
Example 16
Source File: DefaultCLI.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
@Nullable
public StandaloneClusterId getClusterId(CommandLine commandLine) {
	return StandaloneClusterId.getInstance();
}
 
Example 17
Source File: BigUserProgramJobSubmitITCase.java    From flink with Apache License 2.0 4 votes vote down vote up
/**
 * Use a map function that references a 100MB byte array.
 */
@Test
public void bigDataInMap() throws Exception {

	final byte[] data = new byte[16 * 1024 * 1024]; // 16 MB
	rnd.nextBytes(data); // use random data so that Java does not optimise it away
	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 {
		ClientUtils.submitJobAndWaitForResult(restClusterClient, jobGraph, BigUserProgramJobSubmitITCase.class.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();
	}
}
 
Example 18
Source File: BigUserProgramJobSubmitITCase.java    From flink with Apache License 2.0 4 votes vote down vote up
/**
 * Use a map function that references a 100MB byte array.
 */
@Test
public void bigDataInMap() throws Exception {

	final byte[] data = new byte[16 * 1024 * 1024]; // 16 MB
	rnd.nextBytes(data); // use random data so that Java does not optimise it away
	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 {
		restClusterClient.setDetached(false);
		restClusterClient.submitJob(jobGraph, BigUserProgramJobSubmitITCase.class.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.shutdown();
	}
}
 
Example 19
Source File: CliFrontendModifyTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
TestingClusterClient(CompletableFuture<Tuple2<JobID, Integer>> rescaleJobFuture, Configuration configuration) throws Exception {
	super(configuration, StandaloneClusterId.getInstance());

	this.rescaleJobFuture = rescaleJobFuture;
}
 
Example 20
Source File: BigUserProgramJobSubmitITCase.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
/**
 * Use a map function that references a 100MB byte array.
 */
@Test
public void bigDataInMap() throws Exception {

	final byte[] data = new byte[16 * 1024 * 1024]; // 16 MB
	rnd.nextBytes(data); // use random data so that Java does not optimise it away
	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 {
		restClusterClient.setDetached(false);
		restClusterClient.submitJob(jobGraph, BigUserProgramJobSubmitITCase.class.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.shutdown();
	}
}