org.apache.zookeeper.client.StaticHostProvider Java Examples

The following examples show how to use org.apache.zookeeper.client.StaticHostProvider. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ClientCnxnInterceptorTest.java    From skywalking with Apache License 2.0 5 votes vote down vote up
@Test
public void testInterceptor() throws Throwable {
    InetSocketAddress address = new InetSocketAddress("localhost", 2800);
    List<InetSocketAddress> serverAddresses = new ArrayList<InetSocketAddress>();
    serverAddresses.add(address);
    StaticHostProvider provider = new StaticHostProvider(serverAddresses);
    interceptor.onConstruct(instance, new Object[] {
        null,
        provider
    });
    RequestHeader header = new RequestHeader(1, 1);
    CreateRequest createRequest = new CreateRequest("/path", null, null, 0);
    interceptor.beforeMethod(instance, null, new Object[] {
        header,
        null,
        createRequest
    }, null, null);
    interceptor.afterMethod(instance, null, null, null, null);
    MatcherAssert.assertThat((String) instance.getSkyWalkingDynamicField(), Is.is("localhost:2800;"));
    TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
    List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
    assertThat(spans.size(), is(1));
    assertThat(spans.get(0).getOperationName(), is("Zookeeper/create"));
    assertThat(spans.get(0).isExit(), is(true));
    assertThat(SpanHelper.getComponentId(spans.get(0)), is(58));
    List<TagValuePair> tags = SpanHelper.getTags(spans.get(0));
    assertThat(tags.get(0).getValue(), is("Zookeeper"));
    assertThat(SpanHelper.getLayer(spans.get(0)), CoreMatchers.is(SpanLayer.CACHE));
}