Java 类org.apache.cassandra.thrift.TokenRange 实例源码

项目:cassandra-kmean    文件:StorageService.java   
/**
 * The same as {@code describeRing(String)} but converts TokenRange to the String for JMX compatibility
 *
 * @param keyspace The keyspace to fetch information about
 *
 * @return a List of TokenRange(s) converted to String for the given keyspace
 */
public List<String> describeRingJMX(String keyspace) throws IOException
{
    List<TokenRange> tokenRanges;
    try
    {
        tokenRanges = describeRing(keyspace);
    }
    catch (InvalidRequestException e)
    {
        throw new IOException(e.getMessage());
    }
    List<String> result = new ArrayList<>(tokenRanges.size());

    for (TokenRange tokenRange : tokenRanges)
        result.add(tokenRange.toString());

    return result;
}
项目:ACaZoo    文件:StorageService.java   
/**
 * The same as {@code describeRing(String)} but converts TokenRange to the String for JMX compatibility
 *
 * @param keyspace The keyspace to fetch information about
 *
 * @return a List of TokenRange(s) converted to String for the given keyspace
 */
public List<String> describeRingJMX(String keyspace) throws IOException
{
    List<TokenRange> tokenRanges;
    try
    {
        tokenRanges = describeRing(keyspace);
    }
    catch (InvalidRequestException e)
    {
        throw new IOException(e.getMessage());
    }
    List<String> result = new ArrayList<String>(tokenRanges.size());

    for (TokenRange tokenRange : tokenRanges)
        result.add(tokenRange.toString());

    return result;
}
项目:scylla-tools-java    文件:StorageService.java   
/**
 * The same as {@code describeRing(String)} but converts TokenRange to the String for JMX compatibility
 *
 * @param keyspace The keyspace to fetch information about
 *
 * @return a List of TokenRange(s) converted to String for the given keyspace
 */
public List<String> describeRingJMX(String keyspace) throws IOException
{
    List<TokenRange> tokenRanges;
    try
    {
        tokenRanges = describeRing(keyspace);
    }
    catch (InvalidRequestException e)
    {
        throw new IOException(e.getMessage());
    }
    List<String> result = new ArrayList<>(tokenRanges.size());

    for (TokenRange tokenRange : tokenRanges)
        result.add(tokenRange.toString());

    return result;
}
项目:GraphTrek    文件:StorageService.java   
/**
 * The same as {@code describeRing(String)} but converts TokenRange to the String for JMX compatibility
 *
 * @param keyspace The keyspace to fetch information about
 *
 * @return a List of TokenRange(s) converted to String for the given keyspace
 */
public List<String> describeRingJMX(String keyspace) throws IOException
{
    List<TokenRange> tokenRanges;
    try
    {
        tokenRanges = describeRing(keyspace);
    }
    catch (InvalidRequestException e)
    {
        throw new IOException(e.getMessage());
    }
    List<String> result = new ArrayList<>(tokenRanges.size());

    for (TokenRange tokenRange : tokenRanges)
        result.add(tokenRange.toString());

    return result;
}
项目:Cassandra-Wasef    文件:StorageService.java   
/**
 * The same as {@code describeRing(String)} but converts TokenRange to the String for JMX compatibility
 *
 * @param keyspace The keyspace to fetch information about
 *
 * @return a List of TokenRange(s) converted to String for the given keyspace
 */
public List<String> describeRingJMX(String keyspace) throws IOException
{
    List<TokenRange> tokenRanges = null;
    try
    {
        tokenRanges = describeRing(keyspace);
    }
    catch (InvalidRequestException e)
    {
        throw new IOException(e.getMessage());
    }
    List<String> result = new ArrayList<String>(tokenRanges.size());

    for (TokenRange tokenRange : tokenRanges)
        result.add(tokenRange.toString());

    return result;
}
项目:stratio-cassandra    文件:StorageService.java   
/**
 * The same as {@code describeRing(String)} but converts TokenRange to the String for JMX compatibility
 *
 * @param keyspace The keyspace to fetch information about
 *
 * @return a List of TokenRange(s) converted to String for the given keyspace
 */
public List<String> describeRingJMX(String keyspace) throws IOException
{
    List<TokenRange> tokenRanges;
    try
    {
        tokenRanges = describeRing(keyspace);
    }
    catch (InvalidRequestException e)
    {
        throw new IOException(e.getMessage());
    }
    List<String> result = new ArrayList<>(tokenRanges.size());

    for (TokenRange tokenRange : tokenRanges)
        result.add(tokenRange.toString());

    return result;
}
项目:cassandra-cqlMod    文件:StorageService.java   
/**
 * The same as {@code describeRing(String)} but converts TokenRange to the String for JMX compatibility
 *
 * @param keyspace The keyspace to fetch information about
 *
 * @return a List of TokenRange(s) converted to String for the given keyspace
 */
public List<String> describeRingJMX(String keyspace) throws IOException
{
    List<TokenRange> tokenRanges;
    try
    {
        tokenRanges = describeRing(keyspace);
    }
    catch (InvalidRequestException e)
    {
        throw new IOException(e.getMessage());
    }
    List<String> result = new ArrayList<String>(tokenRanges.size());

    for (TokenRange tokenRange : tokenRanges)
        result.add(tokenRange.toString());

    return result;
}
项目:wso2-cassandra    文件:StorageService.java   
/**
 * The same as {@code describeRing(String)} but converts TokenRange to the String for JMX compatibility
 *
 * @param keyspace The keyspace to fetch information about
 *
 * @return a List of TokenRange(s) converted to String for the given keyspace
 */
public List<String> describeRingJMX(String keyspace) throws IOException
{
    List<TokenRange> tokenRanges = null;
    try
    {
        tokenRanges = describeRing(keyspace);
    }
    catch (InvalidRequestException e)
    {
        throw new IOException(e.getMessage());
    }
    List<String> result = new ArrayList<String>(tokenRanges.size());

    for (TokenRange tokenRange : tokenRanges)
        result.add(tokenRange.toString());

    return result;
}
项目:cassandra-trunk    文件:StorageService.java   
/**
 * The same as {@code describeRing(String)} but converts TokenRange to the String for JMX compatibility
 *
 * @param keyspace The keyspace to fetch information about
 *
 * @return a List of TokenRange(s) converted to String for the given keyspace
 */
public List<String> describeRingJMX(String keyspace) throws IOException
{
    List<TokenRange> tokenRanges;
    try
    {
        tokenRanges = describeRing(keyspace);
    }
    catch (InvalidRequestException e)
    {
        throw new IOException(e.getMessage());
    }
    List<String> result = new ArrayList<>(tokenRanges.size());

    for (TokenRange tokenRange : tokenRanges)
        result.add(tokenRange.toString());

    return result;
}
项目:cassandra-1.2.16    文件:StorageService.java   
/**
 * The same as {@code describeRing(String)} but converts TokenRange to the String for JMX compatibility
 *
 * @param keyspace The keyspace to fetch information about
 *
 * @return a List of TokenRange(s) converted to String for the given keyspace
 */
public List<String> describeRingJMX(String keyspace) throws IOException
{
    List<TokenRange> tokenRanges = null;
    try
    {
        tokenRanges = describeRing(keyspace);
    }
    catch (InvalidRequestException e)
    {
        throw new IOException(e.getMessage());
    }
    List<String> result = new ArrayList<String>(tokenRanges.size());

    for (TokenRange tokenRange : tokenRanges)
        result.add(tokenRange.toString());

    return result;
}
项目:ACaZoo    文件:StorageService.java   
/**
 * The TokenRange for a given keyspace.
 *
 * @param keyspace The keyspace to fetch information about
 *
 * @return a List of TokenRange(s) for the given keyspace
 *
 * @throws InvalidRequestException if there is no ring information available about keyspace
 */
public List<TokenRange> describeRing(String keyspace) throws InvalidRequestException
{
    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>();
    Token.TokenFactory tf = getPartitioner().getTokenFactory();

    for (Map.Entry<Range<Token>, List<InetAddress>> entry : getRangeToAddressMap(keyspace).entrySet())
    {
        Range range = entry.getKey();
        List<InetAddress> addresses = entry.getValue();
        List<String> endpoints = new ArrayList<String>(addresses.size());
        List<String> rpc_endpoints = new ArrayList<String>(addresses.size());
        List<EndpointDetails> epDetails = new ArrayList<EndpointDetails>(addresses.size());

        for (InetAddress endpoint : addresses)
        {
            EndpointDetails details = new EndpointDetails();
            details.host = endpoint.getHostAddress();
            details.datacenter = DatabaseDescriptor.getEndpointSnitch().getDatacenter(endpoint);
            details.rack = DatabaseDescriptor.getEndpointSnitch().getRack(endpoint);

            endpoints.add(details.host);
            rpc_endpoints.add(getRpcaddress(endpoint));

            epDetails.add(details);
        }

        TokenRange tr = new TokenRange(tf.toString(range.left.getToken()), tf.toString(range.right.getToken()), endpoints)
                                .setEndpoint_details(epDetails)
                                .setRpc_endpoints(rpc_endpoints);

        ranges.add(tr);
    }

    return ranges;
}
项目:presto    文件:CassandraThriftClient.java   
public List<TokenRange> getRangeMap(String keyspace)
{
    Client client = connectionFactory.create();
    try {
        return client.describe_ring(keyspace);
    }
    catch (TException e) {
        throw new RuntimeException(e);
    }
    finally {
        closeQuietly(client);
    }
}
项目:presto    文件:CassandraTokenSplitManager.java   
public List<TokenSplit> getSplits(String keyspace, String columnFamily)
        throws IOException
{
    List<TokenRange> masterRangeNodes = cassandraThriftClient.getRangeMap(keyspace);

    // canonical ranges, split into pieces, fetching the splits in parallel
    List<TokenSplit> splits = new ArrayList<>();
    List<Future<List<TokenSplit>>> splitFutures = new ArrayList<>();
    for (TokenRange range : masterRangeNodes) {
        // for each range, pick a live owner and ask it to compute bite-sized splits
        splitFutures.add(executor.submit(new SplitCallable<>(range, keyspace, columnFamily, splitSize, cassandraThriftClient, partitioner)));
    }

    // wait until we have all the results back
    for (Future<List<TokenSplit>> futureInputSplits : splitFutures) {
        try {
            splits.addAll(futureInputSplits.get());
        }
        catch (Exception e) {
            throw new IOException("Could not get input splits", e);
        }
    }

    checkState(!splits.isEmpty(), "No splits created");
    //noinspection SharedThreadLocalRandom
    Collections.shuffle(splits, ThreadLocalRandom.current());
    return splits;
}
项目:presto    文件:CassandraTokenSplitManager.java   
public SplitCallable(TokenRange range, String keyspace, String columnFamily, int splitSize, CassandraThriftClient client, IPartitioner<T> partitioner)
{
    checkArgument(range.rpc_endpoints.size() == range.endpoints.size(), "rpc_endpoints size must match endpoints size");
    this.range = range;
    this.keyspace = keyspace;
    this.columnFamily = columnFamily;
    this.splitSize = splitSize;
    this.client = client;
    this.partitioner = partitioner;
}
项目:Cassandra-Wasef    文件:StorageService.java   
/**
 * The TokenRange for a given keyspace.
 *
 * @param keyspace The keyspace to fetch information about
 *
 * @return a List of TokenRange(s) for the given keyspace
 *
 * @throws InvalidRequestException if there is no ring information available about keyspace
 */
public List<TokenRange> describeRing(String keyspace) throws InvalidRequestException
{
    if (keyspace == null || Table.open(keyspace).getReplicationStrategy() instanceof LocalStrategy)
        throw new InvalidRequestException("There is no ring for the keyspace: " + keyspace);

    List<TokenRange> ranges = new ArrayList<TokenRange>();
    Token.TokenFactory tf = getPartitioner().getTokenFactory();

    for (Map.Entry<Range<Token>, List<InetAddress>> entry : getRangeToAddressMap(keyspace).entrySet())
    {
        Range range = entry.getKey();
        List<InetAddress> addresses = entry.getValue();
        List<String> endpoints = new ArrayList<String>(addresses.size());
        List<String> rpc_endpoints = new ArrayList<String>(addresses.size());
        List<EndpointDetails> epDetails = new ArrayList<EndpointDetails>(addresses.size());

        for (InetAddress endpoint : addresses)
        {
            EndpointDetails details = new EndpointDetails();
            details.host = endpoint.getHostAddress();
            details.datacenter = DatabaseDescriptor.getEndpointSnitch().getDatacenter(endpoint);
            details.rack = DatabaseDescriptor.getEndpointSnitch().getRack(endpoint);

            endpoints.add(details.host);
            rpc_endpoints.add(getRpcaddress(endpoint));

            epDetails.add(details);
        }

        TokenRange tr = new TokenRange(tf.toString(range.left.getToken()), tf.toString(range.right.getToken()), endpoints)
                                .setEndpoint_details(epDetails)
                                .setRpc_endpoints(rpc_endpoints);

        ranges.add(tr);
    }

    return ranges;
}
项目:hive-cassandra    文件:CassandraProxyClient.java   
private List<String> getAllServers(List<TokenRange> input) {
    HashMap<String, Integer> map = new HashMap<String, Integer>(input.size());
    for (TokenRange thisRange : input) {
        List<String> servers = thisRange.rpc_endpoints;
        for (String newServer : servers) {
            map.put(newServer, new Integer(1));
        }
    }

    return new ArrayList<String>(map.keySet());
}
项目:Hive-Cassandra    文件:CassandraProxyClient.java   
private List<String> getAllServers(List<TokenRange> input) {
  HashMap<String, Integer> map = new HashMap<String, Integer>(input.size());
  for (TokenRange thisRange : input) {
    List<String> servers = thisRange.rpc_endpoints;
    for (String newServer : servers) {
      map.put(newServer, new Integer(1));
    }
  }

  return new ArrayList<String>(map.keySet());
}
项目:spiff    文件:CassandraTest.java   
public void testDescribeRing ()
  throws Exception
{
  TSocket sock = new TSocket("caleb-htpc", 9160, 5000);
  TTransport tr = new TFramedTransport(sock);
  tr.open();
  Cassandra.Client client = new Cassandra.Client(new TBinaryProtocol(tr));
  for ( TokenRange range : client.describe_ring("Outerspacecat") ) {
    for ( EndpointDetails endpoint : range.getEndpoint_details() ) {
      System.out.println(endpoint.getHost());
    }
  }
}
项目:cassandra-kmean    文件:AbstractColumnFamilyInputFormat.java   
public SplitCallable(TokenRange tr, Configuration conf)
{
    this.range = tr;
    this.conf = conf;
}
项目:cassandra-kmean    文件:StorageService.java   
/**
 * 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);
}
项目:cassandra-kmean    文件:StorageService.java   
private List<TokenRange> describeRing(String keyspace, boolean includeOnlyLocalDC) throws InvalidRequestException
{
    if (!Schema.instance.getKeyspaces().contains(keyspace))
        throw new InvalidRequestException("No such keyspace: " + keyspace);

    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<>();
    Token.TokenFactory tf = getPartitioner().getTokenFactory();

    Map<Range<Token>, List<InetAddress>> rangeToAddressMap =
            includeOnlyLocalDC
                    ? getRangeToAddressMapInLocalDC(keyspace)
                    : getRangeToAddressMap(keyspace);

    for (Map.Entry<Range<Token>, List<InetAddress>> entry : rangeToAddressMap.entrySet())
    {
        Range range = entry.getKey();
        List<InetAddress> addresses = entry.getValue();
        List<String> endpoints = new ArrayList<>(addresses.size());
        List<String> rpc_endpoints = new ArrayList<>(addresses.size());
        List<EndpointDetails> epDetails = new ArrayList<>(addresses.size());

        for (InetAddress endpoint : addresses)
        {
            EndpointDetails details = new EndpointDetails();
            details.host = endpoint.getHostAddress();
            details.datacenter = DatabaseDescriptor.getEndpointSnitch().getDatacenter(endpoint);
            details.rack = DatabaseDescriptor.getEndpointSnitch().getRack(endpoint);

            endpoints.add(details.host);
            rpc_endpoints.add(getRpcaddress(endpoint));

            epDetails.add(details);
        }

        TokenRange tr = new TokenRange(tf.toString(range.left.getToken()), tf.toString(range.right.getToken()), endpoints)
                                .setEndpoint_details(epDetails)
                                .setRpc_endpoints(rpc_endpoints);

        ranges.add(tr);
    }

    return ranges;
}
项目:ACaZoo    文件:AbstractColumnFamilyInputFormat.java   
public SplitCallable(TokenRange tr, Configuration conf)
{
    this.range = tr;
    this.conf = conf;
}
项目:ACaZoo    文件:Shuffle.java   
List<TokenRange> describe_ring(String keyspace) throws InvalidRequestException, TException
{
    return client.describe_ring(keyspace);
}
项目:scylla-tools-java    文件:StorageService.java   
/**
 * 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);
}
项目:scylla-tools-java    文件:StorageService.java   
private List<TokenRange> describeRing(String keyspace, boolean includeOnlyLocalDC) throws InvalidRequestException
{
    if (!Schema.instance.getKeyspaces().contains(keyspace))
        throw new InvalidRequestException("No such keyspace: " + keyspace);

    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<>();
    Token.TokenFactory tf = getTokenFactory();

    Map<Range<Token>, List<InetAddress>> rangeToAddressMap =
            includeOnlyLocalDC
                    ? getRangeToAddressMapInLocalDC(keyspace)
                    : getRangeToAddressMap(keyspace);

    for (Map.Entry<Range<Token>, List<InetAddress>> entry : rangeToAddressMap.entrySet())
    {
        Range<Token> range = entry.getKey();
        List<InetAddress> addresses = entry.getValue();
        List<String> endpoints = new ArrayList<>(addresses.size());
        List<String> rpc_endpoints = new ArrayList<>(addresses.size());
        List<EndpointDetails> epDetails = new ArrayList<>(addresses.size());

        for (InetAddress endpoint : addresses)
        {
            EndpointDetails details = new EndpointDetails();
            details.host = endpoint.getHostAddress();
            details.datacenter = DatabaseDescriptor.getEndpointSnitch().getDatacenter(endpoint);
            details.rack = DatabaseDescriptor.getEndpointSnitch().getRack(endpoint);

            endpoints.add(details.host);
            rpc_endpoints.add(getRpcaddress(endpoint));

            epDetails.add(details);
        }

        TokenRange tr = new TokenRange(tf.toString(range.left.getToken()), tf.toString(range.right.getToken()), endpoints)
                                .setEndpoint_details(epDetails)
                                .setRpc_endpoints(rpc_endpoints);

        ranges.add(tr);
    }

    return ranges;
}
项目:GraphTrek    文件:AbstractColumnFamilyInputFormat.java   
public SplitCallable(TokenRange tr, Configuration conf)
{
    this.range = tr;
    this.conf = conf;
}
项目:GraphTrek    文件:StorageService.java   
/**
 * 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);
}
项目:GraphTrek    文件:StorageService.java   
private List<TokenRange> describeRing(String keyspace, boolean includeOnlyLocalDC) throws InvalidRequestException
{
    if (!Schema.instance.getKeyspaces().contains(keyspace))
        throw new InvalidRequestException("No such keyspace: " + keyspace);

    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<>();
    Token.TokenFactory tf = getPartitioner().getTokenFactory();

    Map<Range<Token>, List<InetAddress>> rangeToAddressMap =
            includeOnlyLocalDC
                    ? getRangeToAddressMapInLocalDC(keyspace)
                    : getRangeToAddressMap(keyspace);

    for (Map.Entry<Range<Token>, List<InetAddress>> entry : rangeToAddressMap.entrySet())
    {
        Range range = entry.getKey();
        List<InetAddress> addresses = entry.getValue();
        List<String> endpoints = new ArrayList<>(addresses.size());
        List<String> rpc_endpoints = new ArrayList<>(addresses.size());
        List<EndpointDetails> epDetails = new ArrayList<>(addresses.size());

        for (InetAddress endpoint : addresses)
        {
            EndpointDetails details = new EndpointDetails();
            details.host = endpoint.getHostAddress();
            details.datacenter = DatabaseDescriptor.getEndpointSnitch().getDatacenter(endpoint);
            details.rack = DatabaseDescriptor.getEndpointSnitch().getRack(endpoint);

            endpoints.add(details.host);
            rpc_endpoints.add(getRpcaddress(endpoint));

            epDetails.add(details);
        }

        TokenRange tr = new TokenRange(tf.toString(range.left.getToken()), tf.toString(range.right.getToken()), endpoints)
                                .setEndpoint_details(epDetails)
                                .setRpc_endpoints(rpc_endpoints);

        ranges.add(tr);
    }

    return ranges;
}
项目:Cassandra-Wasef    文件:AbstractColumnFamilyInputFormat.java   
public SplitCallable(TokenRange tr, Configuration conf)
{
    this.range = tr;
    this.conf = conf;
}
项目:Cassandra-Wasef    文件:Shuffle.java   
List<TokenRange> describe_ring(String keyspace) throws InvalidRequestException, TException
{
    return client.describe_ring(keyspace);
}
项目:stratio-cassandra    文件:AbstractColumnFamilyInputFormat.java   
public SplitCallable(TokenRange tr, Configuration conf)
{
    this.range = tr;
    this.conf = conf;
}
项目:stratio-cassandra    文件:StorageService.java   
/**
 * 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);
}
项目:stratio-cassandra    文件:StorageService.java   
private List<TokenRange> describeRing(String keyspace, boolean includeOnlyLocalDC) throws InvalidRequestException
{
    if (!Schema.instance.getKeyspaces().contains(keyspace))
        throw new InvalidRequestException("No such keyspace: " + keyspace);

    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<>();
    Token.TokenFactory tf = getPartitioner().getTokenFactory();

    Map<Range<Token>, List<InetAddress>> rangeToAddressMap =
            includeOnlyLocalDC
                    ? getRangeToAddressMapInLocalDC(keyspace)
                    : getRangeToAddressMap(keyspace);

    for (Map.Entry<Range<Token>, List<InetAddress>> entry : rangeToAddressMap.entrySet())
    {
        Range range = entry.getKey();
        List<InetAddress> addresses = entry.getValue();
        List<String> endpoints = new ArrayList<>(addresses.size());
        List<String> rpc_endpoints = new ArrayList<>(addresses.size());
        List<EndpointDetails> epDetails = new ArrayList<>(addresses.size());

        for (InetAddress endpoint : addresses)
        {
            EndpointDetails details = new EndpointDetails();
            details.host = endpoint.getHostAddress();
            details.datacenter = DatabaseDescriptor.getEndpointSnitch().getDatacenter(endpoint);
            details.rack = DatabaseDescriptor.getEndpointSnitch().getRack(endpoint);

            endpoints.add(details.host);
            rpc_endpoints.add(getRpcaddress(endpoint));

            epDetails.add(details);
        }

        TokenRange tr = new TokenRange(tf.toString(range.left.getToken()), tf.toString(range.right.getToken()), endpoints)
                                .setEndpoint_details(epDetails)
                                .setRpc_endpoints(rpc_endpoints);

        ranges.add(tr);
    }

    return ranges;
}
项目:cassandra-cqlMod    文件:AbstractColumnFamilyInputFormat.java   
public SplitCallable(TokenRange tr, Configuration conf)
{
    this.range = tr;
    this.conf = conf;
}
项目:cassandra-cqlMod    文件:StorageService.java   
/**
 * 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);
}
项目:cassandra-cqlMod    文件:StorageService.java   
private List<TokenRange> describeRing(String keyspace, boolean includeOnlyLocalDC) throws InvalidRequestException
{
    if (!Schema.instance.getKeyspaces().contains(keyspace))
        throw new InvalidRequestException("No such keyspace: " + keyspace);

    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>();
    Token.TokenFactory tf = getPartitioner().getTokenFactory();

    Map<Range<Token>, List<InetAddress>> rangeToAddressMap =
            includeOnlyLocalDC
                    ? getRangeToAddressMapInLocalDC(keyspace)
                    : getRangeToAddressMap(keyspace);

    for (Map.Entry<Range<Token>, List<InetAddress>> entry : rangeToAddressMap.entrySet())
    {
        Range range = entry.getKey();
        List<InetAddress> addresses = entry.getValue();
        List<String> endpoints = new ArrayList<String>(addresses.size());
        List<String> rpc_endpoints = new ArrayList<String>(addresses.size());
        List<EndpointDetails> epDetails = new ArrayList<EndpointDetails>(addresses.size());

        for (InetAddress endpoint : addresses)
        {
            EndpointDetails details = new EndpointDetails();
            details.host = endpoint.getHostAddress();
            details.datacenter = DatabaseDescriptor.getEndpointSnitch().getDatacenter(endpoint);
            details.rack = DatabaseDescriptor.getEndpointSnitch().getRack(endpoint);

            endpoints.add(details.host);
            rpc_endpoints.add(getRpcaddress(endpoint));

            epDetails.add(details);
        }

        TokenRange tr = new TokenRange(tf.toString(range.left.getToken()), tf.toString(range.right.getToken()), endpoints)
                                .setEndpoint_details(epDetails)
                                .setRpc_endpoints(rpc_endpoints);

        ranges.add(tr);
    }

    return ranges;
}
项目:cassandra-cqlMod    文件:Shuffle.java   
List<TokenRange> describe_ring(String keyspace) throws InvalidRequestException, TException
{
    return client.describe_ring(keyspace);
}
项目:wso2-cassandra    文件:AbstractColumnFamilyInputFormat.java   
public SplitCallable(TokenRange tr, Configuration conf)
{
    this.range = tr;
    this.conf = conf;
}
项目:wso2-cassandra    文件:StorageService.java   
/**
 * 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);
}
项目:wso2-cassandra    文件:StorageService.java   
private List<TokenRange> describeRing(String keyspace, boolean includeOnlyLocalDC) throws InvalidRequestException
{
    if (keyspace == null || Table.open(keyspace).getReplicationStrategy() instanceof LocalStrategy)
        throw new InvalidRequestException("There is no ring for the keyspace: " + keyspace);

    List<TokenRange> ranges = new ArrayList<TokenRange>();
    Token.TokenFactory tf = getPartitioner().getTokenFactory();

    Map<Range<Token>, List<InetAddress>> rangeToAddressMap =
            includeOnlyLocalDC
                    ? getRangeToAddressMapInLocalDC(keyspace)
                    : getRangeToAddressMap(keyspace);

    for (Map.Entry<Range<Token>, List<InetAddress>> entry : rangeToAddressMap.entrySet())
    {
        Range range = entry.getKey();
        List<InetAddress> addresses = entry.getValue();
        List<String> endpoints = new ArrayList<String>(addresses.size());
        List<String> rpc_endpoints = new ArrayList<String>(addresses.size());
        List<EndpointDetails> epDetails = new ArrayList<EndpointDetails>(addresses.size());

        for (InetAddress endpoint : addresses)
        {
            EndpointDetails details = new EndpointDetails();
            details.host = endpoint.getHostAddress();
            details.datacenter = DatabaseDescriptor.getEndpointSnitch().getDatacenter(endpoint);
            details.rack = DatabaseDescriptor.getEndpointSnitch().getRack(endpoint);

            endpoints.add(details.host);
            rpc_endpoints.add(getRpcaddress(endpoint));

            epDetails.add(details);
        }

        TokenRange tr = new TokenRange(tf.toString(range.left.getToken()), tf.toString(range.right.getToken()), endpoints)
                                .setEndpoint_details(epDetails)
                                .setRpc_endpoints(rpc_endpoints);

        ranges.add(tr);
    }

    return ranges;
}