Package com.linkedin.r2.message

Examples of com.linkedin.r2.message.RequestContext


    FindRequestBuilder<Long, Greeting> findRB = new FindRequestBuilder<Long, Greeting>(TEST_URI,
                                                                                       Greeting.class,
                                                                                       _COLL_SPEC,
                                                                                       options);
    Collection<RequestContext> requestContexts =
        (searchRB.buildRequestContexts(findRB.fields(Greeting.fields().message()).build(), new RequestContext())).getPartitionInfo();

    Assert.assertEquals(PARTITION_NUM, requestContexts.size());

    Set<String> expectedHostPrefixes = new HashSet<String>();
    for (int i = 0; i < PARTITION_NUM; i++)
View Full Code Here


        }
        latch.countDown();
      }
    };

    searchRB.sendRequests(REST_CLIENT, request, new RequestContext(), cb);
    latch.await();
    if (!errors.isEmpty())
    {
      Assert.fail("I knew it: " + errors.toString());
    }
View Full Code Here

      // N.B. since QueryParamMockCollection is implemented using the synchronous rest.li interface,
      // RestLiServer.handleRequest() will invoke the application resource *and* the callback
      // *synchronously*, ensuring that the all instances of the callback are invoked before the
      // loop terminates.
      server.handleRequest(restRequest, new RequestContext(), new Callback<RestResponse>()
      {
        @Override
        public void onError(Throwable e)
        {
          Assert.fail();
View Full Code Here

  private void executeRequestThroughParseqDebugHandler(URI uri, Callback<RestResponse> callback)
  {
    ParseqTraceDebugRequestHandler requestHandler = new ParseqTraceDebugRequestHandler();
    RestRequestBuilder requestBuilder = new RestRequestBuilder(uri);
    RestRequest request = requestBuilder.build();
    RequestContext requestContext = new RequestContext();

    requestHandler.handleRequest(request,
                                  requestContext,
                                  new RestLiDebugRequestHandler.ResourceDebugRequestHandler()
                                  {
View Full Code Here

    // create the load balancer
    SimpleLoadBalancer loadBalancer = new SimpleLoadBalancer(state);

    final TransportClient tc = loadBalancer.getClient(new URIRequest("d2://browsemaps/52"),
                                                      new RequestContext());
    final Client c = new TransportClientAdapter(tc);
    c.restRequest(null);
  }
View Full Code Here

    properties.put("test", "exists");

    assertEquals(factory.getClientCount, 0);
    assertNull(factory.properties);

    client.restRequest(null, new RequestContext(), null, null);

    assertEquals(factory.getClientCount, 1);
    assertEquals(factory.properties, properties);

    client.restRequest(null, new RequestContext(), null, null);
    client.rpcRequest(null, new RequestContext(), null, null);

    assertEquals(factory.getClientCount, 1);
    assertEquals(factory.restRequestCount, 2);
    assertEquals(factory.rpcRequestCount, 1);
    assertEquals(factory.shutdownCount, 0);
View Full Code Here


    // 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()));


View Full Code Here

      TransportClient trackerClient;
      int badCall = 0;
      for (int i = 0; i < 100; i++)
      {
        trackerClient = _myState.getStrategy("service-1", "http").
                getTrackerClient(null, new RequestContext(), 0, DefaultPartitionAccessor.DEFAULT_PARTITION_ID, _tcList);
        if (trackerClient == null)
        {
          badCall++;
        }
      }
View Full Code Here

    RestRequest restRequest = new RestRequestBuilder(uri).build();
    Map<String, String> restWireAttrs = new HashMap<String, String>();
    TestTransportCallback<RestResponse> restCallback =
        new TestTransportCallback<RestResponse>();

    client.restRequest(restRequest, new RequestContext(), restWireAttrs, restCallback);

    assertFalse(restCallback.response.hasError());
    assertEquals(wrappedClient.restRequest, restRequest);
    assertEquals(wrappedClient.restWireAttrs, restWireAttrs);

    RpcRequest rpcRequest = new RpcRequestBuilder(uri).build();
    Map<String, String> rpcWireAttrs = new HashMap<String, String>();
    TestTransportCallback<RpcResponse> rpcCallback =
        new TestTransportCallback<RpcResponse>();

    client.rpcRequest(rpcRequest, new RequestContext(), rpcWireAttrs, rpcCallback);

    assertTrue(rpcCallback.response.hasError());
    assertEquals(wrappedClient.rpcRequest, rpcRequest);
    assertEquals(wrappedClient.rpcWireAttrs, rpcWireAttrs);
    assertEquals(client.getCallTracker().getCurrentErrorCountTotal(), 1);
View Full Code Here

    RestRequest restRequest = new RestRequestBuilder(URI.create("d2://HistoryService/getCube")).build();
    Map<String, String> restWireAttrs = new HashMap<String, String>();
    TestTransportCallback<RestResponse> restCallback =
        new TestTransportCallback<RestResponse>();

    client.restRequest(restRequest, new RequestContext(), restWireAttrs, restCallback);

    assertFalse(restCallback.response.hasError());
    assertEquals(wrappedClient.restRequest.getHeaders(), restRequest.getHeaders());
    assertEquals(wrappedClient.restRequest.getEntity(), restRequest.getEntity());
    assertEquals(wrappedClient.restRequest.getMethod(), restRequest.getMethod());

    // check the rewrite
    assertEquals(wrappedClient.restRequest.getURI(),
                 URI.create("http://test.linkedin.com/test/getCube"));
    assertEquals(wrappedClient.restWireAttrs, restWireAttrs);

    RpcRequest rpcRequest = new RpcRequestBuilder(URI.create("d2://HistoryService/getCube")).build();
    Map<String, String> rpcWireAttrs = new HashMap<String, String>();
    TestTransportCallback<RpcResponse> rpcCallback =
        new TestTransportCallback<RpcResponse>();

    client.rpcRequest(rpcRequest, new RequestContext(), rpcWireAttrs, rpcCallback);

    assertTrue(rpcCallback.response.hasError());
    assertEquals(wrappedClient.rpcRequest.getURI(),
                 URI.create("http://test.linkedin.com/test/getCube"));
    assertEquals(wrappedClient.rpcRequest.getEntity(), rpcRequest.getEntity());
View Full Code Here

TOP

Related Classes of com.linkedin.r2.message.RequestContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.