Java 类org.apache.hadoop.mapred.TaskUmbilicalProtocol 实例源码

项目:hadoop    文件:MRAppMaster.java   
@Override
protected void serviceStart() throws Exception {
  if (job.isUber()) {
    this.containerLauncher = new LocalContainerLauncher(context,
        (TaskUmbilicalProtocol) taskAttemptListener);
    ((LocalContainerLauncher) this.containerLauncher)
            .setEncryptedSpillKey(encryptedSpillKey);
  } else {
    this.containerLauncher = new ContainerLauncherImpl(context);
  }
  ((Service)this.containerLauncher).init(getConfig());
  ((Service)this.containerLauncher).start();
  super.serviceStart();
}
项目:hadoop    文件:EventFetcher.java   
public EventFetcher(TaskAttemptID reduce,
                    TaskUmbilicalProtocol umbilical,
                    ShuffleScheduler<K,V> scheduler,
                    ExceptionReporter reporter,
                    int maxEventsToFetch) {
  setName("EventFetcher for fetching Map Completion Events");
  setDaemon(true);    
  this.reduce = reduce;
  this.umbilical = umbilical;
  this.scheduler = scheduler;
  exceptionReporter = reporter;
  this.maxEventsToFetch = maxEventsToFetch;
}
项目:aliyun-oss-hadoop-fs    文件:MRAppMaster.java   
@Override
protected void serviceStart() throws Exception {
  if (job.isUber()) {
    this.containerLauncher = new LocalContainerLauncher(context,
        (TaskUmbilicalProtocol) taskAttemptListener, jobClassLoader);
    ((LocalContainerLauncher) this.containerLauncher)
            .setEncryptedSpillKey(encryptedSpillKey);
  } else {
    this.containerLauncher = new ContainerLauncherImpl(context);
  }
  ((Service)this.containerLauncher).init(getConfig());
  ((Service)this.containerLauncher).start();
  super.serviceStart();
}
项目:aliyun-oss-hadoop-fs    文件:EventFetcher.java   
public EventFetcher(TaskAttemptID reduce,
                    TaskUmbilicalProtocol umbilical,
                    ShuffleScheduler<K,V> scheduler,
                    ExceptionReporter reporter,
                    int maxEventsToFetch) {
  setName("EventFetcher for fetching Map Completion Events");
  setDaemon(true);    
  this.reduce = reduce;
  this.umbilical = umbilical;
  this.scheduler = scheduler;
  exceptionReporter = reporter;
  this.maxEventsToFetch = maxEventsToFetch;
}
项目:big-c    文件:MRAppMaster.java   
@Override
protected void serviceStart() throws Exception {
  if (job.isUber()) {
    this.containerLauncher = new LocalContainerLauncher(context,
        (TaskUmbilicalProtocol) taskAttemptListener);
    ((LocalContainerLauncher) this.containerLauncher)
            .setEncryptedSpillKey(encryptedSpillKey);
  } else {
    this.containerLauncher = new ContainerLauncherImpl(context);
  }
  ((Service)this.containerLauncher).init(getConfig());
  ((Service)this.containerLauncher).start();
  super.serviceStart();
}
项目:big-c    文件:EventFetcher.java   
public EventFetcher(TaskAttemptID reduce,
                    TaskUmbilicalProtocol umbilical,
                    ShuffleScheduler<K,V> scheduler,
                    ExceptionReporter reporter,
                    int maxEventsToFetch) {
  setName("EventFetcher for fetching Map Completion Events");
  setDaemon(true);    
  this.reduce = reduce;
  this.umbilical = umbilical;
  this.scheduler = scheduler;
  exceptionReporter = reporter;
  this.maxEventsToFetch = maxEventsToFetch;
}
项目:hadoop-2.6.0-cdh5.4.3    文件:MRAppMaster.java   
@Override
protected void serviceStart() throws Exception {
  if (job.isUber()) {
    this.containerLauncher = new LocalContainerLauncher(context,
        (TaskUmbilicalProtocol) taskAttemptListener);
  } else {
    this.containerLauncher = new ContainerLauncherImpl(context);
  }
  ((Service)this.containerLauncher).init(getConfig());
  ((Service)this.containerLauncher).start();
  super.serviceStart();
}
项目:hadoop-2.6.0-cdh5.4.3    文件:EventFetcher.java   
public EventFetcher(TaskAttemptID reduce,
                    TaskUmbilicalProtocol umbilical,
                    ShuffleScheduler<K,V> scheduler,
                    ExceptionReporter reporter,
                    int maxEventsToFetch) {
  setName("EventFetcher for fetching Map Completion Events");
  setDaemon(true);    
  this.reduce = reduce;
  this.umbilical = umbilical;
  this.scheduler = scheduler;
  exceptionReporter = reporter;
  this.maxEventsToFetch = maxEventsToFetch;
}
项目:hadoop-plus    文件:MRAppMaster.java   
@Override
protected void serviceStart() throws Exception {
  if (job.isUber()) {
    this.containerLauncher = new LocalContainerLauncher(context,
        (TaskUmbilicalProtocol) taskAttemptListener);
  } else {
    this.containerLauncher = new ContainerLauncherImpl(context);
  }
  ((Service)this.containerLauncher).init(getConfig());
  ((Service)this.containerLauncher).start();
  super.serviceStart();
}
项目:hadoop-plus    文件:EventFetcher.java   
public EventFetcher(TaskAttemptID reduce,
                    TaskUmbilicalProtocol umbilical,
                    ShuffleScheduler<K,V> scheduler,
                    ExceptionReporter reporter,
                    int maxEventsToFetch) {
  setName("EventFetcher for fetching Map Completion Events");
  setDaemon(true);    
  this.reduce = reduce;
  this.umbilical = umbilical;
  this.scheduler = scheduler;
  exceptionReporter = reporter;
  this.maxEventsToFetch = maxEventsToFetch;
}
项目:FlexMap    文件:MRAppMaster.java   
@Override
protected void serviceStart() throws Exception {
  if (job.isUber()) {
    this.containerLauncher = new LocalContainerLauncher(context,
        (TaskUmbilicalProtocol) taskAttemptListener);
  } else {
    this.containerLauncher = new ContainerLauncherImpl(context);
  }
  ((Service)this.containerLauncher).init(getConfig());
  ((Service)this.containerLauncher).start();
  super.serviceStart();
}
项目:FlexMap    文件:EventFetcher.java   
public EventFetcher(TaskAttemptID reduce,
                    TaskUmbilicalProtocol umbilical,
                    ShuffleScheduler<K,V> scheduler,
                    ExceptionReporter reporter,
                    int maxEventsToFetch) {
  setName("EventFetcher for fetching Map Completion Events");
  setDaemon(true);    
  this.reduce = reduce;
  this.umbilical = umbilical;
  this.scheduler = scheduler;
  exceptionReporter = reporter;
  this.maxEventsToFetch = maxEventsToFetch;
}
项目:hops    文件:MRAppMaster.java   
@Override
protected void serviceStart() throws Exception {
  if (job.isUber()) {
    this.containerLauncher = new LocalContainerLauncher(context,
        (TaskUmbilicalProtocol) taskAttemptListener, jobClassLoader);
    ((LocalContainerLauncher) this.containerLauncher)
            .setEncryptedSpillKey(encryptedSpillKey);
  } else {
    this.containerLauncher = new ContainerLauncherImpl(context);
  }
  ((Service)this.containerLauncher).init(getConfig());
  ((Service)this.containerLauncher).start();
  super.serviceStart();
}
项目:hops    文件:EventFetcher.java   
public EventFetcher(TaskAttemptID reduce,
                    TaskUmbilicalProtocol umbilical,
                    ShuffleScheduler<K,V> scheduler,
                    ExceptionReporter reporter,
                    int maxEventsToFetch) {
  setName("EventFetcher for fetching Map Completion Events");
  setDaemon(true);    
  this.reduce = reduce;
  this.umbilical = umbilical;
  this.scheduler = scheduler;
  exceptionReporter = reporter;
  this.maxEventsToFetch = maxEventsToFetch;
}
项目:hadoop-TCP    文件:MRAppMaster.java   
@Override
protected void serviceStart() throws Exception {
  if (job.isUber()) {
    this.containerLauncher = new LocalContainerLauncher(context,
        (TaskUmbilicalProtocol) taskAttemptListener);
  } else {
    this.containerLauncher = new ContainerLauncherImpl(context);
  }
  ((Service)this.containerLauncher).init(getConfig());
  ((Service)this.containerLauncher).start();
  super.serviceStart();
}
项目:hadoop-TCP    文件:EventFetcher.java   
public EventFetcher(TaskAttemptID reduce,
                    TaskUmbilicalProtocol umbilical,
                    ShuffleScheduler<K,V> scheduler,
                    ExceptionReporter reporter,
                    int maxEventsToFetch) {
  setName("EventFetcher for fetching Map Completion Events");
  setDaemon(true);    
  this.reduce = reduce;
  this.umbilical = umbilical;
  this.scheduler = scheduler;
  exceptionReporter = reporter;
  this.maxEventsToFetch = maxEventsToFetch;
}
项目:hardfs    文件:MRAppMaster.java   
@Override
protected void serviceStart() throws Exception {
  if (job.isUber()) {
    this.containerLauncher = new LocalContainerLauncher(context,
        (TaskUmbilicalProtocol) taskAttemptListener);
  } else {
    this.containerLauncher = new ContainerLauncherImpl(context);
  }
  ((Service)this.containerLauncher).init(getConfig());
  ((Service)this.containerLauncher).start();
  super.serviceStart();
}
项目:hardfs    文件:EventFetcher.java   
public EventFetcher(TaskAttemptID reduce,
                    TaskUmbilicalProtocol umbilical,
                    ShuffleScheduler<K,V> scheduler,
                    ExceptionReporter reporter,
                    int maxEventsToFetch) {
  setName("EventFetcher for fetching Map Completion Events");
  setDaemon(true);    
  this.reduce = reduce;
  this.umbilical = umbilical;
  this.scheduler = scheduler;
  exceptionReporter = reporter;
  this.maxEventsToFetch = maxEventsToFetch;
}
项目:hadoop-on-lustre2    文件:MRAppMaster.java   
@Override
protected void serviceStart() throws Exception {
  if (job.isUber()) {
    this.containerLauncher = new LocalContainerLauncher(context,
        (TaskUmbilicalProtocol) taskAttemptListener);
  } else {
    this.containerLauncher = new ContainerLauncherImpl(context);
  }
  ((Service)this.containerLauncher).init(getConfig());
  ((Service)this.containerLauncher).start();
  super.serviceStart();
}
项目:hadoop-on-lustre2    文件:EventFetcher.java   
public EventFetcher(TaskAttemptID reduce,
                    TaskUmbilicalProtocol umbilical,
                    ShuffleScheduler<K,V> scheduler,
                    ExceptionReporter reporter,
                    int maxEventsToFetch) {
  setName("EventFetcher for fetching Map Completion Events");
  setDaemon(true);    
  this.reduce = reduce;
  this.umbilical = umbilical;
  this.scheduler = scheduler;
  exceptionReporter = reporter;
  this.maxEventsToFetch = maxEventsToFetch;
}
项目:mapreduce-fork    文件:Shuffle.java   
public Shuffle(TaskAttemptID reduceId, JobConf jobConf, FileSystem localFS,
               TaskUmbilicalProtocol umbilical,
               LocalDirAllocator localDirAllocator,  
               Reporter reporter,
               CompressionCodec codec,
               Class<? extends Reducer> combinerClass,
               CombineOutputCollector<K,V> combineCollector,
               Counters.Counter spilledRecordsCounter,
               Counters.Counter reduceCombineInputCounter,
               Counters.Counter shuffledMapsCounter,
               Counters.Counter reduceShuffleBytes,
               Counters.Counter failedShuffleCounter,
               Counters.Counter mergedMapOutputsCounter,
               TaskStatus status,
               Progress copyPhase,
               Progress mergePhase,
               Task reduceTask) {
  this.reduceId = reduceId;
  this.jobConf = jobConf;
  this.umbilical = umbilical;
  this.reporter = reporter;
  this.metrics = new ShuffleClientMetrics(reduceId, jobConf);
  this.copyPhase = copyPhase;
  this.taskStatus = status;
  this.reduceTask = reduceTask;

  scheduler = 
    new ShuffleScheduler<K,V>(jobConf, status, this, copyPhase, 
                              shuffledMapsCounter, 
                              reduceShuffleBytes, failedShuffleCounter);
  merger = new MergeManager<K, V>(reduceId, jobConf, localFS, 
                                  localDirAllocator, reporter, codec, 
                                  combinerClass, combineCollector, 
                                  spilledRecordsCounter, 
                                  reduceCombineInputCounter, 
                                  mergedMapOutputsCounter, 
                                  this, mergePhase);
}
项目:mapreduce-fork    文件:EventFetcher.java   
public EventFetcher(TaskAttemptID reduce,
                    TaskUmbilicalProtocol umbilical,
                    ShuffleScheduler<K,V> scheduler,
                    ExceptionReporter reporter) {
  setName("EventFetcher for fetching Map Completion Events");
  setDaemon(true);    
  this.reduce = reduce;
  this.umbilical = umbilical;
  this.scheduler = scheduler;
  exceptionReporter = reporter;
}
项目:hadoop    文件:TestTaskImpl.java   
@Override
public void run(JobConf job, TaskUmbilicalProtocol umbilical)
    throws IOException, ClassNotFoundException, InterruptedException {
  return;
}
项目:hadoop    文件:TestShufflePlugin.java   
@Test
/**
 * A testing method verifying availability and accessibility of API that is needed
 * for sub-classes of ShuffleConsumerPlugin
 */
public void testConsumerApi() {

  JobConf jobConf = new JobConf();
  ShuffleConsumerPlugin<K, V> shuffleConsumerPlugin = new TestShuffleConsumerPlugin<K, V>();

  //mock creation
  ReduceTask mockReduceTask = mock(ReduceTask.class);
  TaskUmbilicalProtocol mockUmbilical = mock(TaskUmbilicalProtocol.class);
  Reporter mockReporter = mock(Reporter.class);
  FileSystem mockFileSystem = mock(FileSystem.class);
  Class<? extends org.apache.hadoop.mapred.Reducer>  combinerClass = jobConf.getCombinerClass();
  @SuppressWarnings("unchecked")  // needed for mock with generic
  CombineOutputCollector<K, V>  mockCombineOutputCollector =
    (CombineOutputCollector<K, V>) mock(CombineOutputCollector.class);
  org.apache.hadoop.mapreduce.TaskAttemptID mockTaskAttemptID =
    mock(org.apache.hadoop.mapreduce.TaskAttemptID.class);
  LocalDirAllocator mockLocalDirAllocator = mock(LocalDirAllocator.class);
  CompressionCodec mockCompressionCodec = mock(CompressionCodec.class);
  Counter mockCounter = mock(Counter.class);
  TaskStatus mockTaskStatus = mock(TaskStatus.class);
  Progress mockProgress = mock(Progress.class);
  MapOutputFile mockMapOutputFile = mock(MapOutputFile.class);
  Task mockTask = mock(Task.class);

  try {
    String [] dirs = jobConf.getLocalDirs();
    // verify that these APIs are available through super class handler
    ShuffleConsumerPlugin.Context<K, V> context =
   new ShuffleConsumerPlugin.Context<K, V>(mockTaskAttemptID, jobConf, mockFileSystem,
                                              mockUmbilical, mockLocalDirAllocator,
                                              mockReporter, mockCompressionCodec,
                                              combinerClass, mockCombineOutputCollector,
                                              mockCounter, mockCounter, mockCounter,
                                              mockCounter, mockCounter, mockCounter,
                                              mockTaskStatus, mockProgress, mockProgress,
                                              mockTask, mockMapOutputFile, null);
    shuffleConsumerPlugin.init(context);
    shuffleConsumerPlugin.run();
    shuffleConsumerPlugin.close();
  }
  catch (Exception e) {
    assertTrue("Threw exception:" + e, false);
  }

  // verify that these APIs are available for 3rd party plugins
  mockReduceTask.getTaskID();
  mockReduceTask.getJobID();
  mockReduceTask.getNumMaps();
  mockReduceTask.getPartition();
  mockReporter.progress();
}
项目:hadoop    文件:TestShuffleScheduler.java   
@SuppressWarnings("rawtypes")
@Test
public <K, V> void TestSucceedAndFailedCopyMap() throws Exception {
  JobConf job = new JobConf();
  job.setNumMapTasks(2);
  //mock creation
  TaskUmbilicalProtocol mockUmbilical = mock(TaskUmbilicalProtocol.class);
  Reporter mockReporter = mock(Reporter.class);
  FileSystem mockFileSystem = mock(FileSystem.class);
  Class<? extends org.apache.hadoop.mapred.Reducer>  combinerClass = job.getCombinerClass();
  @SuppressWarnings("unchecked")  // needed for mock with generic
  CombineOutputCollector<K, V>  mockCombineOutputCollector =
      (CombineOutputCollector<K, V>) mock(CombineOutputCollector.class);
  org.apache.hadoop.mapreduce.TaskAttemptID mockTaskAttemptID =
      mock(org.apache.hadoop.mapreduce.TaskAttemptID.class);
  LocalDirAllocator mockLocalDirAllocator = mock(LocalDirAllocator.class);
  CompressionCodec mockCompressionCodec = mock(CompressionCodec.class);
  Counter mockCounter = mock(Counter.class);
  TaskStatus mockTaskStatus = mock(TaskStatus.class);
  Progress mockProgress = mock(Progress.class);
  MapOutputFile mockMapOutputFile = mock(MapOutputFile.class);
  Task mockTask = mock(Task.class);
  @SuppressWarnings("unchecked")
  MapOutput<K, V> output = mock(MapOutput.class);

  ShuffleConsumerPlugin.Context<K, V> context =
      new ShuffleConsumerPlugin.Context<K, V>(
          mockTaskAttemptID, job, mockFileSystem,
          mockUmbilical, mockLocalDirAllocator,
          mockReporter, mockCompressionCodec,
          combinerClass, mockCombineOutputCollector,
          mockCounter, mockCounter, mockCounter,
          mockCounter, mockCounter, mockCounter,
          mockTaskStatus, mockProgress, mockProgress,
          mockTask, mockMapOutputFile, null);
  TaskStatus status = new TaskStatus() {
    @Override
    public boolean getIsMap() {
      return false;
    }
    @Override
    public void addFetchFailedMap(TaskAttemptID mapTaskId) {
    }
  };
  Progress progress = new Progress();
  ShuffleSchedulerImpl<K, V> scheduler = new ShuffleSchedulerImpl<K, V>(job,
      status, null, null, progress, context.getShuffledMapsCounter(),
      context.getReduceShuffleBytes(), context.getFailedShuffleCounter());

  MapHost host1 = new MapHost("host1", null);
  TaskAttemptID failedAttemptID = new TaskAttemptID(
      new org.apache.hadoop.mapred.TaskID(
      new JobID("test",0), TaskType.MAP, 0), 0);

  TaskAttemptID succeedAttemptID = new TaskAttemptID(
      new org.apache.hadoop.mapred.TaskID(
      new JobID("test",0), TaskType.MAP, 1), 1);

  // handle output fetch failure for failedAttemptID, part I
  scheduler.hostFailed(host1.getHostName());

  // handle output fetch succeed for succeedAttemptID
  long bytes = (long)500 * 1024 * 1024;
  scheduler.copySucceeded(succeedAttemptID, host1, bytes, 0, 500000, output);

  // handle output fetch failure for failedAttemptID, part II
  // for MAPREDUCE-6361: verify no NPE exception get thrown out
  scheduler.copyFailed(failedAttemptID, host1, true, false);
}
项目:hadoop    文件:TestEventFetcher.java   
@Test
public void testConsecutiveFetch()
    throws IOException, InterruptedException {
  final int MAX_EVENTS_TO_FETCH = 100;
  TaskAttemptID tid = new TaskAttemptID("12345", 1, TaskType.REDUCE, 1, 1);

  TaskUmbilicalProtocol umbilical = mock(TaskUmbilicalProtocol.class);
  when(umbilical.getMapCompletionEvents(any(JobID.class),
      anyInt(), anyInt(), any(TaskAttemptID.class)))
    .thenReturn(getMockedCompletionEventsUpdate(0, 0));
  when(umbilical.getMapCompletionEvents(any(JobID.class),
      eq(0), eq(MAX_EVENTS_TO_FETCH), eq(tid)))
    .thenReturn(getMockedCompletionEventsUpdate(0, MAX_EVENTS_TO_FETCH));
  when(umbilical.getMapCompletionEvents(any(JobID.class),
      eq(MAX_EVENTS_TO_FETCH), eq(MAX_EVENTS_TO_FETCH), eq(tid)))
    .thenReturn(getMockedCompletionEventsUpdate(MAX_EVENTS_TO_FETCH,
        MAX_EVENTS_TO_FETCH));
  when(umbilical.getMapCompletionEvents(any(JobID.class),
      eq(MAX_EVENTS_TO_FETCH*2), eq(MAX_EVENTS_TO_FETCH), eq(tid)))
    .thenReturn(getMockedCompletionEventsUpdate(MAX_EVENTS_TO_FETCH*2, 3));

  @SuppressWarnings("unchecked")
  ShuffleScheduler<String,String> scheduler =
    mock(ShuffleScheduler.class);
  ExceptionReporter reporter = mock(ExceptionReporter.class);

  EventFetcherForTest<String,String> ef =
      new EventFetcherForTest<String,String>(tid, umbilical, scheduler,
          reporter, MAX_EVENTS_TO_FETCH);
  ef.getMapCompletionEvents();

  verify(reporter, never()).reportException(any(Throwable.class));
  InOrder inOrder = inOrder(umbilical);
  inOrder.verify(umbilical).getMapCompletionEvents(any(JobID.class),
      eq(0), eq(MAX_EVENTS_TO_FETCH), eq(tid));
  inOrder.verify(umbilical).getMapCompletionEvents(any(JobID.class),
      eq(MAX_EVENTS_TO_FETCH), eq(MAX_EVENTS_TO_FETCH), eq(tid));
  inOrder.verify(umbilical).getMapCompletionEvents(any(JobID.class),
      eq(MAX_EVENTS_TO_FETCH*2), eq(MAX_EVENTS_TO_FETCH), eq(tid));
  verify(scheduler, times(MAX_EVENTS_TO_FETCH*2 + 3)).resolve(
      any(TaskCompletionEvent.class));
}
项目:hadoop    文件:TestEventFetcher.java   
public EventFetcherForTest(TaskAttemptID reduce,
    TaskUmbilicalProtocol umbilical, ShuffleScheduler<K,V> scheduler,
    ExceptionReporter reporter, int maxEventsToFetch) {
  super(reduce, umbilical, scheduler, reporter, maxEventsToFetch);
}
项目:aliyun-oss-hadoop-fs    文件:TestTaskImpl.java   
@Override
public void run(JobConf job, TaskUmbilicalProtocol umbilical)
    throws IOException, ClassNotFoundException, InterruptedException {
  return;
}
项目:aliyun-oss-hadoop-fs    文件:TestShufflePlugin.java   
@Test
/**
 * A testing method verifying availability and accessibility of API that is needed
 * for sub-classes of ShuffleConsumerPlugin
 */
public void testConsumerApi() {

  JobConf jobConf = new JobConf();
  ShuffleConsumerPlugin<K, V> shuffleConsumerPlugin = new TestShuffleConsumerPlugin<K, V>();

  //mock creation
  ReduceTask mockReduceTask = mock(ReduceTask.class);
  TaskUmbilicalProtocol mockUmbilical = mock(TaskUmbilicalProtocol.class);
  Reporter mockReporter = mock(Reporter.class);
  FileSystem mockFileSystem = mock(FileSystem.class);
  Class<? extends org.apache.hadoop.mapred.Reducer>  combinerClass = jobConf.getCombinerClass();
  @SuppressWarnings("unchecked")  // needed for mock with generic
  CombineOutputCollector<K, V>  mockCombineOutputCollector =
    (CombineOutputCollector<K, V>) mock(CombineOutputCollector.class);
  org.apache.hadoop.mapreduce.TaskAttemptID mockTaskAttemptID =
    mock(org.apache.hadoop.mapreduce.TaskAttemptID.class);
  LocalDirAllocator mockLocalDirAllocator = mock(LocalDirAllocator.class);
  CompressionCodec mockCompressionCodec = mock(CompressionCodec.class);
  Counter mockCounter = mock(Counter.class);
  TaskStatus mockTaskStatus = mock(TaskStatus.class);
  Progress mockProgress = mock(Progress.class);
  MapOutputFile mockMapOutputFile = mock(MapOutputFile.class);
  Task mockTask = mock(Task.class);

  try {
    String [] dirs = jobConf.getLocalDirs();
    // verify that these APIs are available through super class handler
    ShuffleConsumerPlugin.Context<K, V> context =
   new ShuffleConsumerPlugin.Context<K, V>(mockTaskAttemptID, jobConf, mockFileSystem,
                                              mockUmbilical, mockLocalDirAllocator,
                                              mockReporter, mockCompressionCodec,
                                              combinerClass, mockCombineOutputCollector,
                                              mockCounter, mockCounter, mockCounter,
                                              mockCounter, mockCounter, mockCounter,
                                              mockTaskStatus, mockProgress, mockProgress,
                                              mockTask, mockMapOutputFile, null);
    shuffleConsumerPlugin.init(context);
    shuffleConsumerPlugin.run();
    shuffleConsumerPlugin.close();
  }
  catch (Exception e) {
    assertTrue("Threw exception:" + e, false);
  }

  // verify that these APIs are available for 3rd party plugins
  mockReduceTask.getTaskID();
  mockReduceTask.getJobID();
  mockReduceTask.getNumMaps();
  mockReduceTask.getPartition();
  mockReporter.progress();
}
项目:aliyun-oss-hadoop-fs    文件:TestShuffleScheduler.java   
@SuppressWarnings("rawtypes")
@Test
public <K, V> void TestSucceedAndFailedCopyMap() throws Exception {
  JobConf job = new JobConf();
  job.setNumMapTasks(2);
  //mock creation
  TaskUmbilicalProtocol mockUmbilical = mock(TaskUmbilicalProtocol.class);
  Reporter mockReporter = mock(Reporter.class);
  FileSystem mockFileSystem = mock(FileSystem.class);
  Class<? extends org.apache.hadoop.mapred.Reducer>  combinerClass = job.getCombinerClass();
  @SuppressWarnings("unchecked")  // needed for mock with generic
  CombineOutputCollector<K, V>  mockCombineOutputCollector =
      (CombineOutputCollector<K, V>) mock(CombineOutputCollector.class);
  org.apache.hadoop.mapreduce.TaskAttemptID mockTaskAttemptID =
      mock(org.apache.hadoop.mapreduce.TaskAttemptID.class);
  LocalDirAllocator mockLocalDirAllocator = mock(LocalDirAllocator.class);
  CompressionCodec mockCompressionCodec = mock(CompressionCodec.class);
  Counter mockCounter = mock(Counter.class);
  TaskStatus mockTaskStatus = mock(TaskStatus.class);
  Progress mockProgress = mock(Progress.class);
  MapOutputFile mockMapOutputFile = mock(MapOutputFile.class);
  Task mockTask = mock(Task.class);
  @SuppressWarnings("unchecked")
  MapOutput<K, V> output = mock(MapOutput.class);

  ShuffleConsumerPlugin.Context<K, V> context =
      new ShuffleConsumerPlugin.Context<K, V>(
          mockTaskAttemptID, job, mockFileSystem,
          mockUmbilical, mockLocalDirAllocator,
          mockReporter, mockCompressionCodec,
          combinerClass, mockCombineOutputCollector,
          mockCounter, mockCounter, mockCounter,
          mockCounter, mockCounter, mockCounter,
          mockTaskStatus, mockProgress, mockProgress,
          mockTask, mockMapOutputFile, null);
  TaskStatus status = new TaskStatus() {
    @Override
    public boolean getIsMap() {
      return false;
    }
    @Override
    public void addFetchFailedMap(TaskAttemptID mapTaskId) {
    }
  };
  Progress progress = new Progress();
  ShuffleSchedulerImpl<K, V> scheduler = new ShuffleSchedulerImpl<K, V>(job,
      status, null, null, progress, context.getShuffledMapsCounter(),
      context.getReduceShuffleBytes(), context.getFailedShuffleCounter());

  MapHost host1 = new MapHost("host1", null);
  TaskAttemptID failedAttemptID = new TaskAttemptID(
      new org.apache.hadoop.mapred.TaskID(
      new JobID("test",0), TaskType.MAP, 0), 0);

  TaskAttemptID succeedAttemptID = new TaskAttemptID(
      new org.apache.hadoop.mapred.TaskID(
      new JobID("test",0), TaskType.MAP, 1), 1);

  // handle output fetch failure for failedAttemptID, part I
  scheduler.hostFailed(host1.getHostName());

  // handle output fetch succeed for succeedAttemptID
  long bytes = (long)500 * 1024 * 1024;
  scheduler.copySucceeded(succeedAttemptID, host1, bytes, 0, 500000, output);

  // handle output fetch failure for failedAttemptID, part II
  // for MAPREDUCE-6361: verify no NPE exception get thrown out
  scheduler.copyFailed(failedAttemptID, host1, true, false);
}
项目:aliyun-oss-hadoop-fs    文件:TestEventFetcher.java   
@Test
public void testConsecutiveFetch()
    throws IOException, InterruptedException {
  final int MAX_EVENTS_TO_FETCH = 100;
  TaskAttemptID tid = new TaskAttemptID("12345", 1, TaskType.REDUCE, 1, 1);

  TaskUmbilicalProtocol umbilical = mock(TaskUmbilicalProtocol.class);
  when(umbilical.getMapCompletionEvents(any(JobID.class),
      anyInt(), anyInt(), any(TaskAttemptID.class)))
    .thenReturn(getMockedCompletionEventsUpdate(0, 0));
  when(umbilical.getMapCompletionEvents(any(JobID.class),
      eq(0), eq(MAX_EVENTS_TO_FETCH), eq(tid)))
    .thenReturn(getMockedCompletionEventsUpdate(0, MAX_EVENTS_TO_FETCH));
  when(umbilical.getMapCompletionEvents(any(JobID.class),
      eq(MAX_EVENTS_TO_FETCH), eq(MAX_EVENTS_TO_FETCH), eq(tid)))
    .thenReturn(getMockedCompletionEventsUpdate(MAX_EVENTS_TO_FETCH,
        MAX_EVENTS_TO_FETCH));
  when(umbilical.getMapCompletionEvents(any(JobID.class),
      eq(MAX_EVENTS_TO_FETCH*2), eq(MAX_EVENTS_TO_FETCH), eq(tid)))
    .thenReturn(getMockedCompletionEventsUpdate(MAX_EVENTS_TO_FETCH*2, 3));

  @SuppressWarnings("unchecked")
  ShuffleScheduler<String,String> scheduler =
    mock(ShuffleScheduler.class);
  ExceptionReporter reporter = mock(ExceptionReporter.class);

  EventFetcherForTest<String,String> ef =
      new EventFetcherForTest<String,String>(tid, umbilical, scheduler,
          reporter, MAX_EVENTS_TO_FETCH);
  ef.getMapCompletionEvents();

  verify(reporter, never()).reportException(any(Throwable.class));
  InOrder inOrder = inOrder(umbilical);
  inOrder.verify(umbilical).getMapCompletionEvents(any(JobID.class),
      eq(0), eq(MAX_EVENTS_TO_FETCH), eq(tid));
  inOrder.verify(umbilical).getMapCompletionEvents(any(JobID.class),
      eq(MAX_EVENTS_TO_FETCH), eq(MAX_EVENTS_TO_FETCH), eq(tid));
  inOrder.verify(umbilical).getMapCompletionEvents(any(JobID.class),
      eq(MAX_EVENTS_TO_FETCH*2), eq(MAX_EVENTS_TO_FETCH), eq(tid));
  verify(scheduler, times(MAX_EVENTS_TO_FETCH*2 + 3)).resolve(
      any(TaskCompletionEvent.class));
}
项目:aliyun-oss-hadoop-fs    文件:TestEventFetcher.java   
public EventFetcherForTest(TaskAttemptID reduce,
    TaskUmbilicalProtocol umbilical, ShuffleScheduler<K,V> scheduler,
    ExceptionReporter reporter, int maxEventsToFetch) {
  super(reduce, umbilical, scheduler, reporter, maxEventsToFetch);
}
项目:big-c    文件:TestTaskImpl.java   
@Override
public void run(JobConf job, TaskUmbilicalProtocol umbilical)
    throws IOException, ClassNotFoundException, InterruptedException {
  return;
}
项目:big-c    文件:TestShufflePlugin.java   
@Test
/**
 * A testing method verifying availability and accessibility of API that is needed
 * for sub-classes of ShuffleConsumerPlugin
 */
public void testConsumerApi() {

  JobConf jobConf = new JobConf();
  ShuffleConsumerPlugin<K, V> shuffleConsumerPlugin = new TestShuffleConsumerPlugin<K, V>();

  //mock creation
  ReduceTask mockReduceTask = mock(ReduceTask.class);
  TaskUmbilicalProtocol mockUmbilical = mock(TaskUmbilicalProtocol.class);
  Reporter mockReporter = mock(Reporter.class);
  FileSystem mockFileSystem = mock(FileSystem.class);
  Class<? extends org.apache.hadoop.mapred.Reducer>  combinerClass = jobConf.getCombinerClass();
  @SuppressWarnings("unchecked")  // needed for mock with generic
  CombineOutputCollector<K, V>  mockCombineOutputCollector =
    (CombineOutputCollector<K, V>) mock(CombineOutputCollector.class);
  org.apache.hadoop.mapreduce.TaskAttemptID mockTaskAttemptID =
    mock(org.apache.hadoop.mapreduce.TaskAttemptID.class);
  LocalDirAllocator mockLocalDirAllocator = mock(LocalDirAllocator.class);
  CompressionCodec mockCompressionCodec = mock(CompressionCodec.class);
  Counter mockCounter = mock(Counter.class);
  TaskStatus mockTaskStatus = mock(TaskStatus.class);
  Progress mockProgress = mock(Progress.class);
  MapOutputFile mockMapOutputFile = mock(MapOutputFile.class);
  Task mockTask = mock(Task.class);

  try {
    String [] dirs = jobConf.getLocalDirs();
    // verify that these APIs are available through super class handler
    ShuffleConsumerPlugin.Context<K, V> context =
   new ShuffleConsumerPlugin.Context<K, V>(mockTaskAttemptID, jobConf, mockFileSystem,
                                              mockUmbilical, mockLocalDirAllocator,
                                              mockReporter, mockCompressionCodec,
                                              combinerClass, mockCombineOutputCollector,
                                              mockCounter, mockCounter, mockCounter,
                                              mockCounter, mockCounter, mockCounter,
                                              mockTaskStatus, mockProgress, mockProgress,
                                              mockTask, mockMapOutputFile, null);
    shuffleConsumerPlugin.init(context);
    shuffleConsumerPlugin.run();
    shuffleConsumerPlugin.close();
  }
  catch (Exception e) {
    assertTrue("Threw exception:" + e, false);
  }

  // verify that these APIs are available for 3rd party plugins
  mockReduceTask.getTaskID();
  mockReduceTask.getJobID();
  mockReduceTask.getNumMaps();
  mockReduceTask.getPartition();
  mockReporter.progress();
}
项目:big-c    文件:TestShuffleScheduler.java   
@SuppressWarnings("rawtypes")
@Test
public <K, V> void TestSucceedAndFailedCopyMap() throws Exception {
  JobConf job = new JobConf();
  job.setNumMapTasks(2);
  //mock creation
  TaskUmbilicalProtocol mockUmbilical = mock(TaskUmbilicalProtocol.class);
  Reporter mockReporter = mock(Reporter.class);
  FileSystem mockFileSystem = mock(FileSystem.class);
  Class<? extends org.apache.hadoop.mapred.Reducer>  combinerClass = job.getCombinerClass();
  @SuppressWarnings("unchecked")  // needed for mock with generic
  CombineOutputCollector<K, V>  mockCombineOutputCollector =
      (CombineOutputCollector<K, V>) mock(CombineOutputCollector.class);
  org.apache.hadoop.mapreduce.TaskAttemptID mockTaskAttemptID =
      mock(org.apache.hadoop.mapreduce.TaskAttemptID.class);
  LocalDirAllocator mockLocalDirAllocator = mock(LocalDirAllocator.class);
  CompressionCodec mockCompressionCodec = mock(CompressionCodec.class);
  Counter mockCounter = mock(Counter.class);
  TaskStatus mockTaskStatus = mock(TaskStatus.class);
  Progress mockProgress = mock(Progress.class);
  MapOutputFile mockMapOutputFile = mock(MapOutputFile.class);
  Task mockTask = mock(Task.class);
  @SuppressWarnings("unchecked")
  MapOutput<K, V> output = mock(MapOutput.class);

  ShuffleConsumerPlugin.Context<K, V> context =
      new ShuffleConsumerPlugin.Context<K, V>(
          mockTaskAttemptID, job, mockFileSystem,
          mockUmbilical, mockLocalDirAllocator,
          mockReporter, mockCompressionCodec,
          combinerClass, mockCombineOutputCollector,
          mockCounter, mockCounter, mockCounter,
          mockCounter, mockCounter, mockCounter,
          mockTaskStatus, mockProgress, mockProgress,
          mockTask, mockMapOutputFile, null);
  TaskStatus status = new TaskStatus() {
    @Override
    public boolean getIsMap() {
      return false;
    }
    @Override
    public void addFetchFailedMap(TaskAttemptID mapTaskId) {
    }
  };
  Progress progress = new Progress();
  ShuffleSchedulerImpl<K, V> scheduler = new ShuffleSchedulerImpl<K, V>(job,
      status, null, null, progress, context.getShuffledMapsCounter(),
      context.getReduceShuffleBytes(), context.getFailedShuffleCounter());

  MapHost host1 = new MapHost("host1", null);
  TaskAttemptID failedAttemptID = new TaskAttemptID(
      new org.apache.hadoop.mapred.TaskID(
      new JobID("test",0), TaskType.MAP, 0), 0);

  TaskAttemptID succeedAttemptID = new TaskAttemptID(
      new org.apache.hadoop.mapred.TaskID(
      new JobID("test",0), TaskType.MAP, 1), 1);

  // handle output fetch failure for failedAttemptID, part I
  scheduler.hostFailed(host1.getHostName());

  // handle output fetch succeed for succeedAttemptID
  long bytes = (long)500 * 1024 * 1024;
  scheduler.copySucceeded(succeedAttemptID, host1, bytes, 0, 500000, output);

  // handle output fetch failure for failedAttemptID, part II
  // for MAPREDUCE-6361: verify no NPE exception get thrown out
  scheduler.copyFailed(failedAttemptID, host1, true, false);
}
项目:big-c    文件:TestEventFetcher.java   
@Test
public void testConsecutiveFetch()
    throws IOException, InterruptedException {
  final int MAX_EVENTS_TO_FETCH = 100;
  TaskAttemptID tid = new TaskAttemptID("12345", 1, TaskType.REDUCE, 1, 1);

  TaskUmbilicalProtocol umbilical = mock(TaskUmbilicalProtocol.class);
  when(umbilical.getMapCompletionEvents(any(JobID.class),
      anyInt(), anyInt(), any(TaskAttemptID.class)))
    .thenReturn(getMockedCompletionEventsUpdate(0, 0));
  when(umbilical.getMapCompletionEvents(any(JobID.class),
      eq(0), eq(MAX_EVENTS_TO_FETCH), eq(tid)))
    .thenReturn(getMockedCompletionEventsUpdate(0, MAX_EVENTS_TO_FETCH));
  when(umbilical.getMapCompletionEvents(any(JobID.class),
      eq(MAX_EVENTS_TO_FETCH), eq(MAX_EVENTS_TO_FETCH), eq(tid)))
    .thenReturn(getMockedCompletionEventsUpdate(MAX_EVENTS_TO_FETCH,
        MAX_EVENTS_TO_FETCH));
  when(umbilical.getMapCompletionEvents(any(JobID.class),
      eq(MAX_EVENTS_TO_FETCH*2), eq(MAX_EVENTS_TO_FETCH), eq(tid)))
    .thenReturn(getMockedCompletionEventsUpdate(MAX_EVENTS_TO_FETCH*2, 3));

  @SuppressWarnings("unchecked")
  ShuffleScheduler<String,String> scheduler =
    mock(ShuffleScheduler.class);
  ExceptionReporter reporter = mock(ExceptionReporter.class);

  EventFetcherForTest<String,String> ef =
      new EventFetcherForTest<String,String>(tid, umbilical, scheduler,
          reporter, MAX_EVENTS_TO_FETCH);
  ef.getMapCompletionEvents();

  verify(reporter, never()).reportException(any(Throwable.class));
  InOrder inOrder = inOrder(umbilical);
  inOrder.verify(umbilical).getMapCompletionEvents(any(JobID.class),
      eq(0), eq(MAX_EVENTS_TO_FETCH), eq(tid));
  inOrder.verify(umbilical).getMapCompletionEvents(any(JobID.class),
      eq(MAX_EVENTS_TO_FETCH), eq(MAX_EVENTS_TO_FETCH), eq(tid));
  inOrder.verify(umbilical).getMapCompletionEvents(any(JobID.class),
      eq(MAX_EVENTS_TO_FETCH*2), eq(MAX_EVENTS_TO_FETCH), eq(tid));
  verify(scheduler, times(MAX_EVENTS_TO_FETCH*2 + 3)).resolve(
      any(TaskCompletionEvent.class));
}
项目:big-c    文件:TestEventFetcher.java   
public EventFetcherForTest(TaskAttemptID reduce,
    TaskUmbilicalProtocol umbilical, ShuffleScheduler<K,V> scheduler,
    ExceptionReporter reporter, int maxEventsToFetch) {
  super(reduce, umbilical, scheduler, reporter, maxEventsToFetch);
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestTaskImpl.java   
@Override
public void run(JobConf job, TaskUmbilicalProtocol umbilical)
    throws IOException, ClassNotFoundException, InterruptedException {
  return;
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestShufflePlugin.java   
@Test
/**
 * A testing method verifying availability and accessibility of API that is needed
 * for sub-classes of ShuffleConsumerPlugin
 */
public void testConsumerApi() {

  JobConf jobConf = new JobConf();
  ShuffleConsumerPlugin<K, V> shuffleConsumerPlugin = new TestShuffleConsumerPlugin<K, V>();

  //mock creation
  ReduceTask mockReduceTask = mock(ReduceTask.class);
  TaskUmbilicalProtocol mockUmbilical = mock(TaskUmbilicalProtocol.class);
  Reporter mockReporter = mock(Reporter.class);
  FileSystem mockFileSystem = mock(FileSystem.class);
  Class<? extends org.apache.hadoop.mapred.Reducer>  combinerClass = jobConf.getCombinerClass();
  @SuppressWarnings("unchecked")  // needed for mock with generic
  CombineOutputCollector<K, V>  mockCombineOutputCollector =
    (CombineOutputCollector<K, V>) mock(CombineOutputCollector.class);
  org.apache.hadoop.mapreduce.TaskAttemptID mockTaskAttemptID =
    mock(org.apache.hadoop.mapreduce.TaskAttemptID.class);
  LocalDirAllocator mockLocalDirAllocator = mock(LocalDirAllocator.class);
  CompressionCodec mockCompressionCodec = mock(CompressionCodec.class);
  Counter mockCounter = mock(Counter.class);
  TaskStatus mockTaskStatus = mock(TaskStatus.class);
  Progress mockProgress = mock(Progress.class);
  MapOutputFile mockMapOutputFile = mock(MapOutputFile.class);
  Task mockTask = mock(Task.class);

  try {
    String [] dirs = jobConf.getLocalDirs();
    // verify that these APIs are available through super class handler
    ShuffleConsumerPlugin.Context<K, V> context =
   new ShuffleConsumerPlugin.Context<K, V>(mockTaskAttemptID, jobConf, mockFileSystem,
                                              mockUmbilical, mockLocalDirAllocator,
                                              mockReporter, mockCompressionCodec,
                                              combinerClass, mockCombineOutputCollector,
                                              mockCounter, mockCounter, mockCounter,
                                              mockCounter, mockCounter, mockCounter,
                                              mockTaskStatus, mockProgress, mockProgress,
                                              mockTask, mockMapOutputFile, null);
    shuffleConsumerPlugin.init(context);
    shuffleConsumerPlugin.run();
    shuffleConsumerPlugin.close();
  }
  catch (Exception e) {
    assertTrue("Threw exception:" + e, false);
  }

  // verify that these APIs are available for 3rd party plugins
  mockReduceTask.getTaskID();
  mockReduceTask.getJobID();
  mockReduceTask.getNumMaps();
  mockReduceTask.getPartition();
  mockReporter.progress();
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestEventFetcher.java   
@Test
public void testConsecutiveFetch()
    throws IOException, InterruptedException {
  final int MAX_EVENTS_TO_FETCH = 100;
  TaskAttemptID tid = new TaskAttemptID("12345", 1, TaskType.REDUCE, 1, 1);

  TaskUmbilicalProtocol umbilical = mock(TaskUmbilicalProtocol.class);
  when(umbilical.getMapCompletionEvents(any(JobID.class),
      anyInt(), anyInt(), any(TaskAttemptID.class)))
    .thenReturn(getMockedCompletionEventsUpdate(0, 0));
  when(umbilical.getMapCompletionEvents(any(JobID.class),
      eq(0), eq(MAX_EVENTS_TO_FETCH), eq(tid)))
    .thenReturn(getMockedCompletionEventsUpdate(0, MAX_EVENTS_TO_FETCH));
  when(umbilical.getMapCompletionEvents(any(JobID.class),
      eq(MAX_EVENTS_TO_FETCH), eq(MAX_EVENTS_TO_FETCH), eq(tid)))
    .thenReturn(getMockedCompletionEventsUpdate(MAX_EVENTS_TO_FETCH,
        MAX_EVENTS_TO_FETCH));
  when(umbilical.getMapCompletionEvents(any(JobID.class),
      eq(MAX_EVENTS_TO_FETCH*2), eq(MAX_EVENTS_TO_FETCH), eq(tid)))
    .thenReturn(getMockedCompletionEventsUpdate(MAX_EVENTS_TO_FETCH*2, 3));

  @SuppressWarnings("unchecked")
  ShuffleScheduler<String,String> scheduler =
    mock(ShuffleScheduler.class);
  ExceptionReporter reporter = mock(ExceptionReporter.class);

  EventFetcherForTest<String,String> ef =
      new EventFetcherForTest<String,String>(tid, umbilical, scheduler,
          reporter, MAX_EVENTS_TO_FETCH);
  ef.getMapCompletionEvents();

  verify(reporter, never()).reportException(any(Throwable.class));
  InOrder inOrder = inOrder(umbilical);
  inOrder.verify(umbilical).getMapCompletionEvents(any(JobID.class),
      eq(0), eq(MAX_EVENTS_TO_FETCH), eq(tid));
  inOrder.verify(umbilical).getMapCompletionEvents(any(JobID.class),
      eq(MAX_EVENTS_TO_FETCH), eq(MAX_EVENTS_TO_FETCH), eq(tid));
  inOrder.verify(umbilical).getMapCompletionEvents(any(JobID.class),
      eq(MAX_EVENTS_TO_FETCH*2), eq(MAX_EVENTS_TO_FETCH), eq(tid));
  verify(scheduler, times(MAX_EVENTS_TO_FETCH*2 + 3)).resolve(
      any(TaskCompletionEvent.class));
}