public AllTokensIterator(IPartitioner partitioner, SliceQuery columnSlice, int pageSize) { super(partitioner, columnSlice, pageSize, partitioner.getMinimumToken(), partitioner.getMinimumToken(), false); } }
private static Token getMinimumToken() throws PermanentBackendException { IPartitioner partitioner = StorageService.getPartitioner(); if (partitioner instanceof RandomPartitioner) { return ((RandomPartitioner) partitioner).getMinimumToken(); } else if (partitioner instanceof Murmur3Partitioner) { return ((Murmur3Partitioner) partitioner).getMinimumToken(); } else if (partitioner instanceof ByteOrderedPartitioner) { //TODO: This makes the assumption that its an EdgeStore (i.e. 8 byte keys) return new BytesToken(com.thinkaurelius.titan.diskstorage.util.ByteBufferUtil.zeroByteBuffer(8)); } else { throw new PermanentBackendException("Unsupported partitioner: " + partitioner); } }
private static Token getMaximumToken() throws PermanentBackendException { IPartitioner partitioner = StorageService.getPartitioner(); if (partitioner instanceof RandomPartitioner) { return new BigIntegerToken(RandomPartitioner.MAXIMUM); } else if (partitioner instanceof Murmur3Partitioner) { return new LongToken(Murmur3Partitioner.MAXIMUM); } else if (partitioner instanceof ByteOrderedPartitioner) { //TODO: This makes the assumption that its an EdgeStore (i.e. 8 byte keys) return new BytesToken(com.thinkaurelius.titan.diskstorage.util.ByteBufferUtil.oneByteBuffer(8)); } else { throw new PermanentBackendException("Unsupported partitioner: " + partitioner); } } }
try { List<Future<List<Shard>>> futures = new ArrayList<>(); TokenFactory tokenFactory = this.partitioner.getTokenFactory(); TokenRange tokenRange = rangeToTokenRange(new Range<>( tokenFactory.fromString(start), tokenFactory.fromString(end)));
public static <T extends RingPosition<T>> AbstractBounds<T> bounds(T min, boolean inclusiveMin, T max, boolean inclusiveMax) { if (inclusiveMin && inclusiveMax) return new Bounds<T>(min, max); else if (inclusiveMax) return new Range<T>(min, max); else if (inclusiveMin) return new IncludingExcludingBounds<T>(min, max); else return new ExcludingBounds<T>(min, max); }
@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); } }
public KeyRangeIterator(IPartitioner partitioner, SliceQuery columnSlice, int pageSize, ByteBuffer startKey, ByteBuffer endKey) throws BackendException { super(partitioner, columnSlice, pageSize, partitioner.getToken(startKey), partitioner.getToken(endKey), true); Preconditions.checkArgument(partitioner instanceof AbstractByteOrderedPartitioner); // Get first slice with key range instead of token range. Token // ranges are start-exclusive, key ranges are start-inclusive. Both // are end-inclusive. If we don't make the call below, then we will // erroneously miss startKey. List<KeySlice> ks = getKeySlice(startKey, endKey, columnSlice, pageSize); this.ksIter = checkFreshSlices(ks).iterator(); } }
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))); }
RowPosition startPosition = start.minKeyBound(partitioner); RowPosition endPosition = end.minKeyBound(partitioner); IDiskAtomFilter filter = ThriftValidation.asIFilter(predicate, cfm, null); RangeSliceCommand cmd = new RangeSliceCommand(keyspace, columnFamily, nowMillis, filter, new Bounds<RowPosition>(startPosition, endPosition), pageSize);
@Override public BigIntegerToken getToken(ByteBuffer key) { ByteBuffer extractedToken = extractSolandraToken(key); if(extractedToken == null) return super.getToken(key); //the token is pre-processed try { return new BigIntegerToken(ByteBufferUtil.string(extractedToken)); } catch (CharacterCodingException e) { throw new RuntimeException(e); } }
OAuthService service = new ServiceBuilder() .provider(TwitterApi.class) .apiKey("your_api_key") .apiSecret("your_api_secret") .build(); ... Token requestToken = service.getRequestToken(); String your_token = requestToken.getToken(); ... Verifier verifier = new Verifier("your_previously_retrieved_verifier"); Token accessToken = service.getAccessToken(requestToken, verifier);
public String getToken() { if (StorageService.instance.isClientMode()) return CassandraUtils.fakeToken; return StorageService.instance.getTokenMetadata().getToken(FBUtilities.getLocalAddress()).toString(); }
Logger.debug(String.format("token = %s", token.uuid)); LocalToken localToken = new LocalToken(); localToken.uuid = token.uuid; localToken.email = token.email;
BytesToken r = (BytesToken) rightKeyInclusive; byte[] leftTokenValue = l.getTokenValue(); byte[] rightTokenValue = r.getTokenValue();
public CassandraShard(CassandraSessionPool.Session session, String keyspace, String table) { this.session = session; this.keyspace = keyspace; this.table = table; this.partitioner = new Murmur3Partitioner(); }
protected List<KeySlice> checkFreshSlices(List<KeySlice> ks) { if (0 == ks.size()) { seenEnd = true; return Collections.emptyList(); } nextStartKey = ks.get(ks.size() - 1).bufferForKey(); nextStartToken = partitioner.getToken(nextStartKey); if (nextStartToken.equals(endToken)) { seenEnd = true; if (omitEndToken) ks.remove(ks.size() - 1); } return ks; }
@Override public org.apache.cassandra.db.DecoratedKey<BigIntegerToken> decorateKey(ByteBuffer key) { ByteBuffer extractedToken = extractSolandraToken(key); //non-solandra key passes through if(extractedToken == null) return new org.apache.cassandra.db.DecoratedKey<BigIntegerToken>(super.getToken(key), key); //the token is pre-processed try { return new org.apache.cassandra.db.DecoratedKey<BigIntegerToken>(new BigIntegerToken(ByteBufferUtil.string(extractedToken)), key); } catch (CharacterCodingException e) { throw new RuntimeException(e); } }
private final boolean hasNextInternal() throws BackendException { ensureOpen(); if (keys == null) return false; boolean hasNext = keys.hasNext(); if (!hasNext && lastSeenKey != null) { Token lastSeenToken = StorageService.getPartitioner().getToken(lastSeenKey.duplicate()); // let's check if we reached key upper bound already so we can skip one useless call to Cassandra if (maximumToken != getMinimumToken() && lastSeenToken.equals(maximumToken)) { return false; } List<Row> newKeys = getKeySlice(StorageService.getPartitioner().getToken(lastSeenKey), maximumToken, sliceQuery, pageSize, nowMillis); keys = getRowsIterator(newKeys, lastSeenKey); hasNext = keys.hasNext(); } return hasNext; }
public RowIterator(KeyRangeQuery keyRangeQuery, int pageSize, StoreTransaction txh) throws BackendException { this(StorageService.getPartitioner().getToken(keyRangeQuery.getKeyStart().asByteBuffer()), StorageService.getPartitioner().getToken(keyRangeQuery.getKeyEnd().asByteBuffer()), keyRangeQuery, pageSize, txh); }
Token<?> t = StorageService.getPartitioner().getToken(subIndex); List<InetAddress> addrs = Table.open(CassandraUtils.keySpace).getReplicationStrategy().getNaturalEndpoints(t);