当前位置: 首页>>代码示例>>Java>>正文


Java BasicPartitionOwner类代码示例

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


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

示例1: mockServiceGetVertexPartitionOwner

import org.apache.giraph.partition.BasicPartitionOwner; //导入依赖的package包/类
/**
 * Prepare a mocked CentralizedServiceWorker.
 *
 * @param numOfPartitions The number of partitions
 * @return CentralizedServiceWorker
 */
public static CentralizedServiceWorker<IntWritable, IntWritable,
    IntWritable> mockServiceGetVertexPartitionOwner(final int
    numOfPartitions) {
  CentralizedServiceWorker<IntWritable, IntWritable, IntWritable> service =
      Mockito.mock(CentralizedServiceWorker.class);
  Answer<PartitionOwner> answer = new Answer<PartitionOwner>() {
    @Override
    public PartitionOwner answer(InvocationOnMock invocation) throws
        Throwable {
      IntWritable vertexId = (IntWritable) invocation.getArguments()[0];
      return new BasicPartitionOwner(vertexId.get() % numOfPartitions, null);
    }
  };
  Mockito.when(service.getVertexPartitionOwner(
      Mockito.any(IntWritable.class))).thenAnswer(answer);
  return service;
}
 
开发者ID:renato2099,项目名称:giraph-gora,代码行数:24,代码来源:MockUtils.java

示例2: mockServiceGetVertexPartitionOwner

import org.apache.giraph.partition.BasicPartitionOwner; //导入依赖的package包/类
public static CentralizedServiceWorker<IntWritable, IntWritable,
    IntWritable, IntWritable> mockServiceGetVertexPartitionOwner(final int
    numOfPartitions) {
  CentralizedServiceWorker<IntWritable, IntWritable, IntWritable,
      IntWritable> service = Mockito.mock(CentralizedServiceWorker.class);
  Answer<PartitionOwner> answer = new Answer<PartitionOwner>() {
    @Override
    public PartitionOwner answer(InvocationOnMock invocation) throws
        Throwable {
      IntWritable vertexId = (IntWritable) invocation.getArguments()[0];
      return new BasicPartitionOwner(vertexId.get() % numOfPartitions, null);
    }
  };
  Mockito.when(service.getVertexPartitionOwner(
      Mockito.any(IntWritable.class))).thenAnswer(answer);
  return service;
}
 
开发者ID:zfighter,项目名称:giraph-research,代码行数:18,代码来源:MockUtils.java

示例3: createPartitionOwner

import org.apache.giraph.partition.BasicPartitionOwner; //导入依赖的package包/类
@Override
public PartitionOwner createPartitionOwner() {
  return new BasicPartitionOwner();
}
 
开发者ID:wmoustafa,项目名称:granada,代码行数:5,代码来源:IdWorkerPartitioner.java

示例4: generateChangedPartitionOwners

import org.apache.giraph.partition.BasicPartitionOwner; //导入依赖的package包/类
@Override
public Collection<PartitionOwner> generateChangedPartitionOwners(
    Collection<PartitionStats> allPartitionStatsList,
    Collection<WorkerInfo> availableWorkerInfos,
    int maxWorkers,
    long superstep) {
  // Assign all the partitions to
  // superstep mod availableWorkerInfos
  // Guaranteed to be different if the workers (and their order)
  // do not change
  long workerIndex = superstep % availableWorkerInfos.size();
  int i = 0;
  WorkerInfo chosenWorkerInfo = null;
  for (WorkerInfo workerInfo : availableWorkerInfos) {
    if (workerIndex == i) {
      chosenWorkerInfo = workerInfo;
    }
    ++i;
  }
  if (LOG.isInfoEnabled()) {
    LOG.info("generateChangedPartitionOwners: Chosen worker " +
             "for superstep " + superstep + " is " +
             chosenWorkerInfo);
  }

  List<PartitionOwner> partitionOwnerList = new ArrayList<PartitionOwner>();
  for (PartitionOwner partitionOwner :
    getCurrentPartitionOwners()) {
    WorkerInfo prevWorkerinfo =
      partitionOwner.getWorkerInfo().equals(chosenWorkerInfo) ?
        null : partitionOwner.getWorkerInfo();
    PartitionOwner tmpPartitionOwner =
      new BasicPartitionOwner(partitionOwner.getPartitionId(),
                              chosenWorkerInfo,
                              prevWorkerinfo,
                              null);
    partitionOwnerList.add(tmpPartitionOwner);
    LOG.info("partition owner was " + partitionOwner +
        ", new " + tmpPartitionOwner);
  }
  setPartitionOwnerList(partitionOwnerList);
  return partitionOwnerList;
}
 
开发者ID:renato2099,项目名称:giraph-gora,代码行数:44,代码来源:SuperstepHashPartitionerFactory.java


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