int serverPort = getClusterPublicPort(options, server.actualPort()); String serverHost = getClusterPublicHost(options); serverID = new ServerID(serverPort, serverHost); nodeInfo = new ClusterNodeInfo(clusterManager.getNodeID(), serverID); vertx.executeBlocking(fut -> {
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ClusterNodeInfo that = (ClusterNodeInfo) o; if (nodeId != null ? !nodeId.equals(that.nodeId) : that.nodeId != null) return false; return serverID != null ? serverID.equals(that.serverID) : that.serverID == null; }
@Override public int hashCode() { int result = nodeId != null ? nodeId.hashCode() : 0; result = 31 * result + (serverID != null ? serverID.hashCode() : 0); return result; }
@Override public String toString() { return nodeId + ":" + serverID.toString(); } }
@Override public String toString() { return nodeId + ":" + serverID.toString(); } }
this.actualPort = socketAddress.port(); // Will be updated on bind for a wildcard port String hostOrPath = socketAddress.host() != null ? socketAddress.host() : socketAddress.path(); id = new ServerID(actualPort, hostOrPath); NetServerImpl shared = vertx.sharedNetServers().get(id); if (shared == null || actualPort == 0) { // Wildcard port will imply a new actual server each time NetServerImpl.this.actualPort = ((InetSocketAddress)ch.localAddress()).getPort(); NetServerImpl.this.id = new ServerID(NetServerImpl.this.actualPort, id.host); serverChannelGroup.add(ch); vertx.sharedNetServers().put(id, NetServerImpl.this);
private <T> void clusteredSendReply(ServerID replyDest, OutboundDeliveryContext<T> sendContext) { MessageImpl message = sendContext.message; String address = message.address(); if (!replyDest.equals(serverID)) { if (metrics != null) { metrics.messageSent(address, false, false, true); } sendRemote(replyDest, message); } else { if (metrics != null) { metrics.messageSent(address, false, true, false); } deliverMessageLocally(sendContext); } }
@Override public int hashCode() { int result = nodeId != null ? nodeId.hashCode() : 0; result = 31 * result + (serverID != null ? serverID.hashCode() : 0); return result; }
synchronized (vertx.sharedHttpServers()) { this.actualPort = port; // Will be updated on bind for a wildcard port id = new ServerID(port, host); HttpServerImpl shared = vertx.sharedHttpServers().get(id); if (shared == null || port == 0) {
if (sid != null && !sid.equals(serverID)) { //We don't send to this node if (metrics != null) { metrics.messageSent(address, false, false, true); boolean remote = false; for (ClusterNodeInfo ci : subs) { if (!ci.serverID.equals(serverID)) { //We don't send to this node remote = true; sendRemote(ci.serverID, sendContext.message);
pos += headersLength; bodyPos = pos; sender = new ServerID(senderPort, senderHost); wireBuffer = buffer; fromWire = true;
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ClusterNodeInfo that = (ClusterNodeInfo) o; if (nodeId != null ? !nodeId.equals(that.nodeId) : that.nodeId != null) return false; return serverID != null ? serverID.equals(that.serverID) : that.serverID == null; }
@Test public void testMapAddGet() { ServerID serverID1 = new ServerID(1234, "foo.com"); map.add("some-sub", serverID1, onSuccess(res -> { assertNull(res); ServerID serverID2 = new ServerID(4321, "blah.com"); map.add("some-sub", serverID2, onSuccess(res2 -> { assertNull(res2); ServerID serverID3 = new ServerID(5432, "quux.com"); map.add("some-sub2", serverID3, onSuccess(res3 -> { assertNull(res3);
private <T> void clusteredSendReply(ServerID replyDest, OutboundDeliveryContext<T> sendContext) { MessageImpl message = sendContext.message; String address = message.address(); if (!replyDest.equals(serverID)) { if (metrics != null) { metrics.messageSent(address, false, false, true); } sendRemote(replyDest, message); } else { if (metrics != null) { metrics.messageSent(address, false, true, false); } deliverMessageLocally(sendContext); } }
if (sid != null && !sid.equals(serverID)) { //We don't send to this node if (metrics != null) { metrics.messageSent(address, false, false, true); boolean remote = false; for (ClusterNodeInfo ci : subs) { if (!ci.serverID.equals(serverID)) { //We don't send to this node remote = true; sendRemote(ci.serverID, sendContext.message);
@Test public void testMapRemove() { ServerID serverID1 = new ServerID(1234, "foo.com"); map.add("some-sub", serverID1, onSuccess(res -> { assertNull(res); ServerID serverID2 = new ServerID(4321, "blah.com"); map.add("some-sub", serverID2, onSuccess(res2 -> { assertNull(res2); ServerID serverID3 = new ServerID(5432, "quux.com"); map.add("some-sub2", serverID3, onSuccess(res3 -> { assertNull(res3);
int serverPort = getClusterPublicPort(options, server.actualPort()); String serverHost = getClusterPublicHost(options); serverID = new ServerID(serverPort, serverHost); nodeInfo = new ClusterNodeInfo(clusterManager.getNodeID(), serverID); vertx.executeBlocking(fut -> {
this.actualPort = socketAddress.port(); // Will be updated on bind for a wildcard port String hostOrPath = socketAddress.host() != null ? socketAddress.host() : socketAddress.path(); id = new ServerID(actualPort, hostOrPath); NetServerImpl shared = vertx.sharedNetServers().get(id); if (shared == null || actualPort == 0) { // Wildcard port will imply a new actual server each time NetServerImpl.this.actualPort = ((InetSocketAddress)ch.localAddress()).getPort(); NetServerImpl.this.id = new ServerID(NetServerImpl.this.actualPort, id.host); serverChannelGroup.add(ch); vertx.sharedNetServers().put(id, NetServerImpl.this);
pos += headersLength; bodyPos = pos; sender = new ServerID(senderPort, senderHost); wireBuffer = buffer; fromWire = true;