List of usage examples for org.apache.cassandra.repair RepairParallelism SEQUENTIAL
RepairParallelism SEQUENTIAL
To view the source code for org.apache.cassandra.repair RepairParallelism SEQUENTIAL.
Click Source Link
From source file:com.mesosphere.dcos.cassandra.executor.tasks.Repair.java
License:Apache License
private void repairKeyspace(String keyspace, List<String> columnFamilies) throws Exception { LOGGER.info("Starting repair : keySpace = {}, columnFamilies = {}", keyspace, columnFamilies); Map<String, String> options = new HashMap<>(); options.put(RepairOption.PRIMARY_RANGE_KEY, "true"); options.put(RepairOption.COLUMNFAMILIES_KEY, String.join(",", columnFamilies)); options.put(RepairOption.PARALLELISM_KEY, RepairParallelism.SEQUENTIAL.getName()); options.put(RepairOption.INCREMENTAL_KEY, "true"); String result = daemon.repair(keyspace, options); LOGGER.info("Repair output = {}", result); LOGGER.info("Completed repair : keySpace = {}, columnFamilies = {}", keyspace, columnFamilies); sendStatus(driver, Protos.TaskState.TASK_RUNNING, String.format("Completed repair : keySpace = %s, columnFamilies = %s", keyspace, columnFamilies)); }
From source file:com.spotify.reaper.cassandra.JmxProxy.java
License:Apache License
/** * Triggers a repair of range (beginToken, endToken] for given keyspace and column family. * The repair is triggered by {@link org.apache.cassandra.service.StorageServiceMBean#forceRepairRangeAsync} * For time being, we don't allow local nor snapshot repairs. * * @return Repair command number, or 0 if nothing to repair *//*from w w w . j a v a 2s . c o m*/ public int triggerRepair(BigInteger beginToken, BigInteger endToken, String keyspace, RepairParallelism repairParallelism, Collection<String> columnFamilies) { checkNotNull(ssProxy, "Looks like the proxy is not connected"); String cassandraVersion = ssProxy.getReleaseVersion(); boolean canUseDatacenterAware = false; try { canUseDatacenterAware = versionCompare(cassandraVersion, "2.0.12") >= 0; } catch (ReaperException e) { LOG.warn("failed on version comparison, not using dc aware repairs by default"); } String msg = String.format( "Triggering repair of range (%s,%s] for keyspace \"%s\" on " + "host %s, with repair parallelism %s, in cluster with Cassandra " + "version '%s' (can use DATACENTER_AWARE '%s'), " + "for column families: %s", beginToken.toString(), endToken.toString(), keyspace, this.host, repairParallelism, cassandraVersion, canUseDatacenterAware, columnFamilies); LOG.info(msg); if (repairParallelism.equals(RepairParallelism.DATACENTER_AWARE)) { if (canUseDatacenterAware) { return ssProxy.forceRepairRangeAsync(beginToken.toString(), endToken.toString(), keyspace, repairParallelism.ordinal(), null, null, columnFamilies.toArray(new String[columnFamilies.size()])); } else { LOG.info("Cannot use DATACENTER_AWARE repair policy for Cassandra cluster with version {}," + " falling back to SEQUENTIAL repair.", cassandraVersion); repairParallelism = RepairParallelism.SEQUENTIAL; } } boolean snapshotRepair = repairParallelism.equals(RepairParallelism.SEQUENTIAL); return ssProxy.forceRepairRangeAsync(beginToken.toString(), endToken.toString(), keyspace, snapshotRepair, false, columnFamilies.toArray(new String[columnFamilies.size()])); }
From source file:io.cassandrareaper.jmx.JmxProxyImpl.java
License:Apache License
@Override public int triggerRepair(BigInteger beginToken, BigInteger endToken, String keyspace, RepairParallelism repairParallelism, Collection<String> columnFamilies, boolean fullRepair, Collection<String> datacenters, RepairStatusHandler repairStatusHandler, List<RingRange> associatedTokens, int repairThreadCount) throws ReaperException { checkNotNull(ssProxy, "Looks like the proxy is not connected"); String cassandraVersion = getCassandraVersion(); boolean canUseDatacenterAware = false; canUseDatacenterAware = versionCompare(cassandraVersion, "2.0.12") >= 0; String msg = String.format( "Triggering repair of range (%s,%s] for keyspace \"%s\" on " + "host %s, with repair parallelism %s, in cluster with Cassandra " + "version '%s' (can use DATACENTER_AWARE '%s'), " + "for column families: %s", beginToken.toString(), endToken.toString(), keyspace, this.host, repairParallelism, cassandraVersion, canUseDatacenterAware, columnFamilies); LOG.info(msg);//from w w w . ja va 2 s .com if (repairParallelism.equals(RepairParallelism.DATACENTER_AWARE) && !canUseDatacenterAware) { LOG.info("Cannot use DATACENTER_AWARE repair policy for Cassandra cluster with version {}," + " falling back to SEQUENTIAL repair.", cassandraVersion); repairParallelism = RepairParallelism.SEQUENTIAL; } try { if (cassandraVersion.startsWith("2.0") || cassandraVersion.startsWith("1.")) { return triggerRepairPre2dot1(repairParallelism, keyspace, columnFamilies, beginToken, endToken, datacenters.size() > 0 ? datacenters : null, repairStatusHandler); } else if (cassandraVersion.startsWith("2.1")) { return triggerRepair2dot1(fullRepair, repairParallelism, keyspace, columnFamilies, beginToken, endToken, cassandraVersion, datacenters.size() > 0 ? datacenters : null, repairStatusHandler); } else { return triggerRepairPost2dot2(fullRepair, repairParallelism, keyspace, columnFamilies, beginToken, endToken, cassandraVersion, datacenters, repairStatusHandler, associatedTokens, repairThreadCount); } } catch (RuntimeException e) { LOG.error("Segment repair failed", e); throw new ReaperException(e); } }
From source file:io.cassandrareaper.jmx.JmxProxyImpl.java
License:Apache License
private int triggerRepair2dot1(boolean fullRepair, RepairParallelism repairParallelism, String keyspace, Collection<String> columnFamilies, BigInteger beginToken, BigInteger endToken, String cassandraVersion, Collection<String> datacenters, RepairStatusHandler repairStatusHandler) { if (fullRepair) { // full repair if (repairParallelism.equals(RepairParallelism.DATACENTER_AWARE)) { int commandId = ((StorageServiceMBean) ssProxy).forceRepairRangeAsync(beginToken.toString(), endToken.toString(), keyspace, repairParallelism.ordinal(), datacenters, cassandraVersion.startsWith("2.2") ? new HashSet<String>() : null, fullRepair, columnFamilies.toArray(new String[columnFamilies.size()])); repairStatusHandlers.putIfAbsent(commandId, repairStatusHandler); return commandId; }//w w w.jav a 2 s .c o m boolean snapshotRepair = repairParallelism.equals(RepairParallelism.SEQUENTIAL); int commandId = ((StorageServiceMBean) ssProxy).forceRepairRangeAsync(beginToken.toString(), endToken.toString(), keyspace, snapshotRepair ? RepairParallelism.SEQUENTIAL.ordinal() : RepairParallelism.PARALLEL.ordinal(), datacenters, cassandraVersion.startsWith("2.2") ? new HashSet<String>() : null, fullRepair, columnFamilies.toArray(new String[columnFamilies.size()])); repairStatusHandlers.putIfAbsent(commandId, repairStatusHandler); return commandId; } // incremental repair int commandId = ((StorageServiceMBean) ssProxy).forceRepairAsync(keyspace, Boolean.FALSE, Boolean.FALSE, Boolean.FALSE, fullRepair, columnFamilies.toArray(new String[columnFamilies.size()])); repairStatusHandlers.putIfAbsent(commandId, repairStatusHandler); return commandId; }
From source file:io.cassandrareaper.jmx.JmxProxyImpl.java
License:Apache License
private int triggerRepairPre2dot1(RepairParallelism repairParallelism, String keyspace, Collection<String> columnFamilies, BigInteger beginToken, BigInteger endToken, Collection<String> datacenters, RepairStatusHandler repairStatusHandler) { // Cassandra 1.2 and 2.0 compatibility if (repairParallelism.equals(RepairParallelism.DATACENTER_AWARE)) { int commandId = ((StorageServiceMBean20) ssProxy).forceRepairRangeAsync(beginToken.toString(), endToken.toString(), keyspace, repairParallelism.ordinal(), datacenters, null, columnFamilies.toArray(new String[columnFamilies.size()])); repairStatusHandlers.putIfAbsent(commandId, repairStatusHandler); return commandId; }//from w w w . jav a2s. c om boolean snapshotRepair = repairParallelism.equals(RepairParallelism.SEQUENTIAL); int commandId = ((StorageServiceMBean20) ssProxy).forceRepairRangeAsync(beginToken.toString(), endToken.toString(), keyspace, snapshotRepair, false, columnFamilies.toArray(new String[columnFamilies.size()])); repairStatusHandlers.putIfAbsent(commandId, repairStatusHandler); return commandId; }