@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } HostAndPortWithScheme that = (HostAndPortWithScheme) o; if (!scheme.equals(that.scheme)) { return false; } return hostAndPort.equals(that.hostAndPort); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } HostAndPortWithScheme that = (HostAndPortWithScheme) o; if (!scheme.equals(that.scheme)) { return false; } return hostAndPort.equals(that.hostAndPort); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } HostAndPortWithScheme that = (HostAndPortWithScheme) o; if (!scheme.equals(that.scheme)) { return false; } return hostAndPort.equals(that.hostAndPort); }
@Override public boolean apply(HostAndPort input) { return HostAndPort.fromParts("1.2.3.5", 22).equals(input); } };
@Override public boolean apply(HostAndPort input) { return HostAndPort.fromParts(PRIVATE_IP, 22).equals(input); } };
@Override public RecordingSshTool.CustomResponse generate(RecordingSshTool.ExecParams execParams) throws Exception { HostAndPort hap = HostAndPort.fromParts( (String) execParams.constructorProps.get("host"), (Integer) execParams.constructorProps.get("port")); int exitCode = authorisedHostAndPort.equals(hap) ? 0 : 1; return new RecordingSshTool.CustomResponse(exitCode, "", ""); } });
public static Set<String> getPeers(final HostAndPort ignoreHost, boolean wantPort) throws IOException { Configurator peerConfig = ConfigUtil.getConfigInfo(PEER_CONFIG); final Set<String> peers = peerConfig.findEntriesAsSet("RENDEZVOUS_PEER"); final Set<String> added = new TreeSet<>(); peers.forEach(peerString -> { // form peer config files HostAndPort peer = HostAndPort.fromString(KeyManipulator.getServiceHost(peerString)); if ((ignoreHost.hasPort() && !ignoreHost.equals(peer)) || !ignoreHost.getHostText().equals(peer.getHostText())) { if (wantPort) { added.add(peer.toString()); } else { added.add(peer.getHostText()); } } }); return added; } }
public void startCluster() throws IOException, InterruptedException { // The first node X of the cluster calls .start(), the rest call .join(X) if (listenAddress.equals(seedAddress)) { cluster = new Cluster.Builder(listenAddress) .start(); } else { cluster = new Cluster.Builder(listenAddress) .join(seedAddress); } cluster.registerSubscription(com.vrg.rapid.ClusterEvents.VIEW_CHANGE_PROPOSAL, this::onViewChangeProposal); cluster.registerSubscription(com.vrg.rapid.ClusterEvents.VIEW_CHANGE, this::onViewChange); cluster.registerSubscription(com.vrg.rapid.ClusterEvents.KICKED, this::onKicked); }
@Override public void startCluster() throws IOException, InterruptedException { final Endpoint endpoint = Endpoint.newBuilder() .setHostname(listenAddress.getHost()) .setPort(listenAddress.getPort()).build(); // To use your own messaging implementation with Rapid, supply an instance each of IMessagingClient // and IMessagingServer to Cluster.Builder.setMessagingClientServer(). // // In this example, we use an object NettyClientServer which implements both the IMessagingClient // and IMessagingServer interfaces. final NettyClientServer nettyMessaging = new NettyClientServer(endpoint); if (listenAddress.equals(seedAddress)) { cluster = new Cluster.Builder(listenAddress) .setMessagingClientAndServer(nettyMessaging, nettyMessaging) .start(); } else { cluster = new Cluster.Builder(listenAddress) .setMessagingClientAndServer(nettyMessaging, nettyMessaging) .join(seedAddress); } cluster.registerSubscription(com.vrg.rapid.ClusterEvents.VIEW_CHANGE_PROPOSAL, this::onViewChangeProposal); cluster.registerSubscription(com.vrg.rapid.ClusterEvents.VIEW_CHANGE, this::onViewChange); cluster.registerSubscription(com.vrg.rapid.ClusterEvents.KICKED, this::onKicked); }