public MessageOut<T> withParameter(String key, byte[] value) { ImmutableMap.Builder<String, byte[]> builder = ImmutableMap.builder(); builder.putAll(parameters).put(key, value); return new MessageOut<T>(verb, payload, serializer, builder.build()); }
public MessageOut<ReadCommand> createMessage(int version) { return dataRange().isPaging() ? new MessageOut<>(MessagingService.Verb.PAGED_RANGE, this, pagedRangeSerializer) : new MessageOut<>(MessagingService.Verb.RANGE_SLICE, this, rangeSliceSerializer); }
public MessageOut<ReadCommand> createMessage(int version) { return dataRange().isPaging() ? new MessageOut<>(MessagingService.Verb.PAGED_RANGE, this, pagedRangeSerializer) : new MessageOut<>(MessagingService.Verb.RANGE_SLICE, this, rangeSliceSerializer); }
public void doVerb(MessageIn<EchoMessage> message, int id) { MessageOut<EchoMessage> echoMessage = new MessageOut<EchoMessage>(MessagingService.Verb.REQUEST_RESPONSE, EchoMessage.instance, EchoMessage.serializer); logger.trace("Sending a EchoMessage reply {}", message.from); MessagingService.instance().sendReply(echoMessage, id, message.from); } }
public void doVerb(MessageIn<EchoMessage> message, int id) { MessageOut<EchoMessage> echoMessage = new MessageOut<EchoMessage>(MessagingService.Verb.REQUEST_RESPONSE, EchoMessage.instance, EchoMessage.serializer); logger.trace("Sending a EchoMessage reply {}", message.from); MessagingService.instance().sendReply(echoMessage, id, message.from); } }
@Override public void run() { MessagingService.instance().sendReply(new MessageOut(MessagingService.Verb.INTERNAL_RESPONSE), id, message.from); } }, MoreExecutors.directExecutor());
/** * Unlike commitPaxos, this does not wait for replies */ private static void sendCommit(Commit commit, Iterable<InetAddress> replicas) { MessageOut<Commit> message = new MessageOut<Commit>(MessagingService.Verb.PAXOS_COMMIT, commit, Commit.serializer); for (InetAddress target : replicas) MessagingService.instance().sendOneWay(message, target); }
public void doVerb(MessageIn msg, int id) { StorageService.instance.confirmReplication(msg.from); MessageOut response = new MessageOut(MessagingService.Verb.INTERNAL_RESPONSE); if (logger.isDebugEnabled()) logger.debug("Replying to {}@{}", id, msg.from); MessagingService.instance().sendReply(response, id, msg.from); } }
@Override public void run() { MessagingService.instance().sendReply(new MessageOut(MessagingService.Verb.INTERNAL_RESPONSE), id, message.from); } }, MoreExecutors.directExecutor());
private static void pushSchemaMutation(InetAddress endpoint, Collection<Mutation> schema) { MessageOut<Collection<Mutation>> msg = new MessageOut<>(MessagingService.Verb.DEFINITIONS_UPDATE, schema, MigrationsSerializer.instance); MessagingService.instance().sendOneWay(msg, endpoint); }
/** * Unlike commitPaxos, this does not wait for replies */ private static void sendCommit(Commit commit, Iterable<InetAddress> replicas) { MessageOut<Commit> message = new MessageOut<Commit>(MessagingService.Verb.PAXOS_COMMIT, commit, Commit.serializer); for (InetAddress target : replicas) MessagingService.instance().sendOneWay(message, target); }
private static void pushSchemaMutation(InetAddress endpoint, Collection<Mutation> schema) { MessageOut<Collection<Mutation>> msg = new MessageOut<>(MessagingService.Verb.DEFINITIONS_UPDATE, schema, MigrationsSerializer.instance); MessagingService.instance().sendOneWay(msg, endpoint); }
public void doVerb(MessageIn message, int id) { logger.trace("Received migration request from {}.", message.from); MessageOut<Collection<Mutation>> response = new MessageOut<>(MessagingService.Verb.INTERNAL_RESPONSE, SchemaKeyspace.convertSchemaToMutations(), MigrationManager.MigrationsSerializer.instance); MessagingService.instance().sendReply(response, id, message.from); } }
private void logErrorAndSendFailureResponse(String errorMessage, InetAddress to, int id) { logger.error(errorMessage); MessageOut reply = new MessageOut(MessagingService.Verb.INTERNAL_RESPONSE) .withParameter(MessagingService.FAILURE_RESPONSE_PARAM, MessagingService.ONE_BYTE); MessagingService.instance().sendReply(reply, id, to); } }
public void doVerb(MessageIn message, int id) { logger.trace("Received migration request from {}.", message.from); MessageOut<Collection<Mutation>> response = new MessageOut<>(MessagingService.Verb.INTERNAL_RESPONSE, SchemaKeyspace.convertSchemaToMutations(), MigrationManager.MigrationsSerializer.instance); MessagingService.instance().sendReply(response, id, message.from); } }
public void doVerb(MessageIn<Commit> message, int id) { PrepareResponse response = PaxosState.prepare(message.payload); MessageOut<PrepareResponse> reply = new MessageOut<PrepareResponse>(MessagingService.Verb.REQUEST_RESPONSE, response, PrepareResponse.serializer); MessagingService.instance().sendReply(reply, id, message.from); } }
public void doVerb(MessageIn<Commit> message, int id) { PrepareResponse response = PaxosState.prepare(message.payload); MessageOut<PrepareResponse> reply = new MessageOut<PrepareResponse>(MessagingService.Verb.REQUEST_RESPONSE, response, PrepareResponse.serializer); MessagingService.instance().sendReply(reply, id, message.from); } }
public void doVerb(MessageIn<Commit> message, int id) { Boolean response = PaxosState.propose(message.payload); MessageOut<Boolean> reply = new MessageOut<Boolean>(MessagingService.Verb.REQUEST_RESPONSE, response, BooleanSerializer.serializer); MessagingService.instance().sendReply(reply, id, message.from); } }
public MessageOut<T> withParameter(String key, byte[] value) { ImmutableMap.Builder<String, byte[]> builder = ImmutableMap.builder(); builder.putAll(parameters).put(key, value); return new MessageOut<T>(verb, payload, serializer, builder.build()); }
private static PrepareCallback preparePaxos(Commit toPrepare, List<InetAddress> endpoints, int requiredParticipants, ConsistencyLevel consistencyForPaxos, long queryStartNanoTime) throws WriteTimeoutException { PrepareCallback callback = new PrepareCallback(toPrepare.update.partitionKey(), toPrepare.update.metadata(), requiredParticipants, consistencyForPaxos, queryStartNanoTime); MessageOut<Commit> message = new MessageOut<Commit>(MessagingService.Verb.PAXOS_PREPARE, toPrepare, Commit.serializer); for (InetAddress target : endpoints) MessagingService.instance().sendRR(message, target, callback); callback.await(); return callback; }