You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jm...@apache.org on 2014/12/15 18:35:59 UTC

[2/3] cassandra git commit: Merge branch 'cassandra-2.1' into trunk

Merge branch 'cassandra-2.1' into trunk

Conflicts:
	src/java/org/apache/cassandra/service/StorageService.java
	src/java/org/apache/cassandra/utils/FBUtilities.java


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/3a0dc2c0
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/3a0dc2c0
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/3a0dc2c0

Branch: refs/heads/trunk
Commit: 3a0dc2c0f7bbbbbb7c4976b8b99903149f3202e9
Parents: 9acf97a 6d8862b
Author: Joshua McKenzie <jm...@apache.org>
Authored: Mon Dec 15 11:31:48 2014 -0600
Committer: Joshua McKenzie <jm...@apache.org>
Committed: Mon Dec 15 11:31:48 2014 -0600

----------------------------------------------------------------------
 .../apache/cassandra/io/sstable/SSTableRewriter.java |  2 +-
 .../io/sstable/metadata/MetadataSerializer.java      |  2 +-
 .../apache/cassandra/service/CassandraDaemon.java    |  2 +-
 .../org/apache/cassandra/service/StorageService.java |  3 +--
 .../cassandra/utils/BackgroundActivityMonitor.java   |  4 ++--
 src/java/org/apache/cassandra/utils/FBUtilities.java | 15 +++++++++++----
 6 files changed, 17 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a0dc2c0/src/java/org/apache/cassandra/io/sstable/SSTableRewriter.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a0dc2c0/src/java/org/apache/cassandra/service/CassandraDaemon.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a0dc2c0/src/java/org/apache/cassandra/service/StorageService.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/service/StorageService.java
index 4ec23a6,36fe377..f646d87
--- a/src/java/org/apache/cassandra/service/StorageService.java
+++ b/src/java/org/apache/cassandra/service/StorageService.java
@@@ -2429,114 -2494,83 +2429,113 @@@ public class StorageService extends Not
          sendNotification(jmxNotification);
      }
  
 -    public int forceRepairAsync(String keyspace, boolean isSequential, Collection<String> dataCenters, Collection<String> hosts, boolean primaryRange, boolean fullRepair, String... columnFamilies) throws IOException
 -    {
 -        return forceRepairAsync(keyspace, isSequential ? RepairParallelism.SEQUENTIAL : RepairParallelism.PARALLEL, dataCenters, hosts, primaryRange, fullRepair, columnFamilies);
 -    }
 -
 -    public int forceRepairAsync(String keyspace, RepairParallelism parallelismDegree, Collection<String> dataCenters, Collection<String> hosts, boolean primaryRange, boolean fullRepair, String... columnFamilies)
 +    public int repairAsync(String keyspace, Map<String, String> repairSpec)
      {
 -        Collection<Range<Token>> ranges;
 -        if (primaryRange)
 +        RepairOption option = RepairOption.parse(repairSpec, getPartitioner());
 +        // if ranges are not specified
 +        if (option.getRanges().isEmpty())
          {
 -            // when repairing only primary range, neither dataCenters nor hosts can be set
 -            if (dataCenters == null && hosts == null)
 -                ranges = getPrimaryRanges(keyspace);
 -            // except dataCenters only contain local DC (i.e. -local)
 -            else if (dataCenters != null && dataCenters.size() == 1 && dataCenters.contains(DatabaseDescriptor.getLocalDataCenter()))
 -                ranges = getPrimaryRangesWithinDC(keyspace);
 +            if (option.isPrimaryRange())
 +            {
 +                // when repairing only primary range, neither dataCenters nor hosts can be set
 +                if (option.getDataCenters().isEmpty() && option.getHosts().isEmpty())
 +                    option.getRanges().addAll(getPrimaryRanges(keyspace));
 +                    // except dataCenters only contain local DC (i.e. -local)
 +                else if (option.getDataCenters().size() == 1 && option.getDataCenters().contains(DatabaseDescriptor.getLocalDataCenter()))
 +                    option.getRanges().addAll(getPrimaryRangesWithinDC(keyspace));
 +                else
 +                    throw new IllegalArgumentException("You need to run primary range repair on all nodes in the cluster.");
 +            }
              else
 -                throw new IllegalArgumentException("You need to run primary range repair on all nodes in the cluster.");
 -        }
 -        else
 -        {
 -             ranges = getLocalRanges(keyspace);
 +            {
 +                option.getRanges().addAll(getLocalRanges(keyspace));
 +            }
          }
 -
 -        return forceRepairAsync(keyspace, parallelismDegree, dataCenters, hosts, ranges, fullRepair, columnFamilies);
 +        return forceRepairAsync(keyspace, option);
      }
  
 -    public int forceRepairAsync(String keyspace, boolean isSequential, Collection<String> dataCenters, Collection<String> hosts, Collection<Range<Token>> ranges, boolean fullRepair, String... columnFamilies)
 +    @Deprecated
 +    public int forceRepairAsync(String keyspace,
 +                                boolean isSequential,
 +                                Collection<String> dataCenters,
 +                                Collection<String> hosts,
 +                                boolean primaryRange,
 +                                boolean fullRepair,
 +                                String... columnFamilies)
      {
 -        return forceRepairAsync(keyspace, isSequential ? RepairParallelism.SEQUENTIAL : RepairParallelism.PARALLEL, dataCenters, hosts, ranges, fullRepair, columnFamilies);
 +        return forceRepairAsync(keyspace, isSequential ? RepairParallelism.SEQUENTIAL : RepairParallelism.PARALLEL, dataCenters, hosts, primaryRange, fullRepair, columnFamilies);
      }
  
 -    public int forceRepairAsync(String keyspace, RepairParallelism parallelismDegree, Collection<String> dataCenters, Collection<String> hosts, Collection<Range<Token>> ranges, boolean fullRepair, String... columnFamilies)
 +    @Deprecated
 +    public int forceRepairAsync(String keyspace,
 +                                RepairParallelism parallelismDegree,
 +                                Collection<String> dataCenters,
 +                                Collection<String> hosts,
 +                                boolean primaryRange,
 +                                boolean fullRepair,
 +                                String... columnFamilies)
      {
-         if (!FBUtilities.isUnix() && parallelismDegree != RepairParallelism.PARALLEL)
 -        if (ranges.isEmpty() || Keyspace.open(keyspace).getReplicationStrategy().getReplicationFactor() < 2)
 -            return 0;
++        if (FBUtilities.isWindows() && parallelismDegree != RepairParallelism.PARALLEL)
 +        {
 +            logger.warn("Snapshot-based repair is not yet supported on Windows.  Reverting to parallel repair.");
 +            parallelismDegree = RepairParallelism.PARALLEL;
 +        }
  
 -        int cmd = nextRepairCommand.incrementAndGet();
 -        if (ranges.size() > 0)
 +        RepairOption options = new RepairOption(parallelismDegree, primaryRange, !fullRepair, false, 1, Collections.<Range<Token>>emptyList());
 +        if (dataCenters != null)
          {
 -            if (FBUtilities.isWindows() && parallelismDegree != RepairParallelism.PARALLEL)
 +            options.getDataCenters().addAll(dataCenters);
 +        }
 +        if (hosts != null)
 +        {
 +            options.getHosts().addAll(hosts);
 +        }
 +        if (columnFamilies != null)
 +        {
 +            for (String columnFamily : columnFamilies)
              {
 -                logger.warn("Snapshot-based repair is not yet supported on Windows.  Reverting to parallel repair.");
 -                parallelismDegree = RepairParallelism.PARALLEL;
 +                options.getColumnFamilies().add(columnFamily);
              }
 -            new Thread(createRepairTask(cmd, keyspace, ranges, parallelismDegree, dataCenters, hosts, fullRepair, columnFamilies)).start();
          }
 -        return cmd;
 +        return forceRepairAsync(keyspace, options);
      }
  
 -    public int forceRepairAsync(String keyspace, boolean isSequential, boolean isLocal, boolean primaryRange, boolean fullRepair, String... columnFamilies)
 +    public int forceRepairAsync(String keyspace,
 +                                boolean isSequential,
 +                                boolean isLocal,
 +                                boolean primaryRange,
 +                                boolean fullRepair,
 +                                String... columnFamilies)
      {
 -        Collection<Range<Token>> ranges;
 -        if (primaryRange)
 -        {
 -            ranges = isLocal ? getPrimaryRangesWithinDC(keyspace) : getPrimaryRanges(keyspace);
 -        }
 -        else
 +        Set<String> dataCenters = null;
 +        if (isLocal)
          {
 -            ranges = getLocalRanges(keyspace);
 +            dataCenters = Sets.newHashSet(DatabaseDescriptor.getLocalDataCenter());
          }
 -
 -        return forceRepairAsync(keyspace, isSequential, isLocal, ranges, fullRepair, columnFamilies);
 +        return forceRepairAsync(keyspace, isSequential, dataCenters, null, primaryRange, fullRepair, columnFamilies);
      }
  
 -    public int forceRepairAsync(String keyspace, boolean isSequential, boolean isLocal, Collection<Range<Token>> ranges, boolean fullRepair, String... columnFamilies)
 +    public int forceRepairRangeAsync(String beginToken,
 +                                     String endToken,
 +                                     String keyspaceName,
 +                                     boolean isSequential,
 +                                     Collection<String> dataCenters,
 +                                     Collection<String> hosts,
 +                                     boolean fullRepair,
 +                                     String... columnFamilies)
      {
 -        return forceRepairAsync(keyspace, isSequential ? RepairParallelism.SEQUENTIAL : RepairParallelism.PARALLEL, isLocal, ranges, fullRepair, columnFamilies);
 +        return forceRepairRangeAsync(beginToken, endToken, keyspaceName, isSequential ? RepairParallelism.SEQUENTIAL : RepairParallelism.PARALLEL, dataCenters, hosts, fullRepair, columnFamilies);
      }
  
 -    public int forceRepairAsync(String keyspace, RepairParallelism parallelismDegree, boolean isLocal, Collection<Range<Token>> ranges, boolean fullRepair, String... columnFamilies)
 +    public int forceRepairRangeAsync(String beginToken,
 +                                     String endToken,
 +                                     String keyspaceName,
 +                                     RepairParallelism parallelismDegree,
 +                                     Collection<String> dataCenters,
 +                                     Collection<String> hosts,
 +                                     boolean fullRepair,
 +                                     String... columnFamilies)
      {
-         if (!FBUtilities.isUnix() && parallelismDegree != RepairParallelism.PARALLEL)
 -        if (ranges.isEmpty() || Keyspace.open(keyspace).getReplicationStrategy().getReplicationFactor() < 2)
 -            return 0;
 -
 -        int cmd = nextRepairCommand.incrementAndGet();
 -        if (FBUtilities.isWindows() && parallelismDegree != RepairParallelism.PARALLEL)
          {
              logger.warn("Snapshot-based repair is not yet supported on Windows.  Reverting to parallel repair.");
              parallelismDegree = RepairParallelism.PARALLEL;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a0dc2c0/src/java/org/apache/cassandra/utils/FBUtilities.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/utils/FBUtilities.java
index acd19ad,4c81b2a..c41a6c0
--- a/src/java/org/apache/cassandra/utils/FBUtilities.java
+++ b/src/java/org/apache/cassandra/utils/FBUtilities.java
@@@ -70,6 -70,12 +70,10 @@@ public class FBUtilitie
      public static final BigInteger TWO = new BigInteger("2");
      private static final String DEFAULT_TRIGGER_DIR = "triggers";
  
 -    private static final String OPERATING_SYSTEM = System.getProperty("os.name").toLowerCase();
 -
+     private static final boolean IS_WINDOWS = OPERATING_SYSTEM.contains("windows");
+ 
+     private static final boolean HAS_PROCFS = !IS_WINDOWS && (new File(File.separator + "proc")).exists();
+ 
      private static volatile InetAddress localInetAddress;
      private static volatile InetAddress broadcastInetAddress;