本文整理汇总了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;
}
示例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;
}
示例3: createPartitionOwner
import org.apache.giraph.partition.BasicPartitionOwner; //导入依赖的package包/类
@Override
public PartitionOwner createPartitionOwner() {
return new BasicPartitionOwner();
}
示例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;
}