热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

org.apache.flink.api.common.JobID类的使用及代码示例

本文整理了Java中org.apache.flink.api.common.JobID类的一些代码示例,展示了JobID类的具体用法。这些代码

本文整理了Java中org.apache.flink.api.common.JobID类的一些代码示例,展示了JobID类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JobID类的具体详情如下:
包路径:org.apache.flink.api.common.JobID
类名称:JobID

JobID介绍

[英]Unique (at least statistically unique) identifier for a Flink Job. Jobs in Flink correspond to dataflow graphs.

Jobs act simultaneously as sessions, because jobs can be created and submitted incrementally in different parts. Newer fragments of a graph can be attached to existing graphs, thereby extending the current data flow graphs.
[中]Flink作业的唯一(至少在统计上唯一)标识符。Flink中的作业对应于数据流图。
作业同时充当会话,因为作业可以在不同的部分以增量方式创建和提交。图的较新片段可以附加到现有图,从而扩展当前的数据流图。

代码示例

代码示例来源:origin: apache/flink

private static ClusterClient createClusterClient() throws Exception {
final ClusterClient clusterClient = mock(ClusterClient.class);
when(clusterClient.listJobs()).thenReturn(CompletableFuture.completedFuture(Arrays.asList(
new JobStatusMessage(new JobID(), "job1", JobStatus.RUNNING, 1L),
new JobStatusMessage(new JobID(), "job2", JobStatus.CREATED, 1L),
new JobStatusMessage(new JobID(), "job3", JobStatus.SUSPENDING, 3L),
new JobStatusMessage(new JobID(), "job4", JobStatus.SUSPENDING, 2L),
new JobStatusMessage(new JobID(), "job5", JobStatus.FINISHED, 3L)
)));
return clusterClient;
}
}

代码示例来源:origin: apache/flink

@Test
public void testStop() throws Exception {
// test stop properly
JobID jid = new JobID();
String jidString = jid.toString();
String[] parameters = { jidString };
final ClusterClient clusterClient = createClusterClient(null);
MockedCliFrontend testFrOntend= new MockedCliFrontend(clusterClient);
testFrontend.stop(parameters);
Mockito.verify(clusterClient, times(1)).stop(any(JobID.class));
}

代码示例来源:origin: apache/flink

/**
* Creates a new Execution Environment.
*/
protected ExecutionEnvironment() {
jobID = JobID.generate();
}

代码示例来源:origin: apache/flink

@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
}
}

代码示例来源:origin: apache/flink

/**
* Tests cancelling with the savepoint option.
*/
@Test
public void testCancelWithSavepoint() throws Exception {
{
// Cancel with savepoint (no target directory)
JobID jid = new JobID();
String[] parameters = { "-s", jid.toString() };
final ClusterClient clusterClient = createClusterClient();
MockedCliFrontend testFrOntend= new MockedCliFrontend(clusterClient);
testFrontend.cancel(parameters);
Mockito.verify(clusterClient, times(1))
.cancelWithSavepoint(any(JobID.class), isNull(String.class));
}
{
// Cancel with savepoint (with target directory)
JobID jid = new JobID();
String[] parameters = { "-s", "targetDirectory", jid.toString() };
final ClusterClient clusterClient = createClusterClient();
MockedCliFrontend testFrOntend= new MockedCliFrontend(clusterClient);
testFrontend.cancel(parameters);
Mockito.verify(clusterClient, times(1))
.cancelWithSavepoint(any(JobID.class), notNull(String.class));
}
}

代码示例来源:origin: apache/flink

StreamTask streamTask = spy(new EmptyStreamTask(mockEnvironment));
CheckpointMetaData checkpointMetaData = new CheckpointMetaData(checkpointId, timestamp);
StreamOperator streamOperator1 = mock(StreamOperator.class);
StreamOperator streamOperator2 = mock(StreamOperator.class);
StreamOperator streamOperator3 = mock(StreamOperator.class);
RunnableFuture> failingFuture = mock(RunnableFuture.class);
when(failingFuture.get()).thenThrow(new ExecutionException(new Exception("Test exception")));
when(operatorSnapshotResult3.getOperatorStateRawFuture()).thenReturn(failingFuture);
when(streamOperator1.snapshotState(anyLong(), anyLong(), any(CheckpointOptions.class), any(CheckpointStreamFactory.class))).thenReturn(operatorSnapshotResult1);
when(streamOperator2.snapshotState(anyLong(), anyLong(), any(CheckpointOptions.class), any(CheckpointStreamFactory.class))).thenReturn(operatorSnapshotResult2);
when(streamOperator3.snapshotState(anyLong(), anyLong(), any(CheckpointOptions.class), any(CheckpointStreamFactory.class))).thenReturn(operatorSnapshotResult3);
Whitebox.setInternalState(streamTask, "cancelables", new CloseableRegistry());
Whitebox.setInternalState(streamTask, "asyncOperationsThreadPool", newDirectExecutorService());
Whitebox.setInternalState(streamTask, "configuration", new StreamConfig(new Configuration()));
Whitebox.setInternalState(streamTask, "checkpointStorage", new MemoryBackendCheckpointStorage(new JobID(), null, null, Integer.MAX_VALUE));

代码示例来源:origin: apache/flink

final OneShotLatch completeSubtask = new OneShotLatch();
Environment mockEnvirOnment= spy(new MockEnvironmentBuilder().build());
thenAnswer((Answer) invocation -> {
createSubtask.trigger();
completeSubtask.await();
CheckpointMetaData checkpointMetaData = new CheckpointMetaData(checkpointId, timestamp);
final StreamOperator streamOperator = mock(StreamOperator.class);
final OperatorID operatorID = new OperatorID();
when(streamOperator.getOperatorID()).thenReturn(operatorID);
KeyedStateHandle managedKeyedStateHandle = mock(KeyedStateHandle.class);
DoneFuture.of(SnapshotResult.of(rawOperatorStateHandle)));
when(streamOperator.snapshotState(anyLong(), anyLong(), any(CheckpointOptions.class), any(CheckpointStreamFactory.class))).thenReturn(operatorSnapshotResult);
when(operatorChain.getAllOperators()).thenReturn(streamOperators);
CheckpointStorage checkpointStorage = new MemoryBackendCheckpointStorage(new JobID(), null, null, Integer.MAX_VALUE);
Whitebox.setInternalState(streamTask, "cancelables", new CloseableRegistry());
Whitebox.setInternalState(streamTask, "asyncOperationsThreadPool", executor);
Whitebox.setInternalState(streamTask, "configuration", new StreamConfig(new Configuration()));
Whitebox.setInternalState(streamTask, "checkpointStorage", checkpointStorage);

代码示例来源:origin: apache/flink

final OneShotLatch completeAcknowledge = new OneShotLatch();
CheckpointResponder checkpointRespOnder= mock(CheckpointResponder.class);
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
new JobID(1L, 2L),
new ExecutionAttemptID(1L, 2L),
mock(TaskLocalStateStoreImpl.class),
null,
checkpointResponder);
StreamOperator streamOperator = mock(StreamOperator.class);
when(streamOperator.getOperatorID()).thenReturn(new OperatorID(42, 42));
KeyedStateHandle managedKeyedStateHandle = mock(KeyedStateHandle.class);
DoneFuture.of(SnapshotResult.of(rawOperatorStateHandle)));
when(streamOperator.snapshotState(anyLong(), anyLong(), any(CheckpointOptions.class), any(CheckpointStreamFactory.class))).thenReturn(operatorSnapshotResult);
OperatorChain> operatorChain = mock(OperatorChain.class);
when(operatorChain.getAllOperators()).thenReturn(streamOperators);
CheckpointStorage checkpointStorage = new MemoryBackendCheckpointStorage(new JobID(), null, null, Integer.MAX_VALUE);

代码示例来源:origin: apache/flink

new BlobCacheService(mock(PermanentBlobCache.class), mock(TransientBlobCache.class));
LibraryCacheManager libCache = mock(LibraryCacheManager.class);
when(libCache.getClassLoader(any(JobID.class))).thenReturn(StreamTaskTest.class.getClassLoader());
ResultPartitionManager partitiOnManager= mock(ResultPartitionManager.class);
NetworkEnvironment network = mock(NetworkEnvironment.class);
when(network.getResultPartitionManager()).thenReturn(partitionManager);
when(network.getDefaultIOMode()).thenReturn(IOManager.IOMode.SYNC);
when(network.createKvStateTaskRegistry(any(JobID.class), any(JobVertexID.class)))
.thenReturn(mock(TaskKvStateRegistry.class));
when(network.getTaskEventDispatcher()).thenReturn(taskEventDispatcher);
new JobID(),
"Job Name",
new SerializedValue<>(new ExecutionConfig()),
new Configuration(),
Collections.emptyList(),
Collections.emptyList());

代码示例来源:origin: apache/flink

final long timestamp = 1L;
Environment mockEnvirOnment= spy(new MockEnvironmentBuilder().build());
final List checkpointResult = new ArrayList<>(1);
new JobID(1L, 2L),
new ExecutionAttemptID(1L, 2L),
mock(TaskLocalStateStoreImpl.class),
checkpointResponder);
when(mockEnvironment.getTaskStateManager()).thenReturn(taskStateManager);
when(statelessOperator.getOperatorID()).thenReturn(operatorID);
when(statelessOperator.snapshotState(anyLong(), anyLong(), any(CheckpointOptions.class), any(CheckpointStreamFactory.class)))
.thenReturn(statelessOperatorSnapshotResult);
Whitebox.setInternalState(streamTask, "operatorChain", operatorChain);
Whitebox.setInternalState(streamTask, "cancelables", new CloseableRegistry());
Whitebox.setInternalState(streamTask, "configuration", new StreamConfig(new Configuration()));
Whitebox.setInternalState(streamTask, "asyncOperationsThreadPool", Executors.newCachedThreadPool());
Whitebox.setInternalState(streamTask, "checkpointStorage", new MemoryBackendCheckpointStorage(new JobID(), null, null, Integer.MAX_VALUE));

代码示例来源:origin: apache/flink

final Configuration taskCOnfiguration= new Configuration();
final StreamConfig streamCOnfig= new StreamConfig(taskConfiguration);
final NoOpStreamOperator noOpStreamOperator = new NoOpStreamOperator<>();
new JobID(),
"Test Job",
new SerializedValue<>(new ExecutionConfig()),
new Configuration(),
Collections.emptyList(),
Collections.emptyList());
final NetworkEnvironment networkEnv = mock(NetworkEnvironment.class);
when(networkEnv.createKvStateTaskRegistry(any(JobID.class), any(JobVertexID.class))).thenReturn(mock(TaskKvStateRegistry.class));
when(networkEnv.getTaskEventDispatcher()).thenReturn(taskEventDispatcher);
Executors.directExecutor());
CompletableFuture taskRun = CompletableFuture.runAsync(
() -> task.run(),
TestingUtils.defaultExecutor());
taskRun.get();

代码示例来源:origin: apache/flink

NetworkEnvironment networkEnvirOnment= mock(NetworkEnvironment.class);
when(networkEnvironment.createKvStateTaskRegistry(any(JobID.class), any(JobVertexID.class)))
.thenReturn(mock(TaskKvStateRegistry.class));
when(networkEnvironment.getTaskEventDispatcher()).thenReturn(taskEventDispatcher);
new JobID(),
"test job name",
new SerializedValue<>(new ExecutionConfig()),
new Configuration(),
Collections.emptyList(),
Collections.emptyList());

代码示例来源:origin: apache/flink

new SlotRequest(new JobID(), new AllocationID(), resourceProfile1, taskHost));
return null;
});
registerSlotRequestFuture.get();
doReturn(Collections.singletonList(Collections.singletonList(resourceManager.getContainerRequest())))
.when(mockResourceManagerClient).getMatchingRequests(any(Priority.class), anyString(), any(Resource.class));
verify(mockResourceManagerClient).addContainerRequest(any(AMRMClient.ContainerRequest.class));
verify(mockNMClient).startContainer(eq(testingContainer), any(ContainerLaunchContext.class));
hardwareDescription,
Time.seconds(10L))
.thenCompose(
(RegistrationResponse response) -> {
assertThat(response, instanceOf(TaskExecutorRegistrationSuccess.class));
Time.seconds(10L));
})
.handleAsync(
(Acknowledge ignored, Throwable throwable) -> rmServices.slotManager.getNumberRegisteredSlots(),
resourceManager.getMainThreadExecutorForTesting());

代码示例来源:origin: apache/flink

CompletableFuture registerSlotRequestFuture = resourceManager.runInMainThread(() -> {
rmServices.slotManager.registerSlotRequest(
new SlotRequest(new JobID(), new AllocationID(), resourceProfile1, taskHost));
return null;
});
registerSlotRequestFuture.get();
doReturn(Collections.singletonList(Collections.singletonList(resourceManager.getContainerRequest())))
.when(mockResourceManagerClient).getMatchingRequests(any(Priority.class), anyString(), any(Resource.class));
verify(mockResourceManagerClient).addContainerRequest(any(AMRMClient.ContainerRequest.class));
verify(mockResourceManagerClient).removeContainerRequest(any(AMRMClient.ContainerRequest.class));
verify(mockNMClient).startContainer(eq(testingContainer), any(ContainerLaunchContext.class));

代码示例来源:origin: uber/AthenaX

@Test
public void testDeployerWithIsolatedConfiguration() throws Exception {
YarnClusterConfiguration clusterCOnf= mock(YarnClusterConfiguration.class);
doReturn(new YarnConfiguration()).when(clusterConf).conf();
ScheduledExecutorService executor = mock(ScheduledExecutorService.class);
Configuration flinkCOnf= new Configuration();
YarnClient client = mock(YarnClient.class);
JobDeployer deploy = new JobDeployer(clusterConf, client, executor, flinkConf);
AthenaXYarnClusterDescriptor desc = mock(AthenaXYarnClusterDescriptor.class);
YarnClusterClient clusterClient = mock(YarnClusterClient.class);
doReturn(clusterClient).when(desc).deploy();
ActorGateway actorGateway = mock(ActorGateway.class);
doReturn(actorGateway).when(clusterClient).getJobManagerGateway();
doReturn(Future$.MODULE$.successful(null)).when(actorGateway).ask(any(), any());
JobGraph jobGraph = mock(JobGraph.class);
doReturn(JobID.generate()).when(jobGraph).getJobID();
deploy.start(desc, jobGraph);
verify(clusterClient).runDetached(jobGraph, null);
}
}

代码示例来源:origin: apache/flink

@Test
public void testTriggerSavepointSuccess() throws Exception {
replaceStdOutAndStdErr();
JobID jobId = new JobID();
String savepointPath = "expectedSavepointPath";
final ClusterClient 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();
}
}

代码示例来源:origin: apache/flink

@Test
public void testNonExistingJobRetrieval() throws Exception {
final JobID jobID = new JobID();
try {
client.requestJobResult(jobID).get();
fail();
} catch (Exception exception) {
Optional expectedCause = ExceptionUtils.findThrowable(exception,
candidate -> candidate.getMessage() != null && candidate.getMessage().contains("Could not find Flink job"));
if (!expectedCause.isPresent()) {
throw exception;
}
}
}

代码示例来源:origin: apache/flink

@Test
public void testClusterClientSavepoint() throws Exception {
Configuration cOnfig= new Configuration();
config.setString(JobManagerOptions.ADDRESS, "localhost");
JobID jobID = new JobID();
String savepointDirectory = "/test/directory";
String savepointPath = "/test/path";
TestSavepointActorGateway gateway = new TestSavepointActorGateway(jobID, savepointDirectory, savepointPath);
TestClusterClient clusterClient = new TestClusterClient(config, gateway);
try {
CompletableFuture pathFuture = clusterClient.triggerSavepoint(jobID, savepointDirectory);
Assert.assertTrue(gateway.messageArrived);
Assert.assertEquals(savepointPath, pathFuture.get());
} finally {
clusterClient.shutdown();
}
}

代码示例来源:origin: apache/flink

private static MapState getMapState(
String jobId,
QueryableStateClient client,
MapStateDescriptor stateDescriptor) throws InterruptedException, ExecutionException {
CompletableFuture> resultFuture =
client.getKvState(
JobID.fromHexString(jobId),
QsConstants.QUERY_NAME,
QsConstants.KEY, // which key of the keyed state to access
BasicTypeInfo.STRING_TYPE_INFO,
stateDescriptor);
return resultFuture.get();
}
}

代码示例来源:origin: apache/flink

final JobID jobId = new JobID();
final String jobName = "Semi-Rebalance Test Job";
final Configuration cfg = new Configuration();
new NoRestartStrategy(),
new RestartAllStrategy.Factory(),
new TestingSlotProvider(ignored -> new CompletableFuture<>()),
ExecutionGraph.class.getClassLoader(),
VoidBlobWriter.getInstance(),

推荐阅读
  • Java容器中的compareto方法排序原理解析
    本文从源码解析Java容器中的compareto方法的排序原理,讲解了在使用数组存储数据时的限制以及存储效率的问题。同时提到了Redis的五大数据结构和list、set等知识点,回忆了作者大学时代的Java学习经历。文章以作者做的思维导图作为目录,展示了整个讲解过程。 ... [详细]
  • JavaSE笔试题-接口、抽象类、多态等问题解答
    本文解答了JavaSE笔试题中关于接口、抽象类、多态等问题。包括Math类的取整数方法、接口是否可继承、抽象类是否可实现接口、抽象类是否可继承具体类、抽象类中是否可以有静态main方法等问题。同时介绍了面向对象的特征,以及Java中实现多态的机制。 ... [详细]
  • 个人学习使用:谨慎参考1Client类importcom.thoughtworks.gauge.Step;importcom.thoughtworks.gauge.T ... [详细]
  • Java学习笔记之面向对象编程(OOP)
    本文介绍了Java学习笔记中的面向对象编程(OOP)内容,包括OOP的三大特性(封装、继承、多态)和五大原则(单一职责原则、开放封闭原则、里式替换原则、依赖倒置原则)。通过学习OOP,可以提高代码复用性、拓展性和安全性。 ... [详细]
  • JDK源码学习之HashTable(附带面试题)的学习笔记
    本文介绍了JDK源码学习之HashTable(附带面试题)的学习笔记,包括HashTable的定义、数据类型、与HashMap的关系和区别。文章提供了干货,并附带了其他相关主题的学习笔记。 ... [详细]
  • Week04面向对象设计与继承学习总结及作业要求
    本文总结了Week04面向对象设计与继承的重要知识点,包括对象、类、封装性、静态属性、静态方法、重载、继承和多态等。同时,还介绍了私有构造函数在类外部无法被调用、static不能访问非静态属性以及该类实例可以共享类里的static属性等内容。此外,还提到了作业要求,包括讲述一个在网上商城购物或在班级博客进行学习的故事,并使用Markdown的加粗标记和语句块标记标注关键名词和动词。最后,还提到了参考资料中关于UML类图如何绘制的范例。 ... [详细]
  • 本文讨论了一个关于cuowu类的问题,作者在使用cuowu类时遇到了错误提示和使用AdjustmentListener的问题。文章提供了16个解决方案,并给出了两个可能导致错误的原因。 ... [详细]
  • XML介绍与使用的概述及标签规则
    本文介绍了XML的基本概念和用途,包括XML的可扩展性和标签的自定义特性。同时还详细解释了XML标签的规则,包括标签的尖括号和合法标识符的组成,标签必须成对出现的原则以及特殊标签的使用方法。通过本文的阅读,读者可以对XML的基本知识有一个全面的了解。 ... [详细]
  • 本文详细介绍了Java中vector的使用方法和相关知识,包括vector类的功能、构造方法和使用注意事项。通过使用vector类,可以方便地实现动态数组的功能,并且可以随意插入不同类型的对象,进行查找、插入和删除操作。这篇文章对于需要频繁进行查找、插入和删除操作的情况下,使用vector类是一个很好的选择。 ... [详细]
  • 闭包一直是Java社区中争论不断的话题,很多语言都支持闭包这个语言特性,闭包定义了一个依赖于外部环境的自由变量的函数,这个函数能够访问外部环境的变量。本文以JavaScript的一个闭包为例,介绍了闭包的定义和特性。 ... [详细]
  • Java在运行已编译完成的类时,是通过java虚拟机来装载和执行的,java虚拟机通过操作系统命令JAVA_HOMEbinjava–option来启 ... [详细]
  • 本文介绍了Python爬虫技术基础篇面向对象高级编程(中)中的多重继承概念。通过继承,子类可以扩展父类的功能。文章以动物类层次的设计为例,讨论了按照不同分类方式设计类层次的复杂性和多重继承的优势。最后给出了哺乳动物和鸟类的设计示例,以及能跑、能飞、宠物类和非宠物类的增加对类数量的影响。 ... [详细]
  • Java中包装类的设计原因以及操作方法
    本文主要介绍了Java中设计包装类的原因以及操作方法。在Java中,除了对象类型,还有八大基本类型,为了将基本类型转换成对象,Java引入了包装类。文章通过介绍包装类的定义和实现,解答了为什么需要包装类的问题,并提供了简单易用的操作方法。通过本文的学习,读者可以更好地理解和应用Java中的包装类。 ... [详细]
  • 先看官方文档TheJavaTutorialshavebeenwrittenforJDK8.Examplesandpracticesdescribedinthispagedontta ... [详细]
  • 本文介绍了Swing组件的用法,重点讲解了图标接口的定义和创建方法。图标接口用来将图标与各种组件相关联,可以是简单的绘画或使用磁盘上的GIF格式图像。文章详细介绍了图标接口的属性和绘制方法,并给出了一个菱形图标的实现示例。该示例可以配置图标的尺寸、颜色和填充状态。 ... [详细]
author-avatar
乌海阿斯顿
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有