• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java AuxiliaryServiceHelper类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.hadoop.yarn.util.AuxiliaryServiceHelper的典型用法代码示例。如果您正苦于以下问题:Java AuxiliaryServiceHelper类的具体用法?Java AuxiliaryServiceHelper怎么用?Java AuxiliaryServiceHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AuxiliaryServiceHelper类属于org.apache.hadoop.yarn.util包,在下文中一共展示了AuxiliaryServiceHelper类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testAuxiliaryServiceHelper

import org.apache.hadoop.yarn.util.AuxiliaryServiceHelper; //导入依赖的package包/类
@Test (timeout = 5000)
public void testAuxiliaryServiceHelper() throws Exception {
  Map<String, String> env = new HashMap<String, String>();
  String serviceName = "testAuxiliaryService";
  ByteBuffer bb = ByteBuffer.wrap("testAuxiliaryService".getBytes());
  AuxiliaryServiceHelper.setServiceDataIntoEnv(serviceName, bb, env);
  Assert.assertEquals(bb,
      AuxiliaryServiceHelper.getServiceDataFromEnv(serviceName, env));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:10,代码来源:TestContainerLaunch.java


示例2: getServiceProviderMetaData

import org.apache.hadoop.yarn.util.AuxiliaryServiceHelper; //导入依赖的package包/类
@Nullable
@Override
public ByteBuffer getServiceProviderMetaData(String serviceName) {
  Preconditions.checkNotNull(serviceName, "serviceName is null");
  return AuxiliaryServiceHelper.getServiceDataFromEnv(
      serviceName, auxServiceEnv);
}
 
开发者ID:apache,项目名称:incubator-tez,代码行数:8,代码来源:TezTaskContextImpl.java


示例3: testGeneratedDataMovementEvent

import org.apache.hadoop.yarn.util.AuxiliaryServiceHelper; //导入依赖的package包/类
@Test
public void testGeneratedDataMovementEvent() throws Exception {

  OnFileUnorderedKVOutput kvOutput = new OnFileUnorderedKVOutputForTest();

  Configuration conf = new Configuration();
  conf.set(TezJobConfig.TEZ_RUNTIME_KEY_CLASS, Text.class.getName());
  conf.set(TezJobConfig.TEZ_RUNTIME_VALUE_CLASS, IntWritable.class.getName());

  int appAttemptNumber = 1;
  TezUmbilical tezUmbilical = null;
  String dagName = "currentDAG";
  String taskVertexName = "currentVertex";
  String destinationVertexName = "destinationVertex";
  TezDAGID dagID = TezDAGID.getInstance("2000", 1, 1);
  TezVertexID vertexID = TezVertexID.getInstance(dagID, 1);
  TezTaskID taskID = TezTaskID.getInstance(vertexID, 1);
  TezTaskAttemptID taskAttemptID = TezTaskAttemptID.getInstance(taskID, 1);
  TezCounters counters = new TezCounters();
  byte[] userPayload = TezUtils.createUserPayloadFromConf(conf);
  RuntimeTask runtimeTask = mock(RuntimeTask.class);
  
  int shufflePort = 2112;
  Map<String, String> auxEnv = new HashMap<String, String>();
  ByteBuffer bb = ByteBuffer.allocate(4);
  bb.putInt(shufflePort);
  bb.position(0);
  AuxiliaryServiceHelper.setServiceDataIntoEnv(ShuffleUtils.SHUFFLE_HANDLER_SERVICE_ID, bb, auxEnv);


  OutputDescriptor outputDescriptor = mock(OutputDescriptor.class);
  when(outputDescriptor.getClassName()).thenReturn("OutputDescriptor");

  TezOutputContext outputContext = new TezOutputContextImpl(conf, new String[] {workDir.toString()},
      appAttemptNumber, tezUmbilical, dagName, taskVertexName, destinationVertexName,
      taskAttemptID, counters, 0, userPayload, runtimeTask,
      null, auxEnv, new MemoryDistributor(1, 1, conf) , outputDescriptor);

  List<Event> events = null;

  events = kvOutput.initialize(outputContext);
  assertTrue(events != null && events.size() == 0);

  KeyValueWriter kvWriter = kvOutput.getWriter();
  List<KVPair> data = KVDataGen.generateTestData(true);
  for (KVPair kvp : data) {
    kvWriter.write(kvp.getKey(), kvp.getvalue());
  }

  events = kvOutput.close();
  assertTrue(events != null && events.size() == 1);
  DataMovementEvent dmEvent = (DataMovementEvent)events.get(0);

  assertEquals("Invalid source index", 0, dmEvent.getSourceIndex());

  DataMovementEventPayloadProto shufflePayload = DataMovementEventPayloadProto
      .parseFrom(dmEvent.getUserPayload());

  assertFalse(shufflePayload.hasEmptyPartitions());
  assertEquals(outputContext.getUniqueIdentifier(), shufflePayload.getPathComponent());
  assertEquals(shufflePort, shufflePayload.getPort());
  assertEquals("host", shufflePayload.getHost());
}
 
开发者ID:apache,项目名称:incubator-tez,代码行数:64,代码来源:TestOnFileUnorderedKVOutput.java


示例4: setShufflePort

import org.apache.hadoop.yarn.util.AuxiliaryServiceHelper; //导入依赖的package包/类
public void setShufflePort(String auxiliaryService, int shufflePort) {
  AuxiliaryServiceHelper.setServiceDataIntoEnv(
      auxiliaryService,
      ByteBuffer.allocate(4).putInt(shufflePort), localEnv);
}
 
开发者ID:apache,项目名称:tez,代码行数:6,代码来源:ContainerRunnerImpl.java


示例5: createOutputContext

import org.apache.hadoop.yarn.util.AuxiliaryServiceHelper; //导入依赖的package包/类
private OutputContext createOutputContext(Configuration conf, TezSharedExecutor sharedExecutor)
    throws IOException {
  int appAttemptNumber = 1;
  TezUmbilical tezUmbilical = mock(TezUmbilical.class);
  String dagName = "currentDAG";
  String taskVertexName = "currentVertex";
  String destinationVertexName = "destinationVertex";
  TezDAGID dagID = TezDAGID.getInstance("2000", 1, 1);
  TezVertexID vertexID = TezVertexID.getInstance(dagID, 1);
  TezTaskID taskID = TezTaskID.getInstance(vertexID, 1);
  TezTaskAttemptID taskAttemptID = TezTaskAttemptID.getInstance(taskID, 1);
  UserPayload userPayload = TezUtils.createUserPayloadFromConf(conf);
  
  TaskSpec mockSpec = mock(TaskSpec.class);
  when(mockSpec.getInputs()).thenReturn(Collections.singletonList(mock(InputSpec.class)));
  when(mockSpec.getOutputs()).thenReturn(Collections.singletonList(mock(OutputSpec.class)));
  task = new LogicalIOProcessorRuntimeTask(mockSpec, appAttemptNumber, new Configuration(),
      new String[]{"/"}, tezUmbilical, null, null, null, null, "", null, 1024, false,
      new DefaultHadoopShim(), sharedExecutor);

  LogicalIOProcessorRuntimeTask runtimeTask = spy(task);
  
  Map<String, String> auxEnv = new HashMap<String, String>();
  ByteBuffer bb = ByteBuffer.allocate(4);
  bb.putInt(shufflePort);
  bb.position(0);
  AuxiliaryServiceHelper.setServiceDataIntoEnv(conf.get(TezConfiguration.TEZ_AM_SHUFFLE_AUXILIARY_SERVICE_ID,
      TezConfiguration.TEZ_AM_SHUFFLE_AUXILIARY_SERVICE_ID_DEFAULT), bb, auxEnv);


  OutputDescriptor outputDescriptor = mock(OutputDescriptor.class);
  when(outputDescriptor.getClassName()).thenReturn("OutputDescriptor");

  OutputContext realOutputContext = new TezOutputContextImpl(conf, new String[] {workDir.toString()},
      appAttemptNumber, tezUmbilical, dagName, taskVertexName, destinationVertexName,
      -1, taskAttemptID, 0, userPayload, runtimeTask,
      null, auxEnv, new MemoryDistributor(1, 1, conf) , outputDescriptor, null,
      new ExecutionContextImpl("localhost"), 2048, new TezSharedExecutor(defaultConf));
  verify(runtimeTask, times(1)).addAndGetTezCounter(destinationVertexName);
  verify(runtimeTask, times(1)).getTaskStatistics();
  // verify output stats object got created
  Assert.assertTrue(task.getTaskStatistics().getIOStatistics().containsKey(destinationVertexName));
  OutputContext outputContext = spy(realOutputContext);
  doAnswer(new Answer() {
    @Override public Object answer(InvocationOnMock invocation) throws Throwable {
      long requestedSize = (Long) invocation.getArguments()[0];
      MemoryUpdateCallbackHandler callback = (MemoryUpdateCallbackHandler) invocation
          .getArguments()[1];
      callback.memoryAssigned(requestedSize);
      return null;
    }
  }).when(outputContext).requestInitialMemory(anyLong(), any(MemoryUpdateCallback.class));

  return outputContext;
}
 
开发者ID:apache,项目名称:tez,代码行数:56,代码来源:TestOnFileUnorderedKVOutput.java


示例6: createLogicalTask

import org.apache.hadoop.yarn.util.AuxiliaryServiceHelper; //导入依赖的package包/类
public static LogicalIOProcessorRuntimeTask createLogicalTask(FileSystem fs, Path workDir,
    JobConf jobConf, int mapId, Path mapInput,
    TezUmbilical umbilical, String dagName,
    String vertexName, List<InputSpec> inputSpecs,
    List<OutputSpec> outputSpecs, TezSharedExecutor sharedExecutor) throws Exception {
  jobConf.setInputFormat(SequenceFileInputFormat.class);

  ProcessorDescriptor mapProcessorDesc = ProcessorDescriptor.create(
      MapProcessor.class.getName()).setUserPayload(
      TezUtils.createUserPayloadFromConf(jobConf));
  
  Token<JobTokenIdentifier> shuffleToken = new Token<JobTokenIdentifier>();

  TaskSpec taskSpec = new TaskSpec(
      TezTestUtils.getMockTaskAttemptId(0, 0, mapId, 0),
      dagName, vertexName, -1,
      mapProcessorDesc,
      inputSpecs,
      outputSpecs, null, null);

  Map<String, ByteBuffer> serviceConsumerMetadata = new HashMap<String, ByteBuffer>();
  String auxiliaryService = jobConf.get(TezConfiguration.TEZ_AM_SHUFFLE_AUXILIARY_SERVICE_ID,
      TezConfiguration.TEZ_AM_SHUFFLE_AUXILIARY_SERVICE_ID_DEFAULT);
  serviceConsumerMetadata.put(auxiliaryService,
      ShuffleUtils.convertJobTokenToBytes(shuffleToken));
  Map<String, String> envMap = new HashMap<String, String>();
  ByteBuffer shufflePortBb = ByteBuffer.allocate(4).putInt(0, 8000);
  AuxiliaryServiceHelper
      .setServiceDataIntoEnv(auxiliaryService, shufflePortBb,
          envMap);

  LogicalIOProcessorRuntimeTask task = new LogicalIOProcessorRuntimeTask(
      taskSpec,
      0,
      jobConf,
      new String[] {workDir.toString()},
      umbilical,
      serviceConsumerMetadata,
      envMap,
      HashMultimap.<String, String>create(), null, "", new ExecutionContextImpl("localhost"),
      Runtime.getRuntime().maxMemory(), true, new DefaultHadoopShim(), sharedExecutor);
  return task;
}
 
开发者ID:apache,项目名称:tez,代码行数:44,代码来源:MapUtils.java


示例7: LocalContainerLauncher

import org.apache.hadoop.yarn.util.AuxiliaryServiceHelper; //导入依赖的package包/类
public LocalContainerLauncher(ContainerLauncherContext containerLauncherContext,
                              AppContext context,
                              TaskCommunicatorManagerInterface taskCommunicatorManagerInterface,
                              String workingDirectory,
                              boolean isLocalMode) throws UnknownHostException, TezException {
  // TODO Post TEZ-2003. Most of this information is dynamic and only available after the AM
  // starts up. It's not possible to set these up via a static payload.
  // Will need some kind of mechanism to dynamically crate payloads / bind to parameters
  // after the AM starts up.
  super(containerLauncherContext);
  this.context = context;
  this.tal = taskCommunicatorManagerInterface;
  this.workingDirectory = workingDirectory;
  this.isLocalMode = isLocalMode;

  // Check if the hostname is set in the environment before overriding it.
  String host = isLocalMode ? InetAddress.getLocalHost().getHostName() :
      System.getenv(Environment.NM_HOST.name());
  executionContext = new ExecutionContextImpl(host);

  Configuration conf;
  try {
    conf = TezUtils.createConfFromUserPayload(getContext().getInitialUserPayload());
  } catch (IOException e) {
    throw new TezUncheckedException(
        "Failed to parse user payload for " + LocalContainerLauncher.class.getSimpleName(), e);
  }
  if (isLocalMode) {
    String auxiliaryService = conf.get(TezConfiguration.TEZ_AM_SHUFFLE_AUXILIARY_SERVICE_ID,
        TezConfiguration.TEZ_AM_SHUFFLE_AUXILIARY_SERVICE_ID_DEFAULT);
    localEnv = Maps.newHashMap();
    shufflePort = 0;
    AuxiliaryServiceHelper.setServiceDataIntoEnv(
        auxiliaryService, ByteBuffer.allocate(4).putInt(shufflePort), localEnv);
  } else {
    localEnv = System.getenv();
  }
  numExecutors = conf.getInt(TezConfiguration.TEZ_AM_INLINE_TASK_EXECUTION_MAX_TASKS,
      TezConfiguration.TEZ_AM_INLINE_TASK_EXECUTION_MAX_TASKS_DEFAULT);
  Preconditions.checkState(numExecutors >=1, "Must have at least 1 executor");
  ExecutorService rawExecutor = Executors.newFixedThreadPool(numExecutors,
      new ThreadFactoryBuilder().setDaemon(true).setNameFormat("LocalTaskExecutionThread #%d")
          .build());
  this.taskExecutorService = MoreExecutors.listeningDecorator(rawExecutor);
  boolean cleanupDagDataOnComplete = ShuffleUtils.isTezShuffleHandler(conf)
      && conf.getBoolean(TezConfiguration.TEZ_AM_DAG_CLEANUP_ON_COMPLETION,
      TezConfiguration.TEZ_AM_DAG_CLEANUP_ON_COMPLETION_DEFAULT);
  if (cleanupDagDataOnComplete) {
    String deletionTrackerClassName = conf.get(TezConfiguration.TEZ_AM_DELETION_TRACKER_CLASS,
        TezConfiguration.TEZ_AM_DELETION_TRACKER_CLASS_DEFAULT);
    deletionTracker = ReflectionUtils.createClazzInstance(
        deletionTrackerClassName, new Class[]{Configuration.class}, new Object[]{conf});
  }
}
 
开发者ID:apache,项目名称:tez,代码行数:55,代码来源:LocalContainerLauncher.java



注:本文中的org.apache.hadoop.yarn.util.AuxiliaryServiceHelper类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TreeRange类代码示例发布时间:2022-05-22
下一篇:
Java DelegationTokenRenewer类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap