@Override @SuppressWarnings("unchecked") public IPartitioner getCassandraPartitioner() throws BackendException { try { return StorageService.getPartitioner(); } catch (Exception e) { log.warn("Could not read local token range: {}", e); throw new PermanentBackendException("Could not read partitioner information on cluster", 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); }
@Override public KeyIterator getKeys(KeyRangeQuery keyRangeQuery, StoreTransaction txh) throws BackendException { IPartitioner partitioner = StorageService.getPartitioner(); // see rant about this in Astyanax implementation if (partitioner instanceof RandomPartitioner || partitioner instanceof Murmur3Partitioner) throw new PermanentBackendException("This operation is only supported when byte-ordered partitioner is used."); return new RowIterator(keyRangeQuery, storeManager.getPageSize(), txh); }
Token<?> t = StorageService.getPartitioner().getToken(subIndex); List<InetAddress> addrs = Table.open(CassandraUtils.keySpace).getReplicationStrategy().getNaturalEndpoints(t);
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); } } }
int pageSize, long nowMillis) throws BackendException { IPartitioner partitioner = StorageService.getPartitioner();
@Override @SuppressWarnings("unchecked") public IPartitioner getCassandraPartitioner() throws BackendException { try { return StorageService.getPartitioner(); } catch (Exception e) { log.warn("Could not read local token range: {}", e); throw new PermanentBackendException("Could not read partitioner information on cluster", e); } }
@Override @SuppressWarnings("unchecked") public IPartitioner<? extends Token<?>> getCassandraPartitioner() throws BackendException { try { return StorageService.getPartitioner(); } catch (Exception e) { log.warn("Could not read local token range: {}", e); throw new PermanentBackendException("Could not read partitioner information on cluster", e); } }
public Token deserialize(DataInput in) throws IOException { IPartitioner p = StorageService.getPartitioner(); int size = in.readInt(); byte[] bytes = new byte[size]; in.readFully(bytes); return p.getTokenFactory().fromByteArray(ByteBuffer.wrap(bytes)); }
public static Collection<Token> getRandomTokens(TokenMetadata metadata, int numTokens) { Set<Token> tokens = new HashSet<Token>(numTokens); while (tokens.size() < numTokens) { Token token = StorageService.getPartitioner().getRandomToken(); if (metadata.getEndpoint(token) == null) tokens.add(token); } return tokens; }
public long serializedSize(Token object, TypeSizes typeSizes) { IPartitioner p = StorageService.getPartitioner(); ByteBuffer b = p.getTokenFactory().toByteArray(object); return TypeSizes.NATIVE.sizeof(b.remaining()) + b.remaining(); } }
RangeNamesQueryPager(RangeSliceCommand command, ConsistencyLevel consistencyLevel, boolean localQuery, PagingState state) { this(command, consistencyLevel, localQuery); if (state != null) { lastReturnedKey = StorageService.getPartitioner().decorateKey(state.partitionKey); restoreState(state.remaining, true); } }
public List<String> listEndpointsPendingHints() { Token.TokenFactory tokenFactory = StorageService.getPartitioner().getTokenFactory(); // Extract the keys as strings to be reported. LinkedList<String> result = new LinkedList<>(); for (Row row : getHintsSlice(1)) { if (row.cf != null) //ignore removed rows result.addFirst(tokenFactory.toString(row.key.getToken())); } return result; }
@Override public KeyIterator getKeys(KeyRangeQuery keyRangeQuery, StoreTransaction txh) throws BackendException { IPartitioner partitioner = StorageService.getPartitioner(); // see rant about this in Astyanax implementation if (partitioner instanceof RandomPartitioner || partitioner instanceof Murmur3Partitioner) throw new PermanentBackendException("This operation is only supported when byte-ordered partitioner is used."); return new RowIterator(keyRangeQuery, storeManager.getPageSize(), txh); }
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); }
RangeSliceQueryPager(RangeSliceCommand command, ConsistencyLevel consistencyLevel, boolean localQuery, PagingState state) { this(command, consistencyLevel, localQuery); if (state != null) { lastReturnedKey = StorageService.getPartitioner().decorateKey(state.partitionKey); lastReturnedName = cfm.comparator.cellFromByteBuffer(state.cellName); restoreState(state.remaining, true); } }
public void serialize(Token token, DataOutputPlus out) throws IOException { IPartitioner p = StorageService.getPartitioner(); ByteBuffer b = p.getTokenFactory().toByteArray(token); ByteBufferUtil.writeWithLength(b, out); }
IPartitioner setPartitionerUnsafe(IPartitioner newPartitioner) { IPartitioner oldPartitioner = DatabaseDescriptor.getPartitioner(); DatabaseDescriptor.setPartitioner(newPartitioner); valueFactory = new VersionedValue.VersionedValueFactory(getPartitioner()); return oldPartitioner; }