private static void syncWriteToBatchlog(Collection<Mutation> mutations, BatchlogEndpoints endpoints, UUID uuid, long queryStartNanoTime) throws WriteTimeoutException, WriteFailureException { WriteResponseHandler<?> handler = new WriteResponseHandler<>(endpoints.all, Collections.<InetAddress>emptyList(), endpoints.all.size() == 1 ? ConsistencyLevel.ONE : ConsistencyLevel.TWO, Keyspace.open(SchemaConstants.SYSTEM_KEYSPACE_NAME), null, WriteType.BATCH_LOG, queryStartNanoTime); Batch batch = Batch.createLocal(uuid, FBUtilities.timestampMicros(), mutations); if (!endpoints.current.isEmpty()) syncWriteToBatchlog(handler, batch, endpoints.current); if (!endpoints.legacy.isEmpty()) LegacyBatchlogMigrator.syncWriteToBatchlog(handler, batch, endpoints.legacy); handler.get(); }
private static void syncWriteToBatchlog(Collection<Mutation> mutations, BatchlogEndpoints endpoints, UUID uuid, long queryStartNanoTime) throws WriteTimeoutException, WriteFailureException { WriteResponseHandler<?> handler = new WriteResponseHandler<>(endpoints.all, Collections.<InetAddress>emptyList(), endpoints.all.size() == 1 ? ConsistencyLevel.ONE : ConsistencyLevel.TWO, Keyspace.open(SchemaConstants.SYSTEM_KEYSPACE_NAME), null, WriteType.BATCH_LOG, queryStartNanoTime); Batch batch = Batch.createLocal(uuid, FBUtilities.timestampMicros(), mutations); if (!endpoints.current.isEmpty()) syncWriteToBatchlog(handler, batch, endpoints.current); if (!endpoints.legacy.isEmpty()) LegacyBatchlogMigrator.syncWriteToBatchlog(handler, batch, endpoints.legacy); handler.get(); }
private static void syncWriteToBatchlog(Collection<Mutation> mutations, BatchlogEndpoints endpoints, UUID uuid, long queryStartNanoTime) throws WriteTimeoutException, WriteFailureException { WriteResponseHandler<?> handler = new WriteResponseHandler<>(endpoints.all, Collections.<InetAddress>emptyList(), endpoints.all.size() == 1 ? ConsistencyLevel.ONE : ConsistencyLevel.TWO, Keyspace.open(SchemaConstants.SYSTEM_KEYSPACE_NAME), null, WriteType.BATCH_LOG, queryStartNanoTime); Batch batch = Batch.createLocal(uuid, FBUtilities.timestampMicros(), mutations); if (!endpoints.current.isEmpty()) syncWriteToBatchlog(handler, batch, endpoints.current); if (!endpoints.legacy.isEmpty()) LegacyBatchlogMigrator.syncWriteToBatchlog(handler, batch, endpoints.legacy); handler.get(); }
public Batch deserialize(DataInputPlus in, int version) throws IOException { UUID id = UUIDSerializer.serializer.deserialize(in, version); long creationTime = in.readLong(); /* * If version doesn't match the current one, we cannot not just read the encoded mutations verbatim, * so we decode them instead, to deal with compatibility. */ return version == MessagingService.current_version ? createRemote(id, creationTime, readEncodedMutations(in)) : createLocal(id, creationTime, decodeMutations(in, version)); }
public Batch deserialize(DataInputPlus in, int version) throws IOException { UUID id = UUIDSerializer.serializer.deserialize(in, version); long creationTime = in.readLong(); /* * If version doesn't match the current one, we cannot not just read the encoded mutations verbatim, * so we decode them instead, to deal with compatibility. */ return version == MessagingService.current_version ? createRemote(id, creationTime, readEncodedMutations(in)) : createLocal(id, creationTime, decodeMutations(in, version)); }
public Batch deserialize(DataInputPlus in, int version) throws IOException { UUID id = UUIDSerializer.serializer.deserialize(in, version); long creationTime = in.readLong(); /* * If version doesn't match the current one, we cannot not just read the encoded mutations verbatim, * so we decode them instead, to deal with compatibility. */ return version == MessagingService.current_version ? createRemote(id, creationTime, readEncodedMutations(in)) : createLocal(id, creationTime, decodeMutations(in, version)); }
private static boolean apply(UntypedResultSet.Row row, long counter) { UUID id = row.getUUID("id"); long timestamp = id.version() == 1 ? UUIDGen.unixTimestamp(id) : row.getLong("written_at"); int version = row.has("version") ? row.getInt("version") : MessagingService.VERSION_12; if (id.version() != 1) id = UUIDGen.getTimeUUID(timestamp, counter); logger.trace("Converting mutation at {}", timestamp); try (DataInputBuffer in = new DataInputBuffer(row.getBytes("data"), false)) { int numMutations = in.readInt(); List<Mutation> mutations = new ArrayList<>(numMutations); for (int i = 0; i < numMutations; i++) mutations.add(Mutation.serializer.deserialize(in, version)); BatchlogManager.store(Batch.createLocal(id, TimeUnit.MILLISECONDS.toMicros(timestamp), mutations)); return true; } catch (Throwable t) { logger.error("Failed to convert mutation {} at timestamp {}", id, timestamp, t); return false; } }
private static boolean apply(UntypedResultSet.Row row, long counter) { UUID id = row.getUUID("id"); long timestamp = id.version() == 1 ? UUIDGen.unixTimestamp(id) : row.getLong("written_at"); int version = row.has("version") ? row.getInt("version") : MessagingService.VERSION_12; if (id.version() != 1) id = UUIDGen.getTimeUUID(timestamp, counter); logger.trace("Converting mutation at {}", timestamp); try (DataInputBuffer in = new DataInputBuffer(row.getBytes("data"), false)) { int numMutations = in.readInt(); List<Mutation> mutations = new ArrayList<>(numMutations); for (int i = 0; i < numMutations; i++) mutations.add(Mutation.serializer.deserialize(in, version)); BatchlogManager.store(Batch.createLocal(id, TimeUnit.MILLISECONDS.toMicros(timestamp), mutations)); return true; } catch (Throwable t) { logger.error("Failed to convert mutation {} at timestamp {}", id, timestamp, t); return false; } }
private static boolean apply(UntypedResultSet.Row row, long counter) { UUID id = row.getUUID("id"); long timestamp = id.version() == 1 ? UUIDGen.unixTimestamp(id) : row.getLong("written_at"); int version = row.has("version") ? row.getInt("version") : MessagingService.VERSION_12; if (id.version() != 1) id = UUIDGen.getTimeUUID(timestamp, counter); logger.trace("Converting mutation at {}", timestamp); try (DataInputBuffer in = new DataInputBuffer(row.getBytes("data"), false)) { int numMutations = in.readInt(); List<Mutation> mutations = new ArrayList<>(numMutations); for (int i = 0; i < numMutations; i++) mutations.add(Mutation.serializer.deserialize(in, version)); BatchlogManager.store(Batch.createLocal(id, TimeUnit.MILLISECONDS.toMicros(timestamp), mutations)); return true; } catch (Throwable t) { logger.error("Failed to convert mutation {} at timestamp {}", id, timestamp, t); return false; } }
BatchlogManager.store(Batch.createLocal(batchUUID, FBUtilities.timestampMicros(), mutations), writeCommitLog); BatchlogManager.store(Batch.createLocal(batchUUID, FBUtilities.timestampMicros(), nonLocalMutations), writeCommitLog);
BatchlogManager.store(Batch.createLocal(batchUUID, FBUtilities.timestampMicros(), mutations), writeCommitLog); BatchlogManager.store(Batch.createLocal(batchUUID, FBUtilities.timestampMicros(), nonLocalMutations), writeCommitLog);
BatchlogManager.store(Batch.createLocal(batchUUID, FBUtilities.timestampMicros(), mutations), writeCommitLog); BatchlogManager.store(Batch.createLocal(batchUUID, FBUtilities.timestampMicros(), nonLocalMutations), writeCommitLog);