@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); } }
try { List<Future<List<Shard>>> futures = new ArrayList<>(); TokenFactory tokenFactory = this.partitioner.getTokenFactory(); TokenRange tokenRange = rangeToTokenRange(new Range<>( tokenFactory.fromString(start),
private TokenRange rangeToTokenRange(Range<Token> range) { TokenFactory tokenFactory = this.partitioner.getTokenFactory(); Metadata metadata = this.session.metadata(); return metadata.newTokenRange( metadata.newToken(tokenFactory.toString(range.left)), metadata.newToken(tokenFactory.toString(range.right))); }
public static void serialize(IPartitioner partitioner, Collection<Token> tokens, DataOutput out) throws IOException { for (Token token : tokens) { byte[] bintoken = partitioner.getTokenFactory().toByteArray(token).array(); out.writeInt(bintoken.length); out.write(bintoken); } out.writeInt(0); }
/** * Deserializes the token corresponding to the specified buffer. * * @param buffer the buffer * @return the token corresponding to the specified buffer */ private Token deserializeToken(ByteBuffer buffer) { return partitioner.getTokenFactory().fromByteArray(buffer); }
/** * Deserializes the token corresponding to the specified buffer. * * @param buffer the buffer * @return the token corresponding to the specified buffer */ private Token deserializeToken(ByteBuffer buffer) { return partitioner.getTokenFactory().fromByteArray(buffer); }
public static void serialize(IPartitioner partitioner, Collection<Token> tokens, DataOutput out) throws IOException { for (Token token : tokens) { ByteBuffer tokenBuffer = partitioner.getTokenFactory().toByteArray(token); assert tokenBuffer.arrayOffset() == 0; ByteBufferUtil.writeWithLength(tokenBuffer.array(), out); } out.writeInt(0); }
public static void serialize(IPartitioner partitioner, Collection<Token> tokens, DataOutput out) throws IOException { for (Token token : tokens) { ByteBuffer tokenBuffer = partitioner.getTokenFactory().toByteArray(token); assert tokenBuffer.arrayOffset() == 0; ByteBufferUtil.writeWithLength(tokenBuffer.array(), out); } out.writeInt(0); }
public static void updateViewBuildStatus(String ksname, String viewName, Token token) { String req = "INSERT INTO system.%s (keyspace_name, view_name, last_token) VALUES (?, ?, ?)"; Token.TokenFactory factory = ViewsBuildsInProgress.partitioner.getTokenFactory(); executeInternal(String.format(req, VIEWS_BUILDS_IN_PROGRESS), ksname, viewName, factory.toString(token)); }
public static void updateViewBuildStatus(String ksname, String viewName, Token token) { String req = "INSERT INTO system.%s (keyspace_name, view_name, last_token) VALUES (?, ?, ?)"; Token.TokenFactory factory = ViewsBuildsInProgress.partitioner.getTokenFactory(); executeInternal(String.format(req, VIEWS_BUILDS_IN_PROGRESS), ksname, viewName, factory.toString(token)); }
public long serializedSize(Token object, int version) { IPartitioner p = object.getPartitioner(); ByteBuffer b = p.getTokenFactory().toByteArray(object); return TypeSizes.sizeof(b.remaining()) + b.remaining(); } }
public long serializedSize(Token object, int version) { IPartitioner p = object.getPartitioner(); ByteBuffer b = p.getTokenFactory().toByteArray(object); return TypeSizes.sizeof(b.remaining()) + b.remaining(); } }
public VersionedValue moving(Token token) { return new VersionedValue(VersionedValue.STATUS_MOVING + VersionedValue.DELIMITER + partitioner.getTokenFactory().toString(token)); }
public static void applyInitialTokens() { if (conf.initial_token != null) { Collection<String> tokens = tokensFromString(conf.initial_token); if (tokens.size() != conf.num_tokens) throw new ConfigurationException("The number of initial tokens (by initial_token) specified is different from num_tokens value", false); for (String token : tokens) partitioner.getTokenFactory().validate(token); } }
public static void applyInitialTokens() { if (conf.initial_token != null) { Collection<String> tokens = tokensFromString(conf.initial_token); if (tokens.size() != conf.num_tokens) throw new ConfigurationException("The number of initial tokens (by initial_token) specified is different from num_tokens value", false); for (String token : tokens) partitioner.getTokenFactory().validate(token); } }
private TokenRange rangeToTokenRange(Metadata metadata, Range<Token> range) { return metadata.newTokenRange(metadata.newToken(partitioner.getTokenFactory().toString(range.left)), metadata.newToken(partitioner.getTokenFactory().toString(range.right))); }
private TokenRange rangeToTokenRange(Metadata metadata, Range<Token> range) { return metadata.newTokenRange(metadata.newToken(partitioner.getTokenFactory().toString(range.left)), metadata.newToken(partitioner.getTokenFactory().toString(range.right))); }
public void serialize(Token token, DataOutputPlus out, int version) throws IOException { IPartitioner p = token.getPartitioner(); ByteBuffer b = p.getTokenFactory().toByteArray(token); ByteBufferUtil.writeWithLength(b, out); }
private Token getTokenBound(Bound b, QueryOptions options, IPartitioner p) { if (!partitionKeyRestrictions.hasBound(b)) return p.getMinimumToken(); ByteBuffer value = partitionKeyRestrictions.bounds(b, options).get(0); checkNotNull(value, "Invalid null token value"); return p.getTokenFactory().fromByteArray(value); }
private Token getTokenBound(Bound b, QueryOptions options, IPartitioner p) { if (!partitionKeyRestrictions.hasBound(b)) return p.getMinimumToken(); ByteBuffer value = partitionKeyRestrictions.bounds(b, options).get(0); checkNotNull(value, "Invalid null token value"); return p.getTokenFactory().fromByteArray(value); }