/** * Send a non-mutation message to a given endpoint. This method specifies a callback * which is invoked with the actual response. * * @param message message to be sent. * @param to endpoint to which the message needs to be sent * @param cb callback interface which is used to pass the responses or * suggest that a timeout occurred to the invoker of the send(). * @param timeout the timeout used for expiration * @return an reference to message id used to match with the result */ public int sendRR(MessageOut message, InetAddress to, IAsyncCallback cb, long timeout, boolean failureCallback) { int id = addCallback(cb, message, to, timeout, failureCallback); updateBackPressureOnSend(to, cb, message); sendOneWay(failureCallback ? message.withParameter(FAILURE_CALLBACK_PARAM, ONE_BYTE) : message, id, to); return id; }
/** * Track latency information for the dynamic snitch * * @param cb the callback associated with this message -- this lets us know if it's a message type we're interested in * @param address the host that replied to the message * @param latency */ public void maybeAddLatency(IAsyncCallback cb, InetAddress address, long latency) { if (cb.isLatencyForSnitch()) addLatency(address, latency); }
public static boolean shouldPullSchemaFrom(InetAddress endpoint) { /* * Don't request schema from nodes with a differnt or unknonw major version (may have incompatible schema) * Don't request schema from fat clients */ return MessagingService.instance().knowsVersion(endpoint) && MessagingService.instance().getRawVersion(endpoint) == MessagingService.current_version && !Gossiper.instance.isFatClient(endpoint); }
/** * Removes the endpoint from Gossip but retains endpoint state */ public void removeEndpoint(InetAddress endpoint) { // do subscribers first so anything in the subscriber that depends on gossiper state won't get confused for (IEndpointStateChangeSubscriber subscriber : subscribers) subscriber.onRemove(endpoint); if(seeds.contains(endpoint)) { buildSeedsList(); seeds.remove(endpoint); logger.info("removed {} from seeds, updated seeds list = {}", endpoint, seeds); } liveEndpoints.remove(endpoint); unreachableEndpoints.remove(endpoint); MessagingService.instance().resetVersion(endpoint); quarantineEndpoint(endpoint); MessagingService.instance().destroyConnectionPool(endpoint); if (logger.isDebugEnabled()) logger.debug("removing endpoint {}", endpoint); }
int id = MessagingService.instance().addCallback(handler, message, destination, int id = MessagingService.instance().sendRR(message, target, handler, true); logger.trace("Sending message to {}@{}", id, target);
MessagingService.instance().incrementDroppedMessages(verb, System.currentTimeMillis() - constructionTime); handler.onFailure(FBUtilities.getBroadcastAddress(), RequestFailureReason.UNKNOWN); MessagingService.instance().addLatency(FBUtilities.getBroadcastAddress(), TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start));
/** * called from gossiper when it notices a node is not responding. */ public void convict(InetAddress ep) { logger.trace("Resetting pool for {}", ep); getConnectionPool(ep).reset(); }
private void reconnect(InetAddress publicAddress, InetAddress localAddress) { if (snitch.getDatacenter(publicAddress).equals(localDc) && !MessagingService.instance().getConnectionPool(publicAddress).endPoint().equals(localAddress)) { MessagingService.instance().getConnectionPool(publicAddress).reset(localAddress); logger.debug("Initiated reconnect to an Internal IP {} for the {}", localAddress, publicAddress); } }
if (serializer instanceof MessagingService.CallbackDeterminedSerializer) CallbackInfo callback = MessagingService.instance().getRegisteredCallback(id); if (callback == null)
MessagingService.validateMagic(in.readInt()); int header = in.readInt(); boolean isStream = MessagingService.getBits(header, 3, 1) == 1; int version = MessagingService.getBits(header, 15, 8); logger.debug("Connection version {} from {}", version, socket.getInetAddress()); socket.setSoTimeout(0); : new IncomingTcpConnection(version, MessagingService.getBits(header, 2, 1) == 1, socket, connections); thread.start(); connections.add((Closeable) thread);
protected void runMayThrow() { RangeSliceReply result = new RangeSliceReply(command.executeLocally()); MessagingService.instance().addLatency(FBUtilities.getBroadcastAddress(), TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start)); handler.response(result); } }
/** * Send a non-mutation message to a given endpoint. This method specifies a callback * which is invoked with the actual response. * * @param message message to be sent. * @param to endpoint to which the message needs to be sent * @param cb callback interface which is used to pass the responses or * suggest that a timeout occurred to the invoker of the send(). * @param timeout the timeout used for expiration * @return an reference to message id used to match with the result */ public int sendRR(MessageOut message, InetAddress to, IAsyncCallback cb, long timeout, boolean failureCallback) { int id = addCallback(cb, message, to, timeout, failureCallback); sendOneWay(failureCallback ? message.withParameter(FAILURE_CALLBACK_PARAM, ONE_BYTE) : message, id, to); return id; }
private void logDroppedMessages() { List<String> logs = getDroppedMessagesLogs(); for (String log : logs) logger.info(log); if (logs.size() > 0) StatusLogger.log(); }
/** * Send a message to a given endpoint. This method adheres to the fire and forget * style messaging. * * @param message messages to be sent. * @param to endpoint to which the message needs to be sent */ public void sendOneWay(MessageOut message, int id, InetAddress to) { if (logger.isTraceEnabled()) logger.trace("{} sending {} to {}@{}", FBUtilities.getBroadcastAddress(), message.verb, id, to); if (to.equals(FBUtilities.getBroadcastAddress())) logger.trace("Message-to-self {} going over MessagingService", message); // message sinks are a testing hook for (IMessageSink ms : messageSinks) if (!ms.allowOutgoingMessage(message, id, to)) return; // get pooled connection (really, connection queue) OutboundTcpConnection connection = getConnection(to, message); // write it connection.enqueue(message, id); }
public static boolean shouldPullSchemaFrom(InetAddress endpoint) { /* * Don't request schema from nodes with a differnt or unknonw major version (may have incompatible schema) * Don't request schema from fat clients */ return MessagingService.instance().knowsVersion(endpoint) && is30Compatible(MessagingService.instance().getRawVersion(endpoint)) && !Gossiper.instance.isGossipOnlyMember(endpoint); }
/** * Removes the endpoint from Gossip but retains endpoint state */ public void removeEndpoint(InetAddress endpoint) { // do subscribers first so anything in the subscriber that depends on gossiper state won't get confused for (IEndpointStateChangeSubscriber subscriber : subscribers) subscriber.onRemove(endpoint); if(seeds.contains(endpoint)) { buildSeedsList(); seeds.remove(endpoint); logger.info("removed {} from seeds, updated seeds list = {}", endpoint, seeds); } liveEndpoints.remove(endpoint); unreachableEndpoints.remove(endpoint); MessagingService.instance().resetVersion(endpoint); quarantineEndpoint(endpoint); MessagingService.instance().destroyConnectionPool(endpoint); if (logger.isDebugEnabled()) logger.debug("removing endpoint {}", endpoint); }
int id = MessagingService.instance().addCallback(handler, message, destination, int id = MessagingService.instance().sendRR(message, target, handler, true); logger.trace("Sending message to {}@{}", id, target);
MessagingService.instance().incrementDroppedMessages(verb, System.currentTimeMillis() - constructionTime); handler.onFailure(FBUtilities.getBroadcastAddress(), RequestFailureReason.UNKNOWN); MessagingService.instance().addLatency(FBUtilities.getBroadcastAddress(), TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start));
/** * called from gossiper when it notices a node is not responding. */ public void convict(InetAddress ep) { logger.trace("Resetting pool for {}", ep); getConnectionPool(ep).reset(); }