mirror of https://github.com/apache/cassandra
Fixed the inconsistency between distributedKeyspaces and distributedAndLocalKeyspaces
Patch by Jacek Lewandowski; reviewed by Benjamin Lerer, Berenguer Blasi, Ekaterina Dimitrova, Jeremiah Jordan for CASSANDRA-18747
This commit is contained in:
parent
ede18e6c9f
commit
ac71d0f56e
|
|
@ -1,4 +1,5 @@
|
|||
4.1.4
|
||||
* Fixed the inconsistency between distributedKeyspaces and distributedAndLocalKeyspaces (CASSANDRA-18747)
|
||||
* Internode legacy SSL storage port certificate is not hot reloaded on update (CASSANDRA-18681)
|
||||
* Nodetool paxos-only repair is no longer incremental (CASSANDRA-18466)
|
||||
* Waiting indefinitely on ReceivedMessage response in StreamSession#receive() can cause deadlock (CASSANDRA-18733)
|
||||
|
|
|
|||
|
|
@ -132,11 +132,12 @@ public abstract class DescribeStatement<T> extends CQLStatement.Raw implements C
|
|||
@Override
|
||||
public ResultMessage executeLocally(QueryState state, QueryOptions options)
|
||||
{
|
||||
Keyspaces keyspaces = Schema.instance.distributedAndLocalKeyspaces();
|
||||
Keyspaces keyspaces = Schema.instance.distributedKeyspaces();
|
||||
UUID schemaVersion = Schema.instance.getVersion();
|
||||
|
||||
keyspaces = Keyspaces.builder()
|
||||
.add(keyspaces)
|
||||
.add(Schema.instance.getLocalKeyspaces())
|
||||
.add(VirtualKeyspaceRegistry.instance.virtualKeyspacesMetadata())
|
||||
.build();
|
||||
|
||||
|
|
|
|||
|
|
@ -140,7 +140,6 @@ public final class CreateTableStatement extends AlterSchemaStatement
|
|||
{
|
||||
int totalUserTables = Schema.instance.getUserKeyspaces()
|
||||
.stream()
|
||||
.map(ksm -> ksm.name)
|
||||
.map(Keyspace::open)
|
||||
.mapToInt(keyspace -> keyspace.getColumnFamilyStores().size())
|
||||
.sum();
|
||||
|
|
|
|||
|
|
@ -768,14 +768,9 @@ public class Keyspace
|
|||
return Schema.instance.getKeyspaces().stream().map(Schema.instance::getKeyspaceInstance).filter(Objects::nonNull);
|
||||
}
|
||||
|
||||
public static Iterable<Keyspace> nonSystem()
|
||||
{
|
||||
return Iterables.transform(Schema.instance.getNonSystemKeyspaces().names(), Keyspace::open);
|
||||
}
|
||||
|
||||
public static Iterable<Keyspace> nonLocalStrategy()
|
||||
{
|
||||
return Iterables.transform(Schema.instance.getNonLocalStrategyKeyspaces().names(), Keyspace::open);
|
||||
return Iterables.transform(Schema.instance.distributedKeyspaces().names(), Keyspace::open);
|
||||
}
|
||||
|
||||
public static Iterable<Keyspace> system()
|
||||
|
|
|
|||
|
|
@ -1257,7 +1257,7 @@ public class CompactionManager implements CompactionManagerMBean
|
|||
/* Used in tests. */
|
||||
public void disableAutoCompaction()
|
||||
{
|
||||
for (String ksname : Schema.instance.getNonSystemKeyspaces().names())
|
||||
for (String ksname : Schema.instance.distributedKeyspaces().names())
|
||||
{
|
||||
for (ColumnFamilyStore cfs : Keyspace.open(ksname).getColumnFamilyStores())
|
||||
cfs.disableAutoCompaction();
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ public class BootStrapper extends ProgressEventNotifierSupport
|
|||
stateStore,
|
||||
true,
|
||||
DatabaseDescriptor.getStreamingConnectionsPerHost());
|
||||
final Collection<String> nonLocalStrategyKeyspaces = Schema.instance.getNonLocalStrategyKeyspaces().names();
|
||||
final Collection<String> nonLocalStrategyKeyspaces = Schema.instance.distributedKeyspaces().names();
|
||||
if (nonLocalStrategyKeyspaces.isEmpty())
|
||||
logger.debug("Schema does not contain any non-local keyspaces to stream on bootstrap");
|
||||
for (String keyspaceName : nonLocalStrategyKeyspaces)
|
||||
|
|
|
|||
|
|
@ -280,7 +280,7 @@ public class TableMetrics
|
|||
{
|
||||
long total = 0;
|
||||
long filtered = 0;
|
||||
for (String keyspace : Schema.instance.getNonSystemKeyspaces().names())
|
||||
for (String keyspace : Schema.instance.distributedKeyspaces().names())
|
||||
{
|
||||
|
||||
Keyspace k = Schema.instance.getKeyspaceInstance(keyspace);
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ public class SchemaArgsParser implements Iterable<ColumnFamilyStore>
|
|||
if (schemaArgs.isEmpty())
|
||||
{
|
||||
// iterate over everything
|
||||
Iterator<String> ksNames = Schema.instance.getNonLocalStrategyKeyspaces().names().iterator();
|
||||
Iterator<String> ksNames = Schema.instance.distributedKeyspaces().names().iterator();
|
||||
|
||||
return new AbstractIterator<ColumnFamilyStore>()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -18,20 +18,34 @@
|
|||
package org.apache.cassandra.schema;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.*;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.MapDifference;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.collect.Streams;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.apache.cassandra.config.CassandraRelevantProperties;
|
||||
import org.apache.cassandra.cql3.functions.*;
|
||||
import org.apache.cassandra.db.*;
|
||||
import org.apache.cassandra.cql3.functions.Function;
|
||||
import org.apache.cassandra.cql3.functions.FunctionName;
|
||||
import org.apache.cassandra.db.ColumnFamilyStore;
|
||||
import org.apache.cassandra.db.Keyspace;
|
||||
import org.apache.cassandra.db.KeyspaceNotDefinedException;
|
||||
import org.apache.cassandra.db.SystemKeyspace;
|
||||
import org.apache.cassandra.db.marshal.AbstractType;
|
||||
import org.apache.cassandra.db.virtual.VirtualKeyspaceRegistry;
|
||||
import org.apache.cassandra.exceptions.ConfigurationException;
|
||||
|
|
@ -49,9 +63,6 @@ import org.apache.cassandra.utils.FBUtilities;
|
|||
import org.apache.cassandra.utils.concurrent.Awaitable;
|
||||
import org.apache.cassandra.utils.concurrent.LoadingMap;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static com.google.common.collect.Iterables.size;
|
||||
import static java.lang.String.format;
|
||||
import static org.apache.cassandra.config.DatabaseDescriptor.isDaemonInitialized;
|
||||
|
|
@ -78,7 +89,6 @@ public class Schema implements SchemaProvider
|
|||
public static final Schema instance = new Schema();
|
||||
|
||||
private volatile Keyspaces distributedKeyspaces = Keyspaces.none();
|
||||
private volatile Keyspaces distributedAndLocalKeyspaces;
|
||||
|
||||
private final Keyspaces localKeyspaces;
|
||||
|
||||
|
|
@ -110,7 +120,6 @@ public class Schema implements SchemaProvider
|
|||
this.localKeyspaces = (CassandraRelevantProperties.FORCE_LOAD_LOCAL_KEYSPACES.getBoolean() || isDaemonInitialized() || isToolInitialized())
|
||||
? Keyspaces.of(SchemaKeyspace.metadata(), SystemKeyspace.metadata())
|
||||
: Keyspaces.none();
|
||||
this.distributedAndLocalKeyspaces = this.localKeyspaces;
|
||||
|
||||
this.localKeyspaces.forEach(this::loadNew);
|
||||
this.updateHandler = SchemaUpdateHandlerFactoryProvider.instance.get().getSchemaUpdateHandler(online, this::mergeAndUpdateVersion);
|
||||
|
|
@ -121,7 +130,6 @@ public class Schema implements SchemaProvider
|
|||
{
|
||||
this.online = online;
|
||||
this.localKeyspaces = localKeyspaces;
|
||||
this.distributedAndLocalKeyspaces = this.localKeyspaces;
|
||||
this.updateHandler = updateHandler;
|
||||
}
|
||||
|
||||
|
|
@ -163,7 +171,6 @@ public class Schema implements SchemaProvider
|
|||
reload(previous, ksm);
|
||||
|
||||
distributedKeyspaces = distributedKeyspaces.withAddedOrUpdated(ksm);
|
||||
distributedAndLocalKeyspaces = distributedAndLocalKeyspaces.withAddedOrUpdated(ksm);
|
||||
}
|
||||
|
||||
private synchronized void loadNew(KeyspaceMetadata ksm)
|
||||
|
|
@ -246,11 +253,6 @@ public class Schema implements SchemaProvider
|
|||
}
|
||||
}
|
||||
|
||||
public Keyspaces distributedAndLocalKeyspaces()
|
||||
{
|
||||
return distributedAndLocalKeyspaces;
|
||||
}
|
||||
|
||||
public Keyspaces distributedKeyspaces()
|
||||
{
|
||||
return distributedKeyspaces;
|
||||
|
|
@ -262,11 +264,11 @@ public class Schema implements SchemaProvider
|
|||
*/
|
||||
public int largestGcgs()
|
||||
{
|
||||
return distributedAndLocalKeyspaces().stream()
|
||||
.flatMap(ksm -> ksm.tables.stream())
|
||||
.mapToInt(tm -> tm.params.gcGraceSeconds)
|
||||
.max()
|
||||
.orElse(Integer.MIN_VALUE);
|
||||
return Streams.concat(distributedKeyspaces.stream(), localKeyspaces.stream())
|
||||
.flatMap(ksm -> ksm.tables.stream())
|
||||
.mapToInt(tm -> tm.params.gcGraceSeconds)
|
||||
.max()
|
||||
.orElse(Integer.MIN_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -277,7 +279,6 @@ public class Schema implements SchemaProvider
|
|||
private synchronized void unload(KeyspaceMetadata ksm)
|
||||
{
|
||||
distributedKeyspaces = distributedKeyspaces.without(ksm.name);
|
||||
distributedAndLocalKeyspaces = distributedAndLocalKeyspaces.without(ksm.name);
|
||||
|
||||
this.tableMetadataRefCache = tableMetadataRefCache.withRemovedRefs(ksm);
|
||||
|
||||
|
|
@ -286,13 +287,16 @@ public class Schema implements SchemaProvider
|
|||
|
||||
public int getNumberOfTables()
|
||||
{
|
||||
return distributedAndLocalKeyspaces().stream().mapToInt(k -> size(k.tablesAndViews())).sum();
|
||||
return Streams.concat(distributedKeyspaces.stream(), localKeyspaces.stream())
|
||||
.mapToInt(k -> size(k.tablesAndViews()))
|
||||
.sum();
|
||||
}
|
||||
|
||||
public ViewMetadata getView(String keyspaceName, String viewName)
|
||||
{
|
||||
assert keyspaceName != null;
|
||||
KeyspaceMetadata ksm = distributedAndLocalKeyspaces().getNullable(keyspaceName);
|
||||
KeyspaceMetadata ksm = distributedKeyspaces.getNullable(keyspaceName);
|
||||
ksm = ksm != null ? ksm : localKeyspaces.getNullable(keyspaceName);
|
||||
return (ksm == null) ? null : ksm.views.getNullable(viewName);
|
||||
}
|
||||
|
||||
|
|
@ -307,36 +311,18 @@ public class Schema implements SchemaProvider
|
|||
public KeyspaceMetadata getKeyspaceMetadata(String keyspaceName)
|
||||
{
|
||||
assert keyspaceName != null;
|
||||
KeyspaceMetadata keyspace = distributedAndLocalKeyspaces().getNullable(keyspaceName);
|
||||
return null != keyspace ? keyspace : VirtualKeyspaceRegistry.instance.getKeyspaceMetadataNullable(keyspaceName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all non-local keyspaces, that is, all but {@link SchemaConstants#LOCAL_SYSTEM_KEYSPACE_NAMES}
|
||||
* or virtual keyspaces.
|
||||
* @deprecated use {@link #distributedKeyspaces()}
|
||||
*/
|
||||
@Deprecated
|
||||
public Keyspaces getNonSystemKeyspaces()
|
||||
{
|
||||
return distributedKeyspaces;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all non-local keyspaces whose replication strategy is not {@link LocalStrategy}.
|
||||
*/
|
||||
public Keyspaces getNonLocalStrategyKeyspaces()
|
||||
{
|
||||
return distributedKeyspaces.filter(keyspace -> keyspace.params.replication.klass != LocalStrategy.class);
|
||||
KeyspaceMetadata ksm = distributedKeyspaces.getNullable(keyspaceName);
|
||||
ksm = ksm != null ? ksm : localKeyspaces.getNullable(keyspaceName);
|
||||
return null != ksm ? ksm : VirtualKeyspaceRegistry.instance.getKeyspaceMetadataNullable(keyspaceName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns user keyspaces, that is all but {@link SchemaConstants#LOCAL_SYSTEM_KEYSPACE_NAMES},
|
||||
* {@link SchemaConstants#REPLICATED_SYSTEM_KEYSPACE_NAMES} or virtual keyspaces.
|
||||
*/
|
||||
public Keyspaces getUserKeyspaces()
|
||||
public Sets.SetView<String> getUserKeyspaces()
|
||||
{
|
||||
return distributedKeyspaces.without(SchemaConstants.REPLICATED_SYSTEM_KEYSPACE_NAMES);
|
||||
return Sets.difference(distributedKeyspaces.names(), SchemaConstants.REPLICATED_SYSTEM_KEYSPACE_NAMES);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -355,11 +341,11 @@ public class Schema implements SchemaProvider
|
|||
}
|
||||
|
||||
/**
|
||||
* @return collection of the all keyspace names registered in the system (system and non-system)
|
||||
* @return a set of local and distributed keyspace names; it does not include virtual keyspaces
|
||||
*/
|
||||
public ImmutableSet<String> getKeyspaces()
|
||||
public Sets.SetView<String> getKeyspaces()
|
||||
{
|
||||
return distributedAndLocalKeyspaces().names();
|
||||
return Sets.union(distributedKeyspaces.names(), localKeyspaces.names());
|
||||
}
|
||||
|
||||
public Keyspaces getLocalKeyspaces()
|
||||
|
|
@ -588,6 +574,7 @@ public class Schema implements SchemaProvider
|
|||
public synchronized void mergeAndUpdateVersion(SchemaTransformationResult result, boolean dropData)
|
||||
{
|
||||
result = localDiff(result);
|
||||
assert result.after.getKeyspaces().stream().noneMatch(ksm -> ksm.params.replication.klass == LocalStrategy.class) : "LocalStrategy should not be used";
|
||||
schemaChangeNotifier.notifyPreChanges(result);
|
||||
merge(result.diff, dropData);
|
||||
updateVersion(result.after.getVersion());
|
||||
|
|
|
|||
|
|
@ -101,9 +101,9 @@ public final class SchemaEvent extends DiagnosticEvent
|
|||
this.viewsDiff = viewsDiff;
|
||||
this.indexesDiff = indexesDiff;
|
||||
|
||||
this.keyspaces = schema.distributedAndLocalKeyspaces().names();
|
||||
this.keyspaces = schema.getKeyspaces().immutableCopy();
|
||||
this.nonSystemKeyspaces = schema.distributedKeyspaces().names();
|
||||
this.userKeyspaces = schema.getUserKeyspaces().names();
|
||||
this.userKeyspaces = schema.getUserKeyspaces().immutableCopy();
|
||||
this.numberOfTables = schema.getNumberOfTables();
|
||||
this.version = schema.getVersion();
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public class PendingRangeCalculatorService
|
|||
private final AtLeastOnceTrigger update = executor.atLeastOnceTrigger(() -> {
|
||||
PendingRangeCalculatorServiceDiagnostics.taskStarted(1);
|
||||
long start = currentTimeMillis();
|
||||
Collection<String> keyspaces = Schema.instance.getNonLocalStrategyKeyspaces().names();
|
||||
Collection<String> keyspaces = Schema.instance.distributedKeyspaces().names();
|
||||
for (String keyspaceName : keyspaces)
|
||||
calculatePendingRanges(Keyspace.open(keyspaceName).getReplicationStrategy(), keyspaceName);
|
||||
if (logger.isTraceEnabled())
|
||||
|
|
|
|||
|
|
@ -1295,7 +1295,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
|
|||
private void executePreJoinTasks(boolean bootstrap)
|
||||
{
|
||||
StreamSupport.stream(ColumnFamilyStore.all().spliterator(), false)
|
||||
.filter(cfs -> Schema.instance.getUserKeyspaces().names().contains(cfs.keyspace.getName()))
|
||||
.filter(cfs -> Schema.instance.getUserKeyspaces().contains(cfs.keyspace.getName()))
|
||||
.forEach(cfs -> cfs.indexManager.executePreJoinTasksBlocking(bootstrap));
|
||||
}
|
||||
|
||||
|
|
@ -1407,7 +1407,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
|
|||
|
||||
if (keyspace == null)
|
||||
{
|
||||
for (String keyspaceName : Schema.instance.getNonLocalStrategyKeyspaces().names())
|
||||
for (String keyspaceName : Schema.instance.distributedKeyspaces().names())
|
||||
streamer.addRanges(keyspaceName, getLocalReplicas(keyspaceName));
|
||||
}
|
||||
else if (tokens == null)
|
||||
|
|
@ -2074,7 +2074,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
|
|||
* All MVs have been created during bootstrap, so mark them as built
|
||||
*/
|
||||
private void markViewsAsBuilt() {
|
||||
for (String keyspace : Schema.instance.getUserKeyspaces().names())
|
||||
for (String keyspace : Schema.instance.getUserKeyspaces())
|
||||
{
|
||||
for (ViewMetadata view: Schema.instance.getKeyspaceMetadata(keyspace).views)
|
||||
SystemKeyspace.finishViewBuildStatus(view.keyspace(), view.name());
|
||||
|
|
@ -2304,7 +2304,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
|
|||
// some people just want to get a visual representation of things. Allow null and set it to the first
|
||||
// non-system keyspace.
|
||||
if (keyspace == null)
|
||||
keyspace = Schema.instance.getNonLocalStrategyKeyspaces().iterator().next().name;
|
||||
keyspace = Schema.instance.distributedKeyspaces().iterator().next().name;
|
||||
|
||||
Map<List<String>, List<String>> map = new HashMap<>();
|
||||
for (Map.Entry<Range<Token>, EndpointsForRange> entry : tokenMetadata.getPendingRangesMM(keyspace).asMap().entrySet())
|
||||
|
|
@ -2358,7 +2358,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
|
|||
// some people just want to get a visual representation of things. Allow null and set it to the first
|
||||
// non-system keyspace.
|
||||
if (keyspace == null)
|
||||
keyspace = Schema.instance.getNonLocalStrategyKeyspaces().iterator().next().name;
|
||||
keyspace = Schema.instance.distributedKeyspaces().iterator().next().name;
|
||||
|
||||
List<Range<Token>> ranges = getAllRanges(sortedTokens);
|
||||
return constructRangeToEndpointMap(keyspace, ranges);
|
||||
|
|
@ -3462,7 +3462,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
|
|||
|
||||
InetAddressAndPort myAddress = FBUtilities.getBroadcastAddressAndPort();
|
||||
|
||||
for (String keyspaceName : Schema.instance.getNonLocalStrategyKeyspaces().names())
|
||||
for (String keyspaceName : Schema.instance.distributedKeyspaces().names())
|
||||
{
|
||||
logger.debug("Restoring replica count for keyspace {}", keyspaceName);
|
||||
EndpointsByReplica changedReplicas = getChangedReplicasForLeaving(keyspaceName, endpoint, tokenMetadata, Keyspace.open(keyspaceName).getReplicationStrategy());
|
||||
|
|
@ -4601,7 +4601,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
|
|||
|
||||
List<Future<?>> futures = new ArrayList<>();
|
||||
|
||||
Keyspaces keyspaces = Schema.instance.getNonLocalStrategyKeyspaces();
|
||||
Keyspaces keyspaces = Schema.instance.distributedKeyspaces();
|
||||
for (String ksName : keyspaces.names())
|
||||
{
|
||||
if (SchemaConstants.REPLICATED_SYSTEM_KEYSPACE_NAMES.contains(ksName))
|
||||
|
|
@ -4952,7 +4952,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
|
|||
if (operationMode != Mode.LEAVING) // If we're already decommissioning there is no point checking RF/pending ranges
|
||||
{
|
||||
int rf, numNodes;
|
||||
for (String keyspaceName : Schema.instance.getNonLocalStrategyKeyspaces().names())
|
||||
for (String keyspaceName : Schema.instance.distributedKeyspaces().names())
|
||||
{
|
||||
if (!force)
|
||||
{
|
||||
|
|
@ -5040,7 +5040,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
|
|||
{
|
||||
Map<String, EndpointsByReplica> rangesToStream = new HashMap<>();
|
||||
|
||||
for (String keyspaceName : Schema.instance.getNonLocalStrategyKeyspaces().names())
|
||||
for (String keyspaceName : Schema.instance.distributedKeyspaces().names())
|
||||
{
|
||||
EndpointsByReplica rangesMM = getChangedReplicasForLeaving(keyspaceName, FBUtilities.getBroadcastAddressAndPort(), tokenMetadata, Keyspace.open(keyspaceName).getReplicationStrategy());
|
||||
|
||||
|
|
@ -5154,7 +5154,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
|
|||
throw new UnsupportedOperationException("This node has more than one token and cannot be moved thusly.");
|
||||
}
|
||||
|
||||
List<String> keyspacesToProcess = ImmutableList.copyOf(Schema.instance.getNonLocalStrategyKeyspaces().names());
|
||||
List<String> keyspacesToProcess = ImmutableList.copyOf(Schema.instance.distributedKeyspaces().names());
|
||||
|
||||
PendingRangeCalculatorService.instance.blockUntilFinished();
|
||||
// checking if data is moving to this node
|
||||
|
|
@ -5301,7 +5301,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
|
|||
Collection<Token> tokens = tokenMetadata.getTokens(endpoint);
|
||||
|
||||
// Find the endpoints that are going to become responsible for data
|
||||
for (String keyspaceName : Schema.instance.getNonLocalStrategyKeyspaces().names())
|
||||
for (String keyspaceName : Schema.instance.distributedKeyspaces().names())
|
||||
{
|
||||
// if the replication factor is 1 the data is lost so we shouldn't wait for confirmation
|
||||
if (Keyspace.open(keyspaceName).getReplicationStrategy().getReplicationFactor().allReplicas == 1)
|
||||
|
|
@ -5485,12 +5485,12 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
|
|||
|
||||
// count CFs first, since forceFlush could block for the flushWriter to get a queue slot empty
|
||||
totalCFs = 0;
|
||||
for (Keyspace keyspace : Keyspace.nonSystem())
|
||||
for (Keyspace keyspace : Keyspace.nonLocalStrategy())
|
||||
totalCFs += keyspace.getColumnFamilyStores().size();
|
||||
remainingCFs = totalCFs;
|
||||
// flush
|
||||
List<Future<?>> flushes = new ArrayList<>();
|
||||
for (Keyspace keyspace : Keyspace.nonSystem())
|
||||
for (Keyspace keyspace : Keyspace.nonLocalStrategy())
|
||||
{
|
||||
for (ColumnFamilyStore cfs : keyspace.getColumnFamilyStores())
|
||||
flushes.add(cfs.forceFlush(ColumnFamilyStore.FlushReason.DRAIN));
|
||||
|
|
@ -5734,9 +5734,9 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
|
|||
}
|
||||
else
|
||||
{
|
||||
Collection<String> userKeyspaces = Schema.instance.getUserKeyspaces().names();
|
||||
Collection<String> userKeyspaces = Schema.instance.getUserKeyspaces();
|
||||
|
||||
if (userKeyspaces.size() > 0)
|
||||
if (!userKeyspaces.isEmpty())
|
||||
{
|
||||
keyspace = userKeyspaces.iterator().next();
|
||||
AbstractReplicationStrategy replicationStrategy = Schema.instance.getKeyspaceInstance(keyspace).getReplicationStrategy();
|
||||
|
|
@ -5805,7 +5805,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
|
|||
|
||||
public List<String> getKeyspaces()
|
||||
{
|
||||
return Lists.newArrayList(Schema.instance.distributedAndLocalKeyspaces().names());
|
||||
return Lists.newArrayList(Schema.instance.getKeyspaces());
|
||||
}
|
||||
|
||||
public List<String> getNonSystemKeyspaces()
|
||||
|
|
@ -5815,7 +5815,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
|
|||
|
||||
public List<String> getNonLocalStrategyKeyspaces()
|
||||
{
|
||||
return Lists.newArrayList(Schema.instance.getNonLocalStrategyKeyspaces().names());
|
||||
return Lists.newArrayList(Schema.instance.distributedKeyspaces().names());
|
||||
}
|
||||
|
||||
public Map<String, String> getViewBuildStatuses(String keyspace, String view, boolean withPort)
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ public class BootStrapperTest
|
|||
public void testSourceTargetComputation() throws UnknownHostException
|
||||
{
|
||||
final int[] clusterSizes = new int[] { 1, 3, 5, 10, 100};
|
||||
for (String keyspaceName : Schema.instance.getNonLocalStrategyKeyspaces().names())
|
||||
for (String keyspaceName : Schema.instance.distributedKeyspaces().names())
|
||||
{
|
||||
int replicationFactor = Keyspace.open(keyspaceName).getReplicationStrategy().getReplicationFactor().allReplicas;
|
||||
for (int clusterSize : clusterSizes)
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ public class SimpleStrategyTest
|
|||
{
|
||||
TokenMetadata tmd;
|
||||
AbstractReplicationStrategy strategy;
|
||||
for (String keyspaceName : Schema.instance.getNonLocalStrategyKeyspaces().names())
|
||||
for (String keyspaceName : Schema.instance.distributedKeyspaces().names())
|
||||
{
|
||||
tmd = new TokenMetadata();
|
||||
strategy = getStrategy(keyspaceName, tmd, new SimpleSnitch());
|
||||
|
|
@ -214,7 +214,7 @@ public class SimpleStrategyTest
|
|||
tmd.addBootstrapToken(bsToken, bootstrapEndpoint);
|
||||
|
||||
AbstractReplicationStrategy strategy = null;
|
||||
for (String keyspaceName : Schema.instance.getNonLocalStrategyKeyspaces().names())
|
||||
for (String keyspaceName : Schema.instance.distributedKeyspaces().names())
|
||||
{
|
||||
strategy = getStrategy(keyspaceName, tmd, new SimpleSnitch());
|
||||
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ public class SchemaKeyspaceTest
|
|||
@Test
|
||||
public void testConversionsInverses() throws Exception
|
||||
{
|
||||
for (String keyspaceName : Schema.instance.getNonSystemKeyspaces().names())
|
||||
for (String keyspaceName : Schema.instance.distributedKeyspaces().names())
|
||||
{
|
||||
for (ColumnFamilyStore cfs : Keyspace.open(keyspaceName).getColumnFamilyStores())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public class SchemaTest
|
|||
@Test
|
||||
public void testTransKsMigration() throws IOException
|
||||
{
|
||||
assertEquals(0, Schema.instance.getNonSystemKeyspaces().size());
|
||||
assertEquals(0, Schema.instance.distributedKeyspaces().size());
|
||||
|
||||
Gossiper.instance.start((int) (System.currentTimeMillis() / 1000));
|
||||
try
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import org.junit.Test;
|
|||
import org.apache.cassandra.SchemaLoader;
|
||||
import org.apache.cassandra.Util;
|
||||
import org.apache.cassandra.Util.PartitionerSwitcher;
|
||||
import org.apache.cassandra.config.CassandraRelevantProperties;
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.apache.cassandra.locator.InetAddressAndPort;
|
||||
import org.apache.cassandra.schema.Schema;
|
||||
|
|
@ -62,6 +63,7 @@ public class LeaveAndBootstrapTest
|
|||
@BeforeClass
|
||||
public static void defineSchema() throws Exception
|
||||
{
|
||||
CassandraRelevantProperties.GOSSIPER_QUARANTINE_DELAY.setLong(10000);
|
||||
DatabaseDescriptor.daemonInitialization();
|
||||
partitionerSwitcher = Util.switchPartitioner(partitioner);
|
||||
SchemaLoader.loadSchema();
|
||||
|
|
@ -123,7 +125,7 @@ public class LeaveAndBootstrapTest
|
|||
PendingRangeCalculatorService.instance.blockUntilFinished();
|
||||
|
||||
AbstractReplicationStrategy strategy;
|
||||
for (String keyspaceName : Schema.instance.getNonLocalStrategyKeyspaces().names())
|
||||
for (String keyspaceName : Schema.instance.distributedKeyspaces().names())
|
||||
{
|
||||
strategy = getStrategy(keyspaceName, tmd);
|
||||
for (Token token : keyTokens)
|
||||
|
|
|
|||
|
|
@ -557,7 +557,7 @@ public class MoveTest
|
|||
private void assertPendingRanges(TokenMetadata tmd, Map<Range<Token>, EndpointsForRange> pendingRanges, String keyspaceName) throws ConfigurationException
|
||||
{
|
||||
boolean keyspaceFound = false;
|
||||
for (String nonSystemKeyspaceName : Schema.instance.getNonLocalStrategyKeyspaces().names())
|
||||
for (String nonSystemKeyspaceName : Schema.instance.distributedKeyspaces().names())
|
||||
{
|
||||
if(!keyspaceName.equals(nonSystemKeyspaceName))
|
||||
continue;
|
||||
|
|
@ -626,7 +626,7 @@ public class MoveTest
|
|||
assertTrue(tmd.isMoving(hosts.get(MOVING_NODE)));
|
||||
|
||||
AbstractReplicationStrategy strategy;
|
||||
for (String keyspaceName : Schema.instance.getNonLocalStrategyKeyspaces().names())
|
||||
for (String keyspaceName : Schema.instance.distributedKeyspaces().names())
|
||||
{
|
||||
strategy = getStrategy(keyspaceName, tmd);
|
||||
if(strategy instanceof NetworkTopologyStrategy)
|
||||
|
|
|
|||
Loading…
Reference in New Issue