mirror of https://github.com/apache/cassandra
Refactor validation logic in StorageService.rebuild
patch by Stefan Miklosovic; reviewed by Ariel Weisberg for CASSANDRA-18803
This commit is contained in:
parent
4ab31d34c8
commit
8bbf92a670
|
|
@ -1,4 +1,5 @@
|
|||
3.0.30
|
||||
* Refactor validation logic in StorageService.rebuild (CASSANDRA-18803)
|
||||
* Make alternation of a user type validate the same way as creation of a user type does (CASSANDRA-18585)
|
||||
* Backport of CASSANDRA-16905 Further restrict schema column drop/recreate conversions (CASSANDRA-18760)
|
||||
* CQLSH emits a warning when the server version doesn't match (CASSANDRA-18745)
|
||||
|
|
|
|||
|
|
@ -1308,35 +1308,27 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
|
|||
|
||||
public void rebuild(String sourceDc)
|
||||
{
|
||||
try
|
||||
if (sourceDc != null)
|
||||
{
|
||||
// check ongoing rebuild
|
||||
if (!isRebuilding.compareAndSet(false, true))
|
||||
TokenMetadata.Topology topology = getTokenMetadata().cloneOnlyTokenMap().getTopology();
|
||||
Set<String> availableDCs = topology.getDatacenterEndpoints().keySet();
|
||||
if (!availableDCs.contains(sourceDc))
|
||||
{
|
||||
throw new IllegalStateException("Node is still rebuilding. Check nodetool netstats.");
|
||||
}
|
||||
|
||||
if (sourceDc != null)
|
||||
{
|
||||
TokenMetadata.Topology topology = getTokenMetadata().cloneOnlyTokenMap().getTopology();
|
||||
Set<String> availableDCs = topology.getDatacenterEndpoints().keySet();
|
||||
if (!availableDCs.contains(sourceDc))
|
||||
{
|
||||
throw new IllegalArgumentException(String.format("Provided datacenter '%s' is not a valid datacenter, available datacenters are: %s",
|
||||
sourceDc, String.join(",", availableDCs)));
|
||||
}
|
||||
throw new IllegalArgumentException(String.format("Provided datacenter '%s' is not a valid datacenter, available datacenters are: %s",
|
||||
sourceDc, String.join(",", availableDCs)));
|
||||
}
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
isRebuilding.set(false);
|
||||
throw ex;
|
||||
}
|
||||
|
||||
logger.info("rebuild from dc: {}", sourceDc == null ? "(any dc)" : sourceDc);
|
||||
// check ongoing rebuild
|
||||
if (!isRebuilding.compareAndSet(false, true))
|
||||
{
|
||||
throw new IllegalStateException("Node is still rebuilding. Check nodetool netstats.");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
logger.info("rebuild from dc: {}", sourceDc == null ? "(any dc)" : sourceDc);
|
||||
|
||||
RangeStreamer streamer = new RangeStreamer(tokenMetadata,
|
||||
null,
|
||||
FBUtilities.getBroadcastAddress(),
|
||||
|
|
|
|||
Loading…
Reference in New Issue