@Override public List<KeyRange> getLocalKeyPartition() throws BackendException { CTConnection conn = null; IPartitioner partitioner = getCassandraPartitioner(); if (!(partitioner instanceof AbstractByteOrderedPartitioner)) throw new UnsupportedOperationException("getLocalKeyPartition() only supported by byte ordered partitioner."); Token.TokenFactory tokenFactory = partitioner.getTokenFactory(); try { // Resist the temptation to describe SYSTEM_KS. It has no ring. // Instead, we'll create our own keyspace (or check that it exists), then describe it. ensureKeyspaceExists(keySpaceName); conn = pool.borrowObject(keySpaceName); List<TokenRange> ranges = conn.getClient().describe_ring(keySpaceName); List<KeyRange> keyRanges = new ArrayList<KeyRange>(ranges.size()); for (TokenRange range : ranges) { if (!NetworkUtil.hasLocalAddress(range.endpoints)) continue; keyRanges.add(CassandraHelper.transformRange(tokenFactory.fromString(range.start_token), tokenFactory.fromString(range.end_token))); } return keyRanges; } catch (Exception e) { throw CassandraThriftKeyColumnValueStore.convertException(e); } finally { pool.returnObjectUnsafe(keySpaceName, conn); } }
List<TokenRange> tokenRanges = client.describe_ring(keyspace); List<KsDef> ksDefs = client.describe_keyspaces();
List<TokenRange> tokenRanges = client.describe_ring(keyspace); List<KsDef> ksDefs = client.describe_keyspaces();
Token.TokenFactory tkFactory = getPartitioner().getTokenFactory(); for (TokenRange tr : client.describe_ring(keyspace))
List<TokenRange> ring = ConfigHelper.getOutputLocalDCOnly(conf) ? client.describe_local_ring(keyspace) : client.describe_ring(keyspace); rangeMap = ArrayListMultimap.create();
List<TokenRange> ring = ConfigHelper.getOutputLocalDCOnly(conf) ? client.describe_local_ring(keyspace) : client.describe_ring(keyspace); rangeMap = ArrayListMultimap.create();
List<TokenRange> ring = ConfigHelper.getOutputLocalDCOnly(conf) ? client.describe_local_ring(keyspace) : client.describe_ring(keyspace); rangeMap = ArrayListMultimap.create();
@Override public List<KeyRange> getLocalKeyPartition() throws BackendException { CTConnection conn = null; IPartitioner partitioner = getCassandraPartitioner(); if (!(partitioner instanceof AbstractByteOrderedPartitioner)) throw new UnsupportedOperationException("getLocalKeyPartition() only supported by byte ordered partitioner."); Token.TokenFactory tokenFactory = partitioner.getTokenFactory(); try { // Resist the temptation to describe SYSTEM_KS. It has no ring. // Instead, we'll create our own keyspace (or check that it exists), then describe it. ensureKeyspaceExists(keySpaceName); conn = pool.borrowObject(keySpaceName); List<TokenRange> ranges = conn.getClient().describe_ring(keySpaceName); List<KeyRange> keyRanges = new ArrayList<KeyRange>(ranges.size()); for (TokenRange range : ranges) { if (!NetworkUtil.hasLocalAddress(range.endpoints)) continue; keyRanges.add(CassandraHelper.transformRange(tokenFactory.fromString(range.start_token), tokenFactory.fromString(range.end_token))); } return keyRanges; } catch (Exception e) { throw CassandraThriftKeyColumnValueStore.convertException(e); } finally { pool.returnObjectUnsafe(keySpaceName, conn); } }
@Override public List<TokenRange> internalExecute(Cassandra.Client client, ConnectionContext context) throws Exception { List<org.apache.cassandra.thrift.TokenRange> trs = client.describe_ring(getKeyspaceName()); List<TokenRange> range = Lists.newArrayList(); for (org.apache.cassandra.thrift.TokenRange tr : trs) { List<String> endpoints = Lists.newArrayList(); for (org.apache.cassandra.thrift.EndpointDetails ed : tr.getEndpoint_details()) { if (dc != null && !ed.getDatacenter().equals(dc)) { continue; } else if (rack != null && !ed.getRack().equals(rack)) { continue; } else { endpoints.add(ed.getHost()); } } if (!endpoints.isEmpty()) { range.add(new TokenRangeImpl(tr.getStart_token(), tr.getEnd_token(), endpoints)); } } return range; } }, getConfig().getRetryPolicy().duplicate()).getResult();
@Override public List<TokenRange> internalExecute(Cassandra.Client client, ConnectionContext context) throws Exception { List<org.apache.cassandra.thrift.TokenRange> trs = client.describe_ring(getKeyspaceName()); List<TokenRange> range = Lists.newArrayList(); for (org.apache.cassandra.thrift.TokenRange tr : trs) { List<String> endpoints = Lists.newArrayList(); for (org.apache.cassandra.thrift.EndpointDetails ed : tr.getEndpoint_details()) { if (dc != null && !ed.getDatacenter().equals(dc)) { continue; } else if (rack != null && !ed.getRack().equals(rack)) { continue; } else { endpoints.add(ed.getHost()); } } if (!endpoints.isEmpty()) { range.add(new TokenRangeImpl(tr.getStart_token(), tr.getEnd_token(), endpoints)); } } return range; } }, getConfig().getRetryPolicy().duplicate()).getResult();
@Override public List<KeyRange> getLocalKeyPartition() throws BackendException { CTConnection conn = null; IPartitioner<?> partitioner = getCassandraPartitioner(); if (!(partitioner instanceof AbstractByteOrderedPartitioner)) throw new UnsupportedOperationException("getLocalKeyPartition() only supported by byte ordered partitioner."); Token.TokenFactory tokenFactory = partitioner.getTokenFactory(); try { conn = pool.borrowObject(keySpaceName); List<TokenRange> ranges = conn.getClient().describe_ring(keySpaceName); List<KeyRange> keyRanges = new ArrayList<KeyRange>(ranges.size()); for (TokenRange range : ranges) { if (!NetworkUtil.hasLocalAddress(range.endpoints)) continue; keyRanges.add(CassandraHelper.transformRange(tokenFactory.fromString(range.start_token), tokenFactory.fromString(range.end_token))); } return keyRanges; } catch (Exception e) { throw CassandraThriftKeyColumnValueStore.convertException(e); } finally { pool.returnObjectUnsafe(keySpaceName, conn); } }
@Override public List<TokenRange> describe_ring(String keyspace) throws InvalidRequestException, TException { return client.describe_ring(keyspace); }
@Override public List<TokenRange> execute(Cassandra.Client cassandra) throws HectorException { try { return cassandra.describe_ring(keyspace); } catch (Exception e) { throw xtrans.translate(e); } } };
@Override public List<TokenRange> execute(Cassandra.Client cassandra) throws HectorException { try { return cassandra.describe_ring(keyspace); } catch (Exception e) { throw xtrans.translate(e); } } };
@Override public List<TokenRange> describe_ring(String keyspace) throws InvalidRequestException, TException { return executeHandlingExceptions(() -> client.describe_ring(keyspace)); }
@Override public List<TokenRange> describe_ring(String keyspace) throws InvalidRequestException, TException { return client.describe_ring(keyspace); }
@Override public List<TokenRange> describe_ring(String keyspace) throws InvalidRequestException, TException { return executeHandlingExceptions(() -> client.describe_ring(keyspace)); }
@Override public List<TokenRange> execute(Cassandra.Client cassandra) throws HectorException { try { return cassandra.describe_ring(keyspace); } catch (Exception e) { throw xtrans.translate(e); } } };
@Override public List<TokenRange> describe_ring(String keyspace) throws InvalidRequestException, TException { return client.describe_ring(keyspace); }