@Test public void recognizeSelfInPeerNodesByPublicUri() throws Throwable { String id = "node-" + VerificationHost.hostNumber.incrementAndGet(); String publicUri = "http: ExampleServiceHost nodeA = new ExampleServiceHost() { @Override public List<URI> getInitialPeerHosts() { try { Field field = ServiceHost.class.getDeclaredField("state"); field.setAccessible(true); ServiceHostState s = (ServiceHostState) field.get(this); s.initialPeerNodes = new String[] { publicUri + getPort() }; s.publicUri = URI.create(publicUri + getPort()); } catch (Exception e) { throw new RuntimeException(e); } return super.getInitialPeerHosts(); } }; TemporaryFolder tmpFolderA = new TemporaryFolder(); tmpFolderA.create(); try { String[] args = { "--port=0", "--id=" + id, "--publicUri=" + publicUri, "--bindAddress=127.0.0.1", "--sandbox=" + tmpFolderA.getRoot().getAbsolutePath() }; nodeA.initialize(args); nodeA.setMaintenanceIntervalMicros(TimeUnit.MILLISECONDS .toMicros(VerificationHost.FAST_MAINT_INTERVAL_MILLIS)); nodeA.start(); URI nodeGroupUri = UriUtils.buildUri(nodeA, ServiceUriPaths.DEFAULT_NODE_GROUP, null); TestRequestSender sender = new TestRequestSender(nodeA); Operation op = Operation.createGet(nodeGroupUri) .setReferer(nodeA.getUri()); NodeGroupState nodeGroupState = sender.sendAndWait(op, NodeGroupState.class); assertEquals(1, nodeGroupState.nodes.size()); assertEquals(1, nodeGroupState.nodes.values().iterator().next().membershipQuorum); } finally { tmpFolderA.delete(); nodeA.stop(); } }
@Override public URI getUri() { if (this.uri == null) { this.uri = super.getUri(); } return this.uri; }
NodeGroupService extends StatefulService { @Override public URI getUri() { if (this.uri == null) { this.uri = super.getUri(); } return this.uri; } }
NodeGroupService extends StatefulService { @Override public URI getUri() { if (this.uri == null) { this.uri = super.getUri(); } return this.uri; } NodeGroupService(); }
NodeGroupService extends StatefulService { @Override public URI getUri() { if (this.uri == null) { this.uri = super.getUri(); } return this.uri; } NodeGroupService(); @Override URI getUri(); @Override void handleStart(Operation startPost); @Override void handleGet(Operation get); @Override void handlePatch(Operation patch); @Override void handlePost(Operation post); @Override void handleMaintenance(Operation maint); void handleGossipPatchCompletion(long sendTimeMicros, Operation maint, Operation patch,
            Throwable e,
            NodeGroupState localState, NodeGroupState patchBody, AtomicInteger remaining,
            NodeState remotePeer); }
NodeGroupService extends StatefulService { @Override public URI getUri() { if (this.uri == null) { this.uri = super.getUri(); } return this.uri; } NodeGroupService(); @Override URI getUri(); @Override void handleStart(Operation startPost); @Override void handleGet(Operation get); @Override void handlePatch(Operation patch); @Override void handlePost(Operation post); @Override void handleMaintenance(Operation maint); void handleGossipPatchCompletion(long sendTimeMicros, Operation maint, Operation patch,
            Throwable e,
            NodeGroupState localState, NodeGroupState patchBody, AtomicInteger remaining,
            NodeState remotePeer); static final String STAT_NAME_JOIN_RETRY_COUNT; static final String STAT_NAME_REMOTE_FALSE_UNAVAILABLE_COUNT; static final String PROPERTY_NAME_PEER_REQUEST_TIMEOUT_MICROS; static final long PEER_REQUEST_TIMEOUT_MICROS; static final int MIN_PEER_GOSSIP_COUNT; static final String STAT_NAME_RESTARTING_SERVICES_COUNT; static final String STAT_NAME_RESTARTING_SERVICES_FAILURE_COUNT; static final String STAT_NAME_PREFIX_GOSSIP_PATCH_DURATION; }