Java Code Examples for org.apache.flink.api.common.JobID#toString()
The following examples show how to use
org.apache.flink.api.common.JobID#toString() .
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: CliFrontendStopWithSavepointTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testStopWithMaxWMAndDefaultSavepointDir() throws Exception { JobID jid = new JobID(); String[] parameters = { "-p", "-d", jid.toString() }; OneShotLatch stopWithSavepointLatch = new OneShotLatch(); TestingClusterClient<String> clusterClient = new TestingClusterClient<>(); clusterClient.setStopWithSavepointFunction((jobID, advanceToEndOfEventTime, savepointDirectory) -> { assertThat(jobID, is(jid)); assertThat(advanceToEndOfEventTime, is(true)); assertNull(savepointDirectory); stopWithSavepointLatch.trigger(); return CompletableFuture.completedFuture(savepointDirectory); }); MockedCliFrontend testFrontend = new MockedCliFrontend(clusterClient); testFrontend.stop(parameters); stopWithSavepointLatch.await(); }
Example 2
Source File: CliFrontendSavepointTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testTriggerSavepointSuccess() throws Exception { replaceStdOutAndStdErr(); JobID jobId = new JobID(); String savepointPath = "expectedSavepointPath"; final ClusterClient<String> clusterClient = createClusterClient(savepointPath); try { MockedCliFrontend frontend = new MockedCliFrontend(clusterClient); String[] parameters = { jobId.toString() }; frontend.savepoint(parameters); verify(clusterClient, times(1)) .triggerSavepoint(eq(jobId), isNull(String.class)); assertTrue(buffer.toString().contains(savepointPath)); } finally { clusterClient.shutdown(); restoreStdOutAndStdErr(); } }
Example 3
Source File: CliFrontendModifyTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testMissingParallelism() throws Exception { final JobID jobId = new JobID(); final String[] args = {jobId.toString()}; try { callModify(args); fail("Expected CliArgsException"); } catch (CliArgsException expected) { // expected } }
Example 4
Source File: ProgramTargetDescriptor.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * Creates a program target description from deployment classes. * * @param clusterId cluster id * @param jobId job id * @param <C> cluster id type * @return program target descriptor */ public static <C> ProgramTargetDescriptor of(C clusterId, JobID jobId, String webInterfaceUrl) { String clusterIdString; try { // check if cluster id has a toString method clusterId.getClass().getDeclaredMethod("toString"); clusterIdString = clusterId.toString(); } catch (NoSuchMethodException e) { clusterIdString = clusterId.getClass().getSimpleName(); } return new ProgramTargetDescriptor(clusterIdString, jobId.toString(), webInterfaceUrl); }
Example 5
Source File: CliFrontendModifyTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testModifyJob() throws Exception { final JobID jobId = new JobID(); final int parallelism = 42; String[] args = {jobId.toString(), "-p", String.valueOf(parallelism)}; Tuple2<JobID, Integer> jobIdParallelism = callModify(args); assertThat(jobIdParallelism.f0, Matchers.is(jobId)); assertThat(jobIdParallelism.f1, Matchers.is(parallelism)); }
Example 6
Source File: CliFrontendStopWithSavepointTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testStopWithMaxWMAndDefaultSavepointDir() throws Exception { JobID jid = new JobID(); String[] parameters = { "-p", "-d", jid.toString() }; final ClusterClient<String> clusterClient = createClusterClient(null); MockedCliFrontend testFrontend = new MockedCliFrontend(clusterClient); testFrontend.stop(parameters); Mockito.verify(clusterClient, times(1)) .stopWithSavepoint(eq(jid), eq(true), isNull()); }
Example 7
Source File: CliFrontendStopWithSavepointTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testStopWithExplicitSavepointDir() throws Exception { JobID jid = new JobID(); String[] parameters = { "-p", "test-target-dir", jid.toString() }; final ClusterClient<String> clusterClient = createClusterClient(null); MockedCliFrontend testFrontend = new MockedCliFrontend(clusterClient); testFrontend.stop(parameters); Mockito.verify(clusterClient, times(1)) .stopWithSavepoint(eq(jid), eq(false), eq("test-target-dir")); }
Example 8
Source File: CliFrontendSavepointTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testTriggerSavepointFailure() throws Exception { replaceStdOutAndStdErr(); JobID jobId = new JobID(); String expectedTestException = "expectedTestException"; Exception testException = new Exception(expectedTestException); final ClusterClient<String> clusterClient = createFailingClusterClient(testException); try { MockedCliFrontend frontend = new MockedCliFrontend(clusterClient); String[] parameters = { jobId.toString() }; try { frontend.savepoint(parameters); fail("Savepoint should have failed."); } catch (FlinkException e) { assertTrue(ExceptionUtils.findThrowableWithMessage(e, expectedTestException).isPresent()); } } finally { clusterClient.close(); restoreStdOutAndStdErr(); } }
Example 9
Source File: CliFrontendStopWithSavepointTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testStopWithDefaultSavepointDir() throws Exception { JobID jid = new JobID(); String[] parameters = {jid.toString() }; final ClusterClient<String> clusterClient = createClusterClient(null); MockedCliFrontend testFrontend = new MockedCliFrontend(clusterClient); testFrontend.stop(parameters); Mockito.verify(clusterClient, times(1)) .stopWithSavepoint(eq(jid), eq(false), isNull()); }
Example 10
Source File: CliFrontendSavepointTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testTriggerSavepointFailure() throws Exception { replaceStdOutAndStdErr(); JobID jobId = new JobID(); String expectedTestException = "expectedTestException"; Exception testException = new Exception(expectedTestException); final ClusterClient<String> clusterClient = createFailingClusterClient(testException); try { MockedCliFrontend frontend = new MockedCliFrontend(clusterClient); String[] parameters = { jobId.toString() }; try { frontend.savepoint(parameters); fail("Savepoint should have failed."); } catch (FlinkException e) { assertTrue(ExceptionUtils.findThrowableWithMessage(e, expectedTestException).isPresent()); } } finally { clusterClient.shutdown(); restoreStdOutAndStdErr(); } }
Example 11
Source File: CliFrontendStopWithSavepointTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testStopOnlyWithMaxWM() throws Exception { JobID jid = new JobID(); String[] parameters = { "-d", jid.toString() }; final ClusterClient<String> clusterClient = createClusterClient(null); MockedCliFrontend testFrontend = new MockedCliFrontend(clusterClient); testFrontend.stop(parameters); Mockito.verify(clusterClient, times(1)) .stopWithSavepoint(eq(jid), eq(true), isNull()); }
Example 12
Source File: CliFrontendCancelTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testCancel() throws Exception { // test cancel properly JobID jid = new JobID(); String[] parameters = { jid.toString() }; final ClusterClient<String> clusterClient = createClusterClient(); MockedCliFrontend testFrontend = new MockedCliFrontend(clusterClient); testFrontend.cancel(parameters); Mockito.verify(clusterClient, times(1)).cancel(any(JobID.class)); }
Example 13
Source File: MesosResourceManagerTest.java From flink with Apache License 2.0 | 5 votes |
MockJobMaster(JobID jobID) { this.jobID = jobID; this.resourceID = new ResourceID(jobID.toString()); this.address = "/" + jobID; this.gateway = mock(JobMasterGateway.class); this.jobMasterId = JobMasterId.generate(); this.leaderRetrievalService = new SettableLeaderRetrievalService(this.address, this.jobMasterId.toUUID()); }
Example 14
Source File: StandaloneJobClusterConfigurationParserFactoryTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testSetJobIdManually() throws FlinkParseException { final JobID jobId = new JobID(); final String[] args = {"--configDir", confDirPath, "--job-classname", "foobar", "--job-id", jobId.toString()}; final StandaloneJobClusterConfiguration standaloneJobClusterConfiguration = commandLineParser.parse(args); assertThat(standaloneJobClusterConfiguration.getJobId(), is(equalTo(jobId))); }
Example 15
Source File: JobIDPathParameter.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Override protected String convertToString(JobID value) { return value.toString(); }
Example 16
Source File: ZooKeeperRunningJobsRegistry.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
private String createZkPath(JobID jobID) { return runningJobPath + jobID.toString(); }
Example 17
Source File: TaskManagerMetricGroup.java From flink with Apache License 2.0 | 4 votes |
public TaskMetricGroup addTaskForJob( final JobID jobId, final String jobName, final JobVertexID jobVertexId, final ExecutionAttemptID executionAttemptId, final String taskName, final int subtaskIndex, final int attemptNumber) { Preconditions.checkNotNull(jobId); String resolvedJobName = jobName == null || jobName.isEmpty() ? jobId.toString() : jobName; // we cannot strictly lock both our map modification and the job group modification // because it might lead to a deadlock while (true) { // get or create a jobs metric group TaskManagerJobMetricGroup currentJobGroup; synchronized (this) { currentJobGroup = jobs.get(jobId); if (currentJobGroup == null || currentJobGroup.isClosed()) { currentJobGroup = new TaskManagerJobMetricGroup(registry, this, jobId, resolvedJobName); jobs.put(jobId, currentJobGroup); } } // try to add another task. this may fail if we found a pre-existing job metrics // group and it is closed concurrently TaskMetricGroup taskGroup = currentJobGroup.addTask( jobVertexId, executionAttemptId, taskName, subtaskIndex, attemptNumber); if (taskGroup != null) { // successfully added the next task return taskGroup; } // else fall through the loop } }
Example 18
Source File: MessageParametersTest.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Override public String convertValueToString(JobID value) { return value.toString(); }
Example 19
Source File: JobsFilterQueryParameter.java From flink with Apache License 2.0 | 4 votes |
@Override public String convertValueToString(JobID value) { return value.toString(); }
Example 20
Source File: FileArchivedExecutionGraphStore.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
private File getExecutionGraphFile(JobID jobId) { return new File(storageDir, jobId.toString()); }