use of org.apache.cassandra.streaming.StreamPlan in project cassandra by apache.
the class LocalSyncTask method createStreamPlan.
@VisibleForTesting
StreamPlan createStreamPlan() {
InetAddressAndPort remote = nodePair.peer;
StreamPlan plan = new StreamPlan(StreamOperation.REPAIR, 1, false, pendingRepair, previewKind).listeners(this).flushBeforeTransfer(pendingRepair == null);
if (requestRanges) {
// see comment on RangesAtEndpoint.toDummyList for why we synthesize replicas here
plan.requestRanges(remote, desc.keyspace, RangesAtEndpoint.toDummyList(rangesToSync), RangesAtEndpoint.toDummyList(Collections.emptyList()), desc.columnFamily);
}
if (transferRanges) {
// send ranges to the remote node if we are not performing a pull repair
// see comment on RangesAtEndpoint.toDummyList for why we synthesize replicas here
plan.transferRanges(remote, desc.keyspace, RangesAtEndpoint.toDummyList(rangesToSync), desc.columnFamily);
}
return plan;
}
use of org.apache.cassandra.streaming.StreamPlan in project cassandra by apache.
the class LegacySSTableTest method streamLegacyTable.
private void streamLegacyTable(String tablePattern, String legacyVersion) throws Exception {
String table = String.format(tablePattern, legacyVersion);
SSTableReader sstable = SSTableReader.open(getDescriptor(legacyVersion, table));
IPartitioner p = sstable.getPartitioner();
List<Range<Token>> ranges = new ArrayList<>();
ranges.add(new Range<>(p.getMinimumToken(), p.getToken(ByteBufferUtil.bytes("100"))));
ranges.add(new Range<>(p.getToken(ByteBufferUtil.bytes("100")), p.getMinimumToken()));
List<OutgoingStream> streams = Lists.newArrayList(new CassandraOutgoingFile(StreamOperation.OTHER, sstable.ref(), sstable.getPositionsForRanges(ranges), ranges, sstable.estimatedKeysForRanges(ranges)));
new StreamPlan(StreamOperation.OTHER).transferStreams(FBUtilities.getBroadcastAddressAndPort(), streams).execute().get();
}
use of org.apache.cassandra.streaming.StreamPlan in project cassandra by apache.
the class LocalSyncTaskTest method incrementalRepairStreamPlan.
@Test
public void incrementalRepairStreamPlan() throws Exception {
UUID sessionID = registerSession(cfs, true, true);
ActiveRepairService.ParentRepairSession prs = ActiveRepairService.instance.getParentRepairSession(sessionID);
RepairJobDesc desc = new RepairJobDesc(sessionID, UUIDGen.getTimeUUID(), KEYSPACE1, CF_STANDARD, prs.getRanges());
TreeResponse r1 = new TreeResponse(local, createInitialTree(desc, DatabaseDescriptor.getPartitioner()));
TreeResponse r2 = new TreeResponse(PARTICIPANT2, createInitialTree(desc, DatabaseDescriptor.getPartitioner()));
LocalSyncTask task = new LocalSyncTask(desc, r1.endpoint, r2.endpoint, MerkleTrees.difference(r1.trees, r2.trees), desc.parentSessionId, true, true, PreviewKind.NONE);
StreamPlan plan = task.createStreamPlan();
assertEquals(desc.parentSessionId, plan.getPendingRepair());
assertFalse(plan.getFlushBeforeTransfer());
assertNumInOut(plan, 1, 1);
}
use of org.apache.cassandra.streaming.StreamPlan in project cassandra by apache.
the class LocalSyncTaskTest method transientLocalStreamPlan.
/**
* Don't request streams if the other endpoint is a transient replica
*/
@Test
public void transientLocalStreamPlan() throws NoSuchRepairSessionException {
UUID sessionID = registerSession(cfs, true, true);
ActiveRepairService.ParentRepairSession prs = ActiveRepairService.instance.getParentRepairSession(sessionID);
RepairJobDesc desc = new RepairJobDesc(sessionID, UUIDGen.getTimeUUID(), KEYSPACE1, CF_STANDARD, prs.getRanges());
TreeResponse r1 = new TreeResponse(local, createInitialTree(desc, DatabaseDescriptor.getPartitioner()));
TreeResponse r2 = new TreeResponse(PARTICIPANT2, createInitialTree(desc, DatabaseDescriptor.getPartitioner()));
LocalSyncTask task = new LocalSyncTask(desc, r1.endpoint, r2.endpoint, MerkleTrees.difference(r1.trees, r2.trees), desc.parentSessionId, false, true, PreviewKind.NONE);
StreamPlan plan = task.createStreamPlan();
assertNumInOut(plan, 0, 1);
}
use of org.apache.cassandra.streaming.StreamPlan in project cassandra by apache.
the class LocalSyncTask method startSync.
/**
* Starts sending/receiving our list of differences to/from the remote endpoint: creates a callback
* that will be called out of band once the streams complete.
*/
protected void startSync(List<Range<Token>> differences) {
InetAddress local = FBUtilities.getBroadcastAddress();
// We can take anyone of the node as source or destination, however if one is localhost, we put at source to avoid a forwarding
InetAddress dst = r2.endpoint.equals(local) ? r1.endpoint : r2.endpoint;
InetAddress preferred = SystemKeyspace.getPreferredIP(dst);
String message = String.format("Performing streaming repair of %d ranges with %s", differences.size(), dst);
logger.info("[repair #{}] {}", desc.sessionId, message);
boolean isIncremental = false;
if (desc.parentSessionId != null) {
ActiveRepairService.ParentRepairSession prs = ActiveRepairService.instance.getParentRepairSession(desc.parentSessionId);
isIncremental = prs.isIncremental;
}
Tracing.traceRepair(message);
StreamPlan plan = new StreamPlan("Repair", repairedAt, 1, false, isIncremental, false, pendingRepair).listeners(this).flushBeforeTransfer(true).requestRanges(dst, preferred, desc.keyspace, differences, desc.columnFamily);
if (!pullRepair) {
// send ranges to the remote node if we are not performing a pull repair
plan.transferRanges(dst, preferred, desc.keyspace, differences, desc.columnFamily);
}
plan.execute();
}
Aggregations