assertEquals(client1.getPartitionWeight(1), 2d);
// Get client, then refresh cluster
TrackerClient client = _state.getClient("service-1", uri);
client.restRequest(new RestRequestBuilder(URI.create("d2://service-1/foo")).build(),
new RequestContext(),
Collections.<String, String>emptyMap(),
new TransportCallbackAdapter<RestResponse>(Callbacks.<RestResponse>empty()));
// now force a refresh by adding cluster
_clusterRegistry.put("cluster-1", new ClusterProperties("cluster-1"));
// Get client, then refresh service
client = _state.getClient("service-1", uri);
client.restRequest(new RestRequestBuilder(URI.create("d2://service-1/foo")).build(),
new RequestContext(),
Collections.<String, String>emptyMap(),
new TransportCallbackAdapter<RestResponse>(Callbacks.<RestResponse>empty()));
// refresh by adding service
_serviceRegistry.put("service-1", new ServiceProperties("service-1",
"cluster-1",
"/test",
"random",
Collections.<String>emptyList(),
Collections.<String, Object>emptyMap(),
null,
null,
schemes,
null));
// Get client, then mark server up/down
client = _state.getClient("service-1", uri);
client.restRequest(new RestRequestBuilder(URI.create("d2://service-1/foo")).build(),
new RequestContext(),
Collections.<String, String>emptyMap(),
new TransportCallbackAdapter<RestResponse>(Callbacks.<RestResponse>empty()));
_uriRegistry.put("cluster-1", new UriProperties("cluster-1", Collections.<URI, Map<Integer, PartitionData>>emptyMap()));
_uriRegistry.put("cluster-1", new UriProperties("cluster-1", uriData));
// Get the client one last time
client = _state.getClient("service-1", uri);
client.restRequest(new RestRequestBuilder(URI.create("d2://service-1/foo")).build(),
new RequestContext(),
Collections.<String, String>emptyMap(),
new TransportCallbackAdapter<RestResponse>(Callbacks.<RestResponse>empty()));