private List<Token> keysToTokens(Range<Token> range, List<DecoratedKey> keys) { List<Token> tokens = Lists.newArrayListWithExpectedSize(keys.size() + 2); tokens.add(range.left); for (DecoratedKey key : keys) tokens.add(key.getToken()); tokens.add(range.right); return tokens; }
public int compare(DecoratedKey o1, DecoratedKey o2) { if ((right.compareTo(o1.getToken()) < 0 && right.compareTo(o2.getToken()) < 0) || (right.compareTo(o1.getToken()) > 0 && right.compareTo(o2.getToken()) > 0)) { // both tokens are on the same side of the wrap point return o1.compareTo(o2); } return o2.compareTo(o1); } };
public boolean apply(SSTableReader sstable) { return sstable != null && !sstable.metadata.isIndex() && // exclude SSTables from 2i new Bounds<>(sstable.first.getToken(), sstable.last.getToken()).intersects(desc.ranges); } }, true, false); //ephemeral snapshot, if repair fails, it will be cleaned next startup
public DKToken(final DecoratedKey key) { super((long) key.getToken().getTokenValue()); keys = new TreeSet<DecoratedKey>(DecoratedKey.comparator) {{ add(key); }}; }
public DKToken(final DecoratedKey key) { super((long) key.getToken().getTokenValue()); keys = new TreeSet<DecoratedKey>(DecoratedKey.comparator) {{ add(key); }}; }
private static void printMinMaxToken(Descriptor descriptor, IPartitioner partitioner, AbstractType<?> keyType, PrintStream out) throws IOException { File summariesFile = new File(descriptor.filenameFor(Component.SUMMARY)); if (!summariesFile.exists()) return; try (DataInputStream iStream = new DataInputStream(new FileInputStream(summariesFile))) { Pair<DecoratedKey, DecoratedKey> firstLast = new IndexSummary.IndexSummarySerializer().deserializeFirstLastKey(iStream, partitioner, descriptor.version.hasSamplingLevel()); out.printf("First token: %s (key=%s)%n", firstLast.left.getToken(), keyType.getString(firstLast.left.getKey())); out.printf("Last token: %s (key=%s)%n", firstLast.right.getToken(), keyType.getString(firstLast.right.getKey())); } }
public int compareTo(PartitionPosition pos) { if (this == pos) return 0; // delegate to Token.KeyBound if needed if (!(pos instanceof DecoratedKey)) return -pos.compareTo(this); DecoratedKey otherKey = (DecoratedKey) pos; int cmp = getToken().compareTo(otherKey.getToken()); return cmp == 0 ? ByteBufferUtil.compareUnsigned(getKey(), otherKey.getKey()) : cmp; }
/** * Write a hint for all replicas. Used to re-dispatch hints whose destination is either missing or no longer correct. */ void writeForAllReplicas(Hint hint) { String keyspaceName = hint.mutation.getKeyspaceName(); Token token = hint.mutation.key().getToken(); Iterable<UUID> hostIds = transform(filter(StorageService.instance.getNaturalAndPendingEndpoints(keyspaceName, token), StorageProxy::shouldHint), StorageService.instance::getHostIdForEndpoint); write(hostIds, hint); }
/** * If the given @param key occupies only part of a larger buffer, allocate a new buffer that is only * as large as necessary. */ public static DecoratedKey getMinimalKey(DecoratedKey key) { return key.getKey().position() > 0 || key.getKey().hasRemaining() || !key.getKey().hasArray() ? new BufferDecoratedKey(key.getToken(), HeapAllocator.instance.clone(key.getKey())) : key; }
@Override public String toString() { String keystring = getKey() == null ? "null" : ByteBufferUtil.bytesToHex(getKey()); return "DecoratedKey(" + getToken() + ", " + keystring + ")"; }
public LongSet getOffsets() { LongSet offsets = new LongOpenHashSet(4); for (DecoratedKey key : keys) offsets.add((long) key.getToken().getTokenValue()); return offsets; }
@Override public String toString() { String keystring = getKey() == null ? "null" : ByteBufferUtil.bytesToHex(getKey()); return "DecoratedKey(" + getToken() + ", " + keystring + ")"; }
public boolean appliesLocally(Mutation mutation) { String keyspaceName = mutation.getKeyspaceName(); Token token = mutation.key().getToken(); InetAddress local = FBUtilities.getBroadcastAddress(); return StorageService.instance.getNaturalEndpoints(keyspaceName, token).contains(local) || StorageService.instance.getTokenMetadata().pendingEndpointsFor(token, keyspaceName).contains(local); }
public boolean appliesLocally(Mutation mutation) { String keyspaceName = mutation.getKeyspaceName(); Token token = mutation.key().getToken(); InetAddress local = FBUtilities.getBroadcastAddress(); return StorageService.instance.getNaturalEndpoints(keyspaceName, token).contains(local) || StorageService.instance.getTokenMetadata().pendingEndpointsFor(token, keyspaceName).contains(local); }
@Override public UnfilteredRowIterator cleanup(UnfilteredRowIterator partition) { if (Range.isInRanges(partition.partitionKey().getToken(), ranges)) return partition; cfs.invalidateCachedPartition(partition.partitionKey()); cfs.indexManager.deletePartition(partition, nowInSec); return null; } }
@Override public UnfilteredRowIterator cleanup(UnfilteredRowIterator partition) { if (Range.isInRanges(partition.partitionKey().getToken(), ranges)) return partition; cfs.invalidateCachedPartition(partition.partitionKey()); cfs.indexManager.deletePartition(partition, nowInSec); return null; } }