You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jb...@apache.org on 2013/12/06 16:52:27 UTC

[10/16] Merge branch 'cassandra-1.2' into cassandra-2.0

http://git-wip-us.apache.org/repos/asf/cassandra/blob/f2a82ee7/interface/thrift/gen-java/org/apache/cassandra/thrift/cassandraConstants.java
----------------------------------------------------------------------
diff --cc interface/thrift/gen-java/org/apache/cassandra/thrift/cassandraConstants.java
index a2c482e,0000000..81b0ffb
mode 100644,000000..100644
--- a/interface/thrift/gen-java/org/apache/cassandra/thrift/cassandraConstants.java
+++ b/interface/thrift/gen-java/org/apache/cassandra/thrift/cassandraConstants.java
@@@ -1,61 -1,0 +1,61 @@@
 +/**
 + * Autogenerated by Thrift Compiler (0.9.1)
 + *
 + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 + *  @generated
 + */
 +package org.apache.cassandra.thrift;
 +/*
 + * 
 + * Licensed to the Apache Software Foundation (ASF) under one
 + * or more contributor license agreements.  See the NOTICE file
 + * distributed with this work for additional information
 + * regarding copyright ownership.  The ASF licenses this file
 + * to you under the Apache License, Version 2.0 (the
 + * "License"); you may not use this file except in compliance
 + * with the License.  You may obtain a copy of the License at
 + * 
 + *   http://www.apache.org/licenses/LICENSE-2.0
 + * 
 + * Unless required by applicable law or agreed to in writing,
 + * software distributed under the License is distributed on an
 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 + * KIND, either express or implied.  See the License for the
 + * specific language governing permissions and limitations
 + * under the License.
 + * 
 + */
 +
 +
 +import org.apache.commons.lang3.builder.HashCodeBuilder;
 +import org.apache.thrift.scheme.IScheme;
 +import org.apache.thrift.scheme.SchemeFactory;
 +import org.apache.thrift.scheme.StandardScheme;
 +
 +import org.apache.thrift.scheme.TupleScheme;
 +import org.apache.thrift.protocol.TTupleProtocol;
 +import org.apache.thrift.protocol.TProtocolException;
 +import org.apache.thrift.EncodingUtils;
 +import org.apache.thrift.TException;
 +import org.apache.thrift.async.AsyncMethodCallback;
 +import org.apache.thrift.server.AbstractNonblockingServer.*;
 +import java.util.List;
 +import java.util.ArrayList;
 +import java.util.Map;
 +import java.util.HashMap;
 +import java.util.EnumMap;
 +import java.util.Set;
 +import java.util.HashSet;
 +import java.util.EnumSet;
 +import java.util.Collections;
 +import java.util.BitSet;
 +import java.nio.ByteBuffer;
 +import java.util.Arrays;
 +import org.slf4j.Logger;
 +import org.slf4j.LoggerFactory;
 +
 +public class cassandraConstants {
 +
-   public static final String VERSION = "19.38.0";
++  public static final String VERSION = "19.39.0";
 +
 +}

http://git-wip-us.apache.org/repos/asf/cassandra/blob/f2a82ee7/src/java/org/apache/cassandra/hadoop/AbstractColumnFamilyInputFormat.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/f2a82ee7/src/java/org/apache/cassandra/service/StorageService.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/service/StorageService.java
index 18ce97b,b85f478..c341684
--- a/src/java/org/apache/cassandra/service/StorageService.java
+++ b/src/java/org/apache/cassandra/service/StorageService.java
@@@ -34,17 -34,13 +34,18 @@@ import javax.management.Notification
  import javax.management.NotificationBroadcasterSupport;
  import javax.management.ObjectName;
  
 +import static java.nio.charset.StandardCharsets.ISO_8859_1;
 +
 +import com.google.common.annotations.VisibleForTesting;
+ import com.google.common.base.Predicate;
  import com.google.common.collect.*;
 -
  import com.google.common.util.concurrent.AtomicDouble;
 -import org.apache.cassandra.db.index.SecondaryIndex;
 +import com.google.common.util.concurrent.FutureCallback;
 +import com.google.common.util.concurrent.Futures;
 +import com.google.common.util.concurrent.Uninterruptibles;
 +
 +import org.apache.commons.lang3.StringUtils;
  import org.apache.log4j.Level;
 -import org.apache.commons.lang.StringUtils;
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  
@@@ -1063,12 -1081,57 +1064,57 @@@ public class StorageService extends Not
  
      public Map<Range<Token>, List<InetAddress>> getRangeToAddressMap(String keyspace)
      {
+         return getRangeToAddressMap(keyspace, tokenMetadata.sortedTokens());
+     }
+ 
+     public Map<Range<Token>, List<InetAddress>> getRangeToAddressMapInLocalDC(String keyspace)
+     {
+         Predicate<InetAddress> isLocalDC = new Predicate<InetAddress>()
+         {
+             public boolean apply(InetAddress address)
+             {
+                 return isLocalDC(address);
+             }
+         };
+ 
+         Map<Range<Token>, List<InetAddress>> origMap = getRangeToAddressMap(keyspace, getTokensInLocalDC());
+         Map<Range<Token>, List<InetAddress>> filteredMap = Maps.newHashMap();
+         for (Map.Entry<Range<Token>, List<InetAddress>> entry : origMap.entrySet())
+         {
+             List<InetAddress> endpointsInLocalDC = Lists.newArrayList(Collections2.filter(entry.getValue(), isLocalDC));
+             filteredMap.put(entry.getKey(), endpointsInLocalDC);
+         }
+ 
+         return filteredMap;
+     }
+ 
+     private List<Token> getTokensInLocalDC()
+     {
+         List<Token> filteredTokens = Lists.newArrayList();
+         for (Token token : tokenMetadata.sortedTokens())
+         {
+             InetAddress endpoint = tokenMetadata.getEndpoint(token);
+             if (isLocalDC(endpoint))
+                 filteredTokens.add(token);
+         }
+         return filteredTokens;
+     }
+ 
+     private boolean isLocalDC(InetAddress targetHost)
+     {
+         String remoteDC = DatabaseDescriptor.getEndpointSnitch().getDatacenter(targetHost);
+         String localDC = DatabaseDescriptor.getEndpointSnitch().getDatacenter(FBUtilities.getBroadcastAddress());
+         return remoteDC.equals(localDC);
+     }
+ 
+     private Map<Range<Token>, List<InetAddress>> getRangeToAddressMap(String keyspace, List<Token> sortedTokens)
+     {
          // some people just want to get a visual representation of things. Allow null and set it to the first
 -        // non-system table.
 +        // non-system keyspace.
          if (keyspace == null)
 -            keyspace = Schema.instance.getNonSystemTables().get(0);
 +            keyspace = Schema.instance.getNonSystemKeyspaces().get(0);
  
-         List<Range<Token>> ranges = getAllRanges(tokenMetadata.sortedTokens());
+         List<Range<Token>> ranges = getAllRanges(sortedTokens);
          return constructRangeToEndpointMap(keyspace, ranges);
      }
  
@@@ -1109,7 -1173,20 +1156,20 @@@
       */
      public List<TokenRange> describeRing(String keyspace) throws InvalidRequestException
      {
+         return describeRing(keyspace, false);
+     }
+ 
+     /**
+      * The same as {@code describeRing(String)} but considers only the part of the ring formed by nodes in the local DC.
+      */
+     public List<TokenRange> describeLocalRing(String keyspace) throws InvalidRequestException
+     {
+         return describeRing(keyspace, true);
+     }
+ 
+     private List<TokenRange> describeRing(String keyspace, boolean includeOnlyLocalDC) throws InvalidRequestException
+     {
 -        if (keyspace == null || Table.open(keyspace).getReplicationStrategy() instanceof LocalStrategy)
 +        if (keyspace == null || Keyspace.open(keyspace).getReplicationStrategy() instanceof LocalStrategy)
              throw new InvalidRequestException("There is no ring for the keyspace: " + keyspace);
  
          List<TokenRange> ranges = new ArrayList<TokenRange>();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/f2a82ee7/src/java/org/apache/cassandra/thrift/CassandraServer.java
----------------------------------------------------------------------