Search in sources :

Example 1 with RepairOption

use of org.apache.cassandra.repair.messages.RepairOption in project cassandra by apache.

the class OnInstanceRepair method invokeRepair.

private static void invokeRepair(String keyspaceName, boolean repairPaxos, boolean repairOnlyPaxos, IIsolatedExecutor.SerializableCallable<Collection<Range<Token>>> rangesSupplier, boolean isPrimaryRangeOnly, boolean force, Runnable listener) {
    Collection<Range<Token>> ranges = rangesSupplier.call();
    // no need to wait for completion, as we track all task submissions and message exchanges, and ensure they finish before continuing to next action
    StorageService.instance.repair(keyspaceName, new RepairOption(RepairParallelism.SEQUENTIAL, isPrimaryRangeOnly, false, false, 1, ranges, false, false, force, PreviewKind.NONE, true, true), singletonList((tag, event) -> {
        if (event.getType() == ProgressEventType.COMPLETE)
            listener.run();
    }));
}
Also used : RepairOption(org.apache.cassandra.repair.messages.RepairOption) RepairOption(org.apache.cassandra.repair.messages.RepairOption) Utils.parseTokenRanges(org.apache.cassandra.simulator.cluster.Utils.parseTokenRanges) Utils.currentToken(org.apache.cassandra.simulator.cluster.Utils.currentToken) Collection(java.util.Collection) Range(org.apache.cassandra.dht.Range) StorageService(org.apache.cassandra.service.StorageService) Condition(org.apache.cassandra.utils.concurrent.Condition) RepairParallelism(org.apache.cassandra.repair.RepairParallelism) Replica(org.apache.cassandra.locator.Replica) Collections.singletonList(java.util.Collections.singletonList) PreviewKind(org.apache.cassandra.streaming.PreviewKind) Token(org.apache.cassandra.dht.Token) RELIABLE_NO_TIMEOUTS(org.apache.cassandra.simulator.Action.Modifiers.RELIABLE_NO_TIMEOUTS) TokenMetadata(org.apache.cassandra.locator.TokenMetadata) FBUtilities.getBroadcastAddressAndPort(org.apache.cassandra.utils.FBUtilities.getBroadcastAddressAndPort) Map(java.util.Map) IIsolatedExecutor(org.apache.cassandra.distributed.api.IIsolatedExecutor) Condition.newOneTimeCondition(org.apache.cassandra.utils.concurrent.Condition.newOneTimeCondition) Collections(java.util.Collections) ProgressEventType(org.apache.cassandra.utils.progress.ProgressEventType) Keyspace(org.apache.cassandra.db.Keyspace) Range(org.apache.cassandra.dht.Range)

Example 2 with RepairOption

use of org.apache.cassandra.repair.messages.RepairOption in project cassandra by apache.

the class StorageService method forceRepairAsync.

@Deprecated
public int forceRepairAsync(String keyspace, int parallelismDegree, Collection<String> dataCenters, Collection<String> hosts, boolean primaryRange, boolean fullRepair, String... tableNames) {
    if (parallelismDegree < 0 || parallelismDegree > RepairParallelism.values().length - 1) {
        throw new IllegalArgumentException("Invalid parallelism degree specified: " + parallelismDegree);
    }
    RepairParallelism parallelism = RepairParallelism.values()[parallelismDegree];
    if (FBUtilities.isWindows && parallelism != RepairParallelism.PARALLEL) {
        logger.warn("Snapshot-based repair is not yet supported on Windows.  Reverting to parallel repair.");
        parallelism = RepairParallelism.PARALLEL;
    }
    RepairOption options = new RepairOption(parallelism, primaryRange, !fullRepair, false, 1, Collections.<Range<Token>>emptyList(), false, false);
    if (dataCenters != null) {
        options.getDataCenters().addAll(dataCenters);
    }
    if (hosts != null) {
        options.getHosts().addAll(hosts);
    }
    if (primaryRange) {
        // when repairing only primary range, neither dataCenters nor hosts can be set
        if (options.getDataCenters().isEmpty() && options.getHosts().isEmpty())
            options.getRanges().addAll(getPrimaryRanges(keyspace));
        else // except dataCenters only contain local DC (i.e. -local)
        if (options.getDataCenters().size() == 1 && options.getDataCenters().contains(DatabaseDescriptor.getLocalDataCenter()))
            options.getRanges().addAll(getPrimaryRangesWithinDC(keyspace));
        else
            throw new IllegalArgumentException("You need to run primary range repair on all nodes in the cluster.");
    } else {
        options.getRanges().addAll(getLocalRanges(keyspace));
    }
    if (tableNames != null) {
        for (String table : tableNames) {
            options.getColumnFamilies().add(table);
        }
    }
    return forceRepairAsync(keyspace, options, true);
}
Also used : RepairOption(org.apache.cassandra.repair.messages.RepairOption)

Example 3 with RepairOption

use of org.apache.cassandra.repair.messages.RepairOption in project cassandra by apache.

the class StorageService method forceRepairRangeAsync.

@Deprecated
public int forceRepairRangeAsync(String beginToken, String endToken, String keyspaceName, int parallelismDegree, Collection<String> dataCenters, Collection<String> hosts, boolean fullRepair, String... tableNames) {
    if (parallelismDegree < 0 || parallelismDegree > RepairParallelism.values().length - 1) {
        throw new IllegalArgumentException("Invalid parallelism degree specified: " + parallelismDegree);
    }
    RepairParallelism parallelism = RepairParallelism.values()[parallelismDegree];
    if (FBUtilities.isWindows && parallelism != RepairParallelism.PARALLEL) {
        logger.warn("Snapshot-based repair is not yet supported on Windows.  Reverting to parallel repair.");
        parallelism = RepairParallelism.PARALLEL;
    }
    if (!fullRepair)
        logger.warn("Incremental repair can't be requested with subrange repair " + "because each subrange repair would generate an anti-compacted table. " + "The repair will occur but without anti-compaction.");
    Collection<Range<Token>> repairingRange = createRepairRangeFrom(beginToken, endToken);
    RepairOption options = new RepairOption(parallelism, false, !fullRepair, false, 1, repairingRange, true, false);
    if (dataCenters != null) {
        options.getDataCenters().addAll(dataCenters);
    }
    if (hosts != null) {
        options.getHosts().addAll(hosts);
    }
    if (tableNames != null) {
        for (String table : tableNames) {
            options.getColumnFamilies().add(table);
        }
    }
    logger.info("starting user-requested repair of range {} for keyspace {} and column families {}", repairingRange, keyspaceName, tableNames);
    return forceRepairAsync(keyspaceName, options, true);
}
Also used : RepairOption(org.apache.cassandra.repair.messages.RepairOption) Range(org.apache.cassandra.dht.Range)

Aggregations

RepairOption (org.apache.cassandra.repair.messages.RepairOption)3 Range (org.apache.cassandra.dht.Range)2 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Collections.singletonList (java.util.Collections.singletonList)1 Map (java.util.Map)1 Keyspace (org.apache.cassandra.db.Keyspace)1 Token (org.apache.cassandra.dht.Token)1 IIsolatedExecutor (org.apache.cassandra.distributed.api.IIsolatedExecutor)1 Replica (org.apache.cassandra.locator.Replica)1 TokenMetadata (org.apache.cassandra.locator.TokenMetadata)1 RepairParallelism (org.apache.cassandra.repair.RepairParallelism)1 StorageService (org.apache.cassandra.service.StorageService)1 RELIABLE_NO_TIMEOUTS (org.apache.cassandra.simulator.Action.Modifiers.RELIABLE_NO_TIMEOUTS)1 Utils.currentToken (org.apache.cassandra.simulator.cluster.Utils.currentToken)1 Utils.parseTokenRanges (org.apache.cassandra.simulator.cluster.Utils.parseTokenRanges)1 PreviewKind (org.apache.cassandra.streaming.PreviewKind)1 FBUtilities.getBroadcastAddressAndPort (org.apache.cassandra.utils.FBUtilities.getBroadcastAddressAndPort)1 Condition (org.apache.cassandra.utils.concurrent.Condition)1 Condition.newOneTimeCondition (org.apache.cassandra.utils.concurrent.Condition.newOneTimeCondition)1