for (int i = 0; i < 11; ++i) {
VertexMutations<IntWritable, IntWritable, IntWritable, IntWritable>
mutations = new VertexMutations<IntWritable, IntWritable,
IntWritable, IntWritable>();
for (int j = 0; j < 3; ++j) {
Vertex vertex = conf.createVertex();
vertex.initialize(new IntWritable(i), new IntWritable(j));
mutations.addVertex(vertex);
}
for (int j = 0; j < 2; ++j) {
mutations.removeVertex();
}
for (int j = 0; j < 5; ++j) {
Edge<IntWritable, IntWritable> edge =
EdgeFactory.create(new IntWritable(i), new IntWritable(2 * j));
mutations.addEdge(edge);
}
for (int j = 0; j < 7; ++j) {
mutations.removeEdge(new IntWritable(j));
}
vertexIdMutations.put(new IntWritable(i), mutations);
}
// Send the request
SendPartitionMutationsRequest<IntWritable, IntWritable, IntWritable,
IntWritable> request =
new SendPartitionMutationsRequest<IntWritable, IntWritable,
IntWritable, IntWritable>(partitionId, vertexIdMutations);
GiraphMetrics.init(conf);
client.sendWritableRequest(workerInfo.getTaskId(), request);
client.waitAllRequests();
// Stop the service
client.stop();
server.stop();
// Check the output
ConcurrentHashMap<IntWritable, VertexMutations<IntWritable, IntWritable,
IntWritable, IntWritable>> inVertexIdMutations =
serverData.getVertexMutations();
int keySum = 0;
for (Entry<IntWritable, VertexMutations<IntWritable, IntWritable,
IntWritable, IntWritable>> entry :
inVertexIdMutations.entrySet()) {
synchronized (entry.getValue()) {
keySum += entry.getKey().get();
int vertexValueSum = 0;
for (Vertex<IntWritable, IntWritable, IntWritable, IntWritable>
vertex : entry.getValue().getAddedVertexList()) {
vertexValueSum += vertex.getValue().get();
}
assertEquals(3, vertexValueSum);
assertEquals(2, entry.getValue().getRemovedVertexCount());
int removeEdgeValueSum = 0;
for (Edge<IntWritable, IntWritable> edge :