OutboundTcpConnectionPool(InetAddress remoteEp, BackPressureState backPressureState) { id = remoteEp; resetEndpoint = SystemKeyspace.getPreferredIP(remoteEp); started = new CountDownLatch(1); smallMessages = new OutboundTcpConnection(this, "Small"); largeMessages = new OutboundTcpConnection(this, "Large"); gossipMessages = new OutboundTcpConnection(this, "Gossip"); this.backPressureState = backPressureState; }
void reset() { for (OutboundTcpConnection conn : new OutboundTcpConnection[] { smallMessages, largeMessages, gossipMessages }) conn.closeSocket(false); }
void softCloseSocket() { enqueue(CLOSE_SENTINEL, -1); }
public void resetToNewerVersion(int version) { for (OutboundTcpConnection conn : new OutboundTcpConnection[] { smallMessages, largeMessages, gossipMessages }) { if (version > conn.getTargetVersion()) conn.softCloseSocket(); } }
if (isLocalDC(poolReference.endPoint())) writeHeader(out, targetVersion, shouldCompressConnection()); out.flush(); int maxTargetVersion = handshakeVersion(in); if (maxTargetVersion == NO_VERSION) disconnect(); continue; disconnect(); return false; softCloseSocket(); if (shouldCompressConnection()) disconnect(); disconnect(); logger.debug("Unable to connect to {}", poolReference.endPoint(), e); Uninterruptibles.sleepUninterruptibly(OPEN_RETRY_DELAY, TimeUnit.MILLISECONDS);
if (m == CLOSE_SENTINEL) disconnect(); if (isStopped) break outer; else if (socket != null || connect()) writeConnected(qm, count == 1 && backlog.isEmpty()); else
public Long getValue() { return connectionPool.largeMessages.getDroppedMessages(); } });
public Long getValue() { return connectionPool.largeMessages.getCompletedMesssages(); } });
public Integer getValue() { return connectionPool.smallMessages.getPendingMessages(); } });
writeInternal(qm.message, qm.id, timestampMillis); disconnect(); if (e instanceof IOException)
public void enqueue(MessageOut<?> message, int id) { long nanoTime = System.nanoTime(); expireMessages(nanoTime); try { backlog.put(new QueuedMessage(message, id, nanoTime)); } catch (InterruptedException e) { throw new AssertionError(e); } }
/** * returns the appropriate connection based on message type. * returns null if a connection could not be established. */ OutboundTcpConnection getConnection(MessageOut msg) { if (Stage.GOSSIP == msg.getStage()) return gossipMessages; return msg.payloadSize(smallMessages.getTargetVersion()) > LARGE_MESSAGE_THRESHOLD ? largeMessages : smallMessages; }
if (isLocalDC(poolReference.endPoint())) writeHeader(out, targetVersion, shouldCompressConnection()); out.flush(); int maxTargetVersion = handshakeVersion(in); if (maxTargetVersion == NO_VERSION) if (DatabaseDescriptor.getSeeds().contains(poolReference.endPoint())) logger.warn("Seed gossip version is {}; will not connect with that version", maxTargetVersion); disconnect(); continue; disconnect(); return false; softCloseSocket(); if (shouldCompressConnection())
if (m == CLOSE_SENTINEL) disconnect(); if (isStopped) break outer; else if (socket != null || connect()) writeConnected(qm, count == 1 && backlog.isEmpty()); else
public Long getValue() { return connectionPool.smallMessages.getDroppedMessages(); } });
public Long getValue() { return connectionPool.smallMessages.getCompletedMesssages(); } });
public Integer getValue() { return connectionPool.largeMessages.getPendingMessages(); } });
public void resetToNewerVersion(int version) { for (OutboundTcpConnection conn : new OutboundTcpConnection[] { smallMessages, largeMessages, gossipMessages }) { if (version > conn.getTargetVersion()) conn.softCloseSocket(); } }
writeInternal(qm.message, qm.id, timestampMillis); disconnect(); if (e instanceof IOException || e.getCause() instanceof IOException)
public void enqueue(MessageOut<?> message, int id) { long nanoTime = System.nanoTime(); expireMessages(nanoTime); try { backlog.put(new QueuedMessage(message, id, nanoTime)); } catch (InterruptedException e) { throw new AssertionError(e); } }