/** * Compose. * * @param value * the value * @param clazz * the clazz * @return the byte[] */ private static byte[] compose(Object value, Class clazz) { return UUIDType.instance.decompose((UUID) value).array(); }
return UUIDType.instance.decompose(UUID.fromString(value.toString()));
private static byte[] compose(Object value, Class clazz) { return UUIDType.instance.decompose((UUID) value).array(); }
/** * Returns the {@link String} representation of the specified {@link UUID}. The returned value has the same * collation as {@link UUIDType}. * * @param uuid the {@link UUID} to be serialized * @return the {@link String} representation of the specified {@link UUID} */ static String serialize(UUID uuid) { StringBuilder sb = new StringBuilder(); // Get UUID type version ByteBuffer bb = UUIDType.instance.decompose(uuid); int version = (bb.get(bb.position() + 6) >> 4) & 0x0f; // Add version at the beginning sb.append(ByteBufferUtils.toHex((byte) version)); // If it's a time based UUID, add the UNIX timestamp if (version == 1) { long timestamp = uuid.timestamp(); String timestampHex = ByteBufferUtils.toHex(Longs.toByteArray(timestamp)); sb.append(timestampHex); } // Add the UUID itself sb.append(ByteBufferUtils.toHex(bb)); return sb.toString(); }
private static void deleteLegacyHintsPartition(UUID hostId) { // intentionally use millis, like the rest of the legacy implementation did, just in case Mutation mutation = new Mutation(PartitionUpdate.fullPartitionDelete(SystemKeyspace.LegacyHints, UUIDType.instance.decompose(hostId), System.currentTimeMillis(), FBUtilities.nowInSeconds())); mutation.applyUnsafe(); } }
private static void deleteLegacyHintsPartition(UUID hostId) { // intentionally use millis, like the rest of the legacy implementation did, just in case Mutation mutation = new Mutation(PartitionUpdate.fullPartitionDelete(SystemKeyspace.LegacyHints, UUIDType.instance.decompose(hostId), System.currentTimeMillis(), FBUtilities.nowInSeconds())); mutation.applyUnsafe(); } }
private static void deleteLegacyHintsPartition(UUID hostId) { // intentionally use millis, like the rest of the legacy implementation did, just in case Mutation mutation = new Mutation(PartitionUpdate.fullPartitionDelete(SystemKeyspace.LegacyHints, UUIDType.instance.decompose(hostId), System.currentTimeMillis(), FBUtilities.nowInSeconds())); mutation.applyUnsafe(); } }
@SuppressWarnings("deprecation") private static Mutation getRemoveMutation(UUID uuid) { return new Mutation(PartitionUpdate.fullPartitionDelete(SystemKeyspace.LegacyBatchlog, UUIDType.instance.decompose(uuid), FBUtilities.timestampMicros(), FBUtilities.nowInSeconds())); }
@SuppressWarnings("deprecation") private static Mutation getRemoveMutation(UUID uuid) { return new Mutation(PartitionUpdate.fullPartitionDelete(SystemKeyspace.LegacyBatchlog, UUIDType.instance.decompose(uuid), FBUtilities.timestampMicros(), FBUtilities.nowInSeconds())); }
@SuppressWarnings("deprecation") private static Mutation getRemoveMutation(UUID uuid) { return new Mutation(PartitionUpdate.fullPartitionDelete(SystemKeyspace.LegacyBatchlog, UUIDType.instance.decompose(uuid), FBUtilities.timestampMicros(), FBUtilities.nowInSeconds())); }
private void deleteBatch(UUID id) { Mutation mutation = new Mutation(Keyspace.SYSTEM_KS, UUIDType.instance.decompose(id)); mutation.delete(SystemKeyspace.BATCHLOG_CF, FBUtilities.timestampMicros()); mutation.apply(); }
public static void remove(UUID id) { new Mutation(PartitionUpdate.fullPartitionDelete(SystemKeyspace.Batches, UUIDType.instance.decompose(id), FBUtilities.timestampMicros(), FBUtilities.nowInSeconds())) .apply(); }
public static void remove(UUID id) { new Mutation(PartitionUpdate.fullPartitionDelete(SystemKeyspace.Batches, UUIDType.instance.decompose(id), FBUtilities.timestampMicros(), FBUtilities.nowInSeconds())) .apply(); }
public static void remove(UUID id) { new Mutation(PartitionUpdate.fullPartitionDelete(SystemKeyspace.Batches, UUIDType.instance.decompose(id), FBUtilities.timestampMicros(), FBUtilities.nowInSeconds())) .apply(); }
@VisibleForTesting static Mutation getBatchlogMutationFor(Collection<Mutation> mutations, UUID uuid, int version, long now) { ColumnFamily cf = ArrayBackedSortedColumns.factory.create(CFMetaData.BatchlogCf); CFRowAdder adder = new CFRowAdder(cf, CFMetaData.BatchlogCf.comparator.builder().build(), now); adder.add("data", serializeMutations(mutations, version)) .add("written_at", new Date(now / 1000)) .add("version", version); return new Mutation(Keyspace.SYSTEM_KS, UUIDType.instance.decompose(uuid), cf); }
private static void asyncRemoveFromBatchlog(Collection<InetAddress> endpoints, UUID uuid) { AbstractWriteResponseHandler handler = new WriteResponseHandler(endpoints, Collections.<InetAddress>emptyList(), ConsistencyLevel.ANY, Keyspace.open(Keyspace.SYSTEM_KS), null, WriteType.SIMPLE); Mutation mutation = new Mutation(Keyspace.SYSTEM_KS, UUIDType.instance.decompose(uuid)); mutation.delete(SystemKeyspace.BATCHLOG_CF, FBUtilities.timestampMicros()); MessageOut<Mutation> message = mutation.createMessage(); for (InetAddress target : endpoints) { if (target.equals(FBUtilities.getBroadcastAddress())) insertLocal(message.payload, handler); else MessagingService.instance().sendRR(message, target, handler, false); } }
/** * Returns a mutation representing a Hint to be sent to <code>targetId</code> * as soon as it becomes available again. */ public Mutation hintFor(Mutation mutation, long now, int ttl, Pair<InetAddress, UUID> target) { assert ttl > 0; InetAddress endpoint = target.left; UUID targetId = target.right; metrics.incrCreatedHints(endpoint); UUID hintId = UUIDGen.getTimeUUID(); // serialize the hint with id and version as a composite column name CellName name = CFMetaData.HintsCf.comparator.makeCellName(hintId, MessagingService.current_version); ByteBuffer value = ByteBuffer.wrap(FBUtilities.serialize(mutation, Mutation.serializer, MessagingService.current_version)); ColumnFamily cf = ArrayBackedSortedColumns.factory.create(Schema.instance.getCFMetaData(Keyspace.SYSTEM_KS, SystemKeyspace.HINTS_CF)); cf.addColumn(name, value, now, ttl); return new Mutation(Keyspace.SYSTEM_KS, UUIDType.instance.decompose(targetId), cf); }