gpt4 book ai didi

org.apache.samza.zk.ZkUtils.readTaskLocality()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-15 00:39:31 26 4
gpt4 key购买 nike

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

ZkUtils.readTaskLocality介绍

暂无

代码示例

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

@Test
public void testReadWhenTaskLocalityDoesNotExist() {
 Map<TaskName, LocationId> taskLocality = zkUtils.readTaskLocality();
 Assert.assertEquals(0, taskLocality.size());
}

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

/**
 * Builds the {@link GrouperMetadataImpl} based upon provided {@param jobModelVersion}
 * and {@param processorNodes}.
 * @param jobModelVersion the most recent jobModelVersion available in the zookeeper.
 * @param processorNodes the list of live processors in the zookeeper.
 * @return the built grouper metadata.
 */
private GrouperMetadataImpl getGrouperMetadata(String jobModelVersion, List<ProcessorNode> processorNodes) {
 Map<TaskName, String> taskToProcessorId = new HashMap<>();
 Map<TaskName, List<SystemStreamPartition>> taskToSSPs = new HashMap<>();
 if (jobModelVersion != null) {
  JobModel jobModel = zkUtils.getJobModel(jobModelVersion);
  for (ContainerModel containerModel : jobModel.getContainers().values()) {
   for (TaskModel taskModel : containerModel.getTasks().values()) {
    taskToProcessorId.put(taskModel.getTaskName(), containerModel.getId());
    for (SystemStreamPartition partition : taskModel.getSystemStreamPartitions()) {
     taskToSSPs.computeIfAbsent(taskModel.getTaskName(), k -> new ArrayList<>());
     taskToSSPs.get(taskModel.getTaskName()).add(partition);
    }
   }
  }
 }
 Map<String, LocationId> processorLocality = new HashMap<>();
 for (ProcessorNode processorNode : processorNodes) {
  ProcessorData processorData = processorNode.getProcessorData();
  processorLocality.put(processorData.getProcessorId(), processorData.getLocationId());
 }
 Map<TaskName, LocationId> taskLocality = zkUtils.readTaskLocality();
 return new GrouperMetadataImpl(processorLocality, taskLocality, taskToSSPs, taskToProcessorId);
}

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

@Test
public void testWriteTaskLocalityShouldUpdateTheExistingValue() {
 zkUtils.writeTaskLocality(new TaskName("task-1"), new LocationId("LocationId-1"));
 Map<TaskName, LocationId> taskLocality = ImmutableMap.of(new TaskName("task-1"), new LocationId("LocationId-1"));
 Assert.assertEquals(taskLocality, zkUtils.readTaskLocality());
 zkUtils.writeTaskLocality(new TaskName("task-1"), new LocationId("LocationId-2"));
 taskLocality = ImmutableMap.of(new TaskName("task-1"), new LocationId("LocationId-2"));
 Assert.assertEquals(taskLocality, zkUtils.readTaskLocality());
}

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

@Test
public void testReadAfterWriteTaskLocality() {
 zkUtils.writeTaskLocality(new TaskName("task-1"), new LocationId("LocationId-1"));
 zkUtils.writeTaskLocality(new TaskName("task-2"), new LocationId("LocationId-2"));
 Map<TaskName, LocationId> taskLocality = ImmutableMap.of(new TaskName("task-1"), new LocationId("LocationId-1"),
                              new TaskName("task-2"), new LocationId("LocationId-2"));
 Assert.assertEquals(taskLocality, zkUtils.readTaskLocality());
}

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

@Test
public void testReadTaskLocalityShouldReturnAllTheExistingLocalityValue() {
 zkUtils.writeTaskLocality(new TaskName("task-1"), new LocationId("LocationId-1"));
 zkUtils.writeTaskLocality(new TaskName("task-2"), new LocationId("LocationId-2"));
 zkUtils.writeTaskLocality(new TaskName("task-3"), new LocationId("LocationId-3"));
 zkUtils.writeTaskLocality(new TaskName("task-4"), new LocationId("LocationId-4"));
 zkUtils.writeTaskLocality(new TaskName("task-5"), new LocationId("LocationId-5"));
 Map<TaskName, LocationId> taskLocality = ImmutableMap.of(new TaskName("task-1"), new LocationId("LocationId-1"),
                              new TaskName("task-2"), new LocationId("LocationId-2"),
                              new TaskName("task-3"), new LocationId("LocationId-3"),
                              new TaskName("task-4"), new LocationId("LocationId-4"),
                              new TaskName("task-5"), new LocationId("LocationId-5"));
 Assert.assertEquals(taskLocality, zkUtils.readTaskLocality());
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com