mirror of https://github.com/apache/cassandra
Establish bootstrap stream sessions sequentially
patch by Paulo Motta; reviewed by yukim for CASSANDRA-6992
This commit is contained in:
parent
07c6a36cc3
commit
a018bcb7d7
|
|
@ -1,4 +1,5 @@
|
||||||
3.2
|
3.2
|
||||||
|
* Establish bootstrap stream sessions sequentially (CASSANDRA-6992)
|
||||||
* Sort compactionhistory output by timestamp (CASSANDRA-10464)
|
* Sort compactionhistory output by timestamp (CASSANDRA-10464)
|
||||||
* More efficient BTree removal (CASSANDRA-9991)
|
* More efficient BTree removal (CASSANDRA-9991)
|
||||||
* Make tablehistograms accept the same syntax as tablestats (CASSANDRA-10149)
|
* Make tablehistograms accept the same syntax as tablestats (CASSANDRA-10149)
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,8 @@ public class BootStrapper extends ProgressEventNotifierSupport
|
||||||
"Bootstrap",
|
"Bootstrap",
|
||||||
useStrictConsistency,
|
useStrictConsistency,
|
||||||
DatabaseDescriptor.getEndpointSnitch(),
|
DatabaseDescriptor.getEndpointSnitch(),
|
||||||
stateStore);
|
stateStore,
|
||||||
|
true);
|
||||||
streamer.addSourceFilter(new RangeStreamer.FailureDetectorSourceFilter(FailureDetector.instance));
|
streamer.addSourceFilter(new RangeStreamer.FailureDetectorSourceFilter(FailureDetector.instance));
|
||||||
|
|
||||||
for (String keyspaceName : Schema.instance.getNonSystemKeyspaces())
|
for (String keyspaceName : Schema.instance.getNonSystemKeyspaces())
|
||||||
|
|
|
||||||
|
|
@ -117,13 +117,14 @@ public class RangeStreamer
|
||||||
String description,
|
String description,
|
||||||
boolean useStrictConsistency,
|
boolean useStrictConsistency,
|
||||||
IEndpointSnitch snitch,
|
IEndpointSnitch snitch,
|
||||||
StreamStateStore stateStore)
|
StreamStateStore stateStore,
|
||||||
|
boolean connectSequentially)
|
||||||
{
|
{
|
||||||
this.metadata = metadata;
|
this.metadata = metadata;
|
||||||
this.tokens = tokens;
|
this.tokens = tokens;
|
||||||
this.address = address;
|
this.address = address;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.streamPlan = new StreamPlan(description, true);
|
this.streamPlan = new StreamPlan(description, true, connectSequentially);
|
||||||
this.useStrictConsistency = useStrictConsistency;
|
this.useStrictConsistency = useStrictConsistency;
|
||||||
this.snitch = snitch;
|
this.snitch = snitch;
|
||||||
this.stateStore = stateStore;
|
this.stateStore = stateStore;
|
||||||
|
|
|
||||||
|
|
@ -159,7 +159,7 @@ public class SSTableLoader implements StreamEventHandler
|
||||||
client.init(keyspace);
|
client.init(keyspace);
|
||||||
outputHandler.output("Established connection to initial hosts");
|
outputHandler.output("Established connection to initial hosts");
|
||||||
|
|
||||||
StreamPlan plan = new StreamPlan("Bulk Load", 0, connectionsPerHost, false, false).connectionFactory(client.getConnectionFactory());
|
StreamPlan plan = new StreamPlan("Bulk Load", 0, connectionsPerHost, false, false, false).connectionFactory(client.getConnectionFactory());
|
||||||
|
|
||||||
Map<InetAddress, Collection<Range<Token>>> endpointToRanges = client.getEndpointToRangesMap();
|
Map<InetAddress, Collection<Range<Token>>> endpointToRanges = client.getEndpointToRangesMap();
|
||||||
openSSTables(endpointToRanges);
|
openSSTables(endpointToRanges);
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ public class LocalSyncTask extends SyncTask implements StreamEventHandler
|
||||||
isIncremental = prs.isIncremental;
|
isIncremental = prs.isIncremental;
|
||||||
}
|
}
|
||||||
Tracing.traceRepair(message);
|
Tracing.traceRepair(message);
|
||||||
new StreamPlan("Repair", repairedAt, 1, false, isIncremental).listeners(this)
|
new StreamPlan("Repair", repairedAt, 1, false, isIncremental, false).listeners(this)
|
||||||
.flushBeforeTransfer(true)
|
.flushBeforeTransfer(true)
|
||||||
// request ranges from the remote node
|
// request ranges from the remote node
|
||||||
.requestRanges(dst, preferred, desc.keyspace, differences, desc.columnFamily)
|
.requestRanges(dst, preferred, desc.keyspace, differences, desc.columnFamily)
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ public class StreamingRepairTask implements Runnable, StreamEventHandler
|
||||||
ActiveRepairService.ParentRepairSession prs = ActiveRepairService.instance.getParentRepairSession(desc.parentSessionId);
|
ActiveRepairService.ParentRepairSession prs = ActiveRepairService.instance.getParentRepairSession(desc.parentSessionId);
|
||||||
isIncremental = prs.isIncremental;
|
isIncremental = prs.isIncremental;
|
||||||
}
|
}
|
||||||
new StreamPlan("Repair", repairedAt, 1, false, isIncremental).listeners(this)
|
new StreamPlan("Repair", repairedAt, 1, false, isIncremental, false).listeners(this)
|
||||||
.flushBeforeTransfer(true)
|
.flushBeforeTransfer(true)
|
||||||
// request ranges from the remote node
|
// request ranges from the remote node
|
||||||
.requestRanges(dest, preferred, desc.keyspace, request.ranges, desc.columnFamily)
|
.requestRanges(dest, preferred, desc.keyspace, request.ranges, desc.columnFamily)
|
||||||
|
|
|
||||||
|
|
@ -1106,7 +1106,8 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
|
||||||
"Rebuild",
|
"Rebuild",
|
||||||
!replacing && useStrictConsistency,
|
!replacing && useStrictConsistency,
|
||||||
DatabaseDescriptor.getEndpointSnitch(),
|
DatabaseDescriptor.getEndpointSnitch(),
|
||||||
streamStateStore);
|
streamStateStore,
|
||||||
|
false);
|
||||||
streamer.addSourceFilter(new RangeStreamer.FailureDetectorSourceFilter(FailureDetector.instance));
|
streamer.addSourceFilter(new RangeStreamer.FailureDetectorSourceFilter(FailureDetector.instance));
|
||||||
if (sourceDc != null)
|
if (sourceDc != null)
|
||||||
streamer.addSourceFilter(new RangeStreamer.SingleDatacenterFilter(DatabaseDescriptor.getEndpointSnitch(), sourceDc));
|
streamer.addSourceFilter(new RangeStreamer.SingleDatacenterFilter(DatabaseDescriptor.getEndpointSnitch(), sourceDc));
|
||||||
|
|
|
||||||
|
|
@ -41,19 +41,23 @@ public class StreamCoordinator
|
||||||
// streaming is handled directly by the ConnectionHandler's incoming and outgoing threads.
|
// streaming is handled directly by the ConnectionHandler's incoming and outgoing threads.
|
||||||
private static final DebuggableThreadPoolExecutor streamExecutor = DebuggableThreadPoolExecutor.createWithFixedPoolSize("StreamConnectionEstablisher",
|
private static final DebuggableThreadPoolExecutor streamExecutor = DebuggableThreadPoolExecutor.createWithFixedPoolSize("StreamConnectionEstablisher",
|
||||||
FBUtilities.getAvailableProcessors());
|
FBUtilities.getAvailableProcessors());
|
||||||
|
private final boolean connectSequentially;
|
||||||
|
|
||||||
private Map<InetAddress, HostStreamingData> peerSessions = new HashMap<>();
|
private Map<InetAddress, HostStreamingData> peerSessions = new HashMap<>();
|
||||||
private final int connectionsPerHost;
|
private final int connectionsPerHost;
|
||||||
private StreamConnectionFactory factory;
|
private StreamConnectionFactory factory;
|
||||||
private final boolean keepSSTableLevel;
|
private final boolean keepSSTableLevel;
|
||||||
private final boolean isIncremental;
|
private final boolean isIncremental;
|
||||||
|
private Iterator<StreamSession> sessionsToConnect = null;
|
||||||
|
|
||||||
public StreamCoordinator(int connectionsPerHost, boolean keepSSTableLevel, boolean isIncremental, StreamConnectionFactory factory)
|
public StreamCoordinator(int connectionsPerHost, boolean keepSSTableLevel, boolean isIncremental,
|
||||||
|
StreamConnectionFactory factory, boolean connectSequentially)
|
||||||
{
|
{
|
||||||
this.connectionsPerHost = connectionsPerHost;
|
this.connectionsPerHost = connectionsPerHost;
|
||||||
this.factory = factory;
|
this.factory = factory;
|
||||||
this.keepSSTableLevel = keepSSTableLevel;
|
this.keepSSTableLevel = keepSSTableLevel;
|
||||||
this.isIncremental = isIncremental;
|
this.isIncremental = isIncremental;
|
||||||
|
this.connectSequentially = connectSequentially;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setConnectionFactory(StreamConnectionFactory factory)
|
public void setConnectionFactory(StreamConnectionFactory factory)
|
||||||
|
|
@ -89,12 +93,61 @@ public class StreamCoordinator
|
||||||
return connectionsPerHost == 0;
|
return connectionsPerHost == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void connectAllStreamSessions()
|
public void connect(StreamResultFuture future)
|
||||||
|
{
|
||||||
|
if (this.connectSequentially)
|
||||||
|
connectSequentially(future);
|
||||||
|
else
|
||||||
|
connectAllStreamSessions();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void connectAllStreamSessions()
|
||||||
{
|
{
|
||||||
for (HostStreamingData data : peerSessions.values())
|
for (HostStreamingData data : peerSessions.values())
|
||||||
data.connectAllStreamSessions();
|
data.connectAllStreamSessions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void connectSequentially(StreamResultFuture future)
|
||||||
|
{
|
||||||
|
sessionsToConnect = getAllStreamSessions().iterator();
|
||||||
|
future.addEventListener(new StreamEventHandler()
|
||||||
|
{
|
||||||
|
public void handleStreamEvent(StreamEvent event)
|
||||||
|
{
|
||||||
|
if (event.eventType == StreamEvent.Type.STREAM_PREPARED)
|
||||||
|
{
|
||||||
|
connectNext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onSuccess(StreamState result)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onFailure(Throwable t)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
connectNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void connectNext()
|
||||||
|
{
|
||||||
|
if (sessionsToConnect == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (sessionsToConnect.hasNext())
|
||||||
|
{
|
||||||
|
StreamSession next = sessionsToConnect.next();
|
||||||
|
logger.debug("Connecting next session {} with {}.", next.planId(), next.peer.getHostAddress());
|
||||||
|
streamExecutor.execute(new StreamSessionConnector(next));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
logger.debug("Finished connecting all sessions");
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized Set<InetAddress> getPeers()
|
public synchronized Set<InetAddress> getPeers()
|
||||||
{
|
{
|
||||||
return new HashSet<>(peerSessions.keySet());
|
return new HashSet<>(peerSessions.keySet());
|
||||||
|
|
|
||||||
|
|
@ -47,19 +47,21 @@ public class StreamPlan
|
||||||
*/
|
*/
|
||||||
public StreamPlan(String description)
|
public StreamPlan(String description)
|
||||||
{
|
{
|
||||||
this(description, ActiveRepairService.UNREPAIRED_SSTABLE, 1, false, false);
|
this(description, ActiveRepairService.UNREPAIRED_SSTABLE, 1, false, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public StreamPlan(String description, boolean keepSSTableLevels)
|
public StreamPlan(String description, boolean keepSSTableLevels, boolean connectSequentially)
|
||||||
{
|
{
|
||||||
this(description, ActiveRepairService.UNREPAIRED_SSTABLE, 1, keepSSTableLevels, false);
|
this(description, ActiveRepairService.UNREPAIRED_SSTABLE, 1, keepSSTableLevels, false, connectSequentially);
|
||||||
}
|
}
|
||||||
|
|
||||||
public StreamPlan(String description, long repairedAt, int connectionsPerHost, boolean keepSSTableLevels, boolean isIncremental)
|
public StreamPlan(String description, long repairedAt, int connectionsPerHost, boolean keepSSTableLevels,
|
||||||
|
boolean isIncremental, boolean connectSequentially)
|
||||||
{
|
{
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.repairedAt = repairedAt;
|
this.repairedAt = repairedAt;
|
||||||
this.coordinator = new StreamCoordinator(connectionsPerHost, keepSSTableLevels, isIncremental, new DefaultConnectionFactory());
|
this.coordinator = new StreamCoordinator(connectionsPerHost, keepSSTableLevels, isIncremental, new DefaultConnectionFactory(),
|
||||||
|
connectSequentially);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -71,10 +71,12 @@ public final class StreamResultFuture extends AbstractFuture<StreamState>
|
||||||
|
|
||||||
private StreamResultFuture(UUID planId, String description, boolean keepSSTableLevels, boolean isIncremental)
|
private StreamResultFuture(UUID planId, String description, boolean keepSSTableLevels, boolean isIncremental)
|
||||||
{
|
{
|
||||||
this(planId, description, new StreamCoordinator(0, keepSSTableLevels, isIncremental, new DefaultConnectionFactory()));
|
this(planId, description, new StreamCoordinator(0, keepSSTableLevels, isIncremental,
|
||||||
|
new DefaultConnectionFactory(), false));
|
||||||
}
|
}
|
||||||
|
|
||||||
static StreamResultFuture init(UUID planId, String description, Collection<StreamEventHandler> listeners, StreamCoordinator coordinator)
|
static StreamResultFuture init(UUID planId, String description, Collection<StreamEventHandler> listeners,
|
||||||
|
StreamCoordinator coordinator)
|
||||||
{
|
{
|
||||||
StreamResultFuture future = createAndRegister(planId, description, coordinator);
|
StreamResultFuture future = createAndRegister(planId, description, coordinator);
|
||||||
if (listeners != null)
|
if (listeners != null)
|
||||||
|
|
@ -90,7 +92,8 @@ public final class StreamResultFuture extends AbstractFuture<StreamState>
|
||||||
{
|
{
|
||||||
session.init(future);
|
session.init(future);
|
||||||
}
|
}
|
||||||
coordinator.connectAllStreamSessions();
|
|
||||||
|
coordinator.connect(future);
|
||||||
|
|
||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ public class BootStrapperTest
|
||||||
InetAddress myEndpoint = InetAddress.getByName("127.0.0.1");
|
InetAddress myEndpoint = InetAddress.getByName("127.0.0.1");
|
||||||
|
|
||||||
assertEquals(numOldNodes, tmd.sortedTokens().size());
|
assertEquals(numOldNodes, tmd.sortedTokens().size());
|
||||||
RangeStreamer s = new RangeStreamer(tmd, null, myEndpoint, "Bootstrap", true, DatabaseDescriptor.getEndpointSnitch(), new StreamStateStore());
|
RangeStreamer s = new RangeStreamer(tmd, null, myEndpoint, "Bootstrap", true, DatabaseDescriptor.getEndpointSnitch(), new StreamStateStore(), false);
|
||||||
IFailureDetector mockFailureDetector = new IFailureDetector()
|
IFailureDetector mockFailureDetector = new IFailureDetector()
|
||||||
{
|
{
|
||||||
public boolean isAlive(InetAddress ep)
|
public boolean isAlive(InetAddress ep)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue