Package com.linkedin.r2.sample.echo.rest

Examples of com.linkedin.r2.sample.echo.rest.RestEchoServer


                                           QueryParamMockCollection.DummyRecord.class,
                                           Collections.<String, CompoundKey.TypeInfo> emptyMap()),
                      RestliRequestOptions.DEFAULT_OPTIONS)
                      .id("dummy")
                      .setParam(QueryParamMockCollection.VALUE_KEY, testValue).build();
      RestRequest restRequest = new RestRequestBuilder(RestliUriBuilderUtil.createUriBuilder(req).build())
              .setMethod(req.getMethod().getHttpMethod().toString()).build();

      // 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
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

            RestRequest request = rb.build();
            Future<RestResponse> f = client.restRequest(request);

            // This will block
            RestResponse response = f.get();
            final ByteString entity = response.getEntity();
            if(entity == null) {
                if(logger.isDebugEnabled()) {
                    logger.debug("Empty response !");
                }
            }
View Full Code Here

                                                + base64Key));
            String timeoutStr = Long.toString(this.config.getTimeoutConfig()
                                                         .getOperationTimeout(VoldemortOpCode.GET_OP_CODE));
            rb.setHeader("Accept", MULTIPART_CONTENT_TYPE);

            RestResponse response = fetchGetResponse(rb, timeoutStr);
            final ByteString entity = response.getEntity();
            if(entity != null) {
                resultList = parseGetResponse(entity);
            } else {
                if(logger.isDebugEnabled()) {
                    logger.debug("Did not get any response!");
View Full Code Here

            }
            if(this.zoneId != INVALID_ZONE_ID) {
                rb.setHeader(RestMessageHeaders.X_VOLD_ZONE_ID, String.valueOf(this.zoneId));
            }

            RestResponse response = fetchGetResponse(rb, FETCH_SCHEMA_TIMEOUT_MS);
            return response.getEntity().asString("UTF-8");
        } catch(ExecutionException e) {
            if(e.getCause() instanceof RestException) {
                RestException exception = (RestException) e.getCause();
                if(logger.isDebugEnabled()) {
                    logger.debug("REST EXCEPTION STATUS : " + exception.getResponse().getStatus());
View Full Code Here

    }

    @Override
    public void put(ByteArray key, Versioned<byte[]> value, byte[] transform)
            throws VoldemortException {
        RestResponse response = null;

        try {
            byte[] payload = value.getValue();

            // Create the REST request with this byte array
            String base64Key = RestUtils.encodeVoldemortKey(key.get());
            RestRequestBuilder rb = new RestRequestBuilder(new URI(this.restBootstrapURL + "/"
                                                                   + getName() + "/" + base64Key));

            // Create a HTTP POST request
            rb.setMethod(POST);
            rb.setEntity(payload);
            rb.setHeader(CONTENT_TYPE, "binary");
            rb.setHeader(CONTENT_LENGTH, "" + payload.length);
            String timeoutStr = Long.toString(this.config.getTimeoutConfig()
                                                         .getOperationTimeout(VoldemortOpCode.PUT_OP_CODE));
            rb.setHeader(RestMessageHeaders.X_VOLD_REQUEST_TIMEOUT_MS, timeoutStr);
            rb.setHeader(RestMessageHeaders.X_VOLD_REQUEST_ORIGIN_TIME_MS,
                         String.valueOf(System.currentTimeMillis()));
            if(this.routingTypeCode != null) {
                rb.setHeader(RestMessageHeaders.X_VOLD_ROUTING_TYPE_CODE, this.routingTypeCode);
            }
            if(this.zoneId != INVALID_ZONE_ID) {
                rb.setHeader(RestMessageHeaders.X_VOLD_ZONE_ID, String.valueOf(this.zoneId));
            }

            // Serialize the Vector clock
            VectorClock vc = (VectorClock) value.getVersion();

            // If the given Vector clock is empty, we'll let the receiver of
            // this request fetch the existing vector clock and increment before
            // doing the put.
            if(vc != null) {
                String serializedVC = null;
                if(!vc.getEntries().isEmpty()) {
                    serializedVC = RestUtils.getSerializedVectorClock(vc);
                }

                if(serializedVC != null && serializedVC.length() > 0) {
                    rb.setHeader(RestMessageHeaders.X_VOLD_VECTOR_CLOCK, serializedVC);
                }
            }

            RestRequest request = rb.build();
            Future<RestResponse> f = client.restRequest(request);

            // This will block
            response = f.get();

            String serializedUpdatedVC = response.getHeader(RestMessageHeaders.X_VOLD_VECTOR_CLOCK);
            if(serializedUpdatedVC == null || serializedUpdatedVC.length() == 0) {
                if(logger.isDebugEnabled()) {
                    logger.debug("Received empty vector clock in the response");
                }
            } else {
                VectorClock updatedVC = RestUtils.deserializeVectorClock(serializedUpdatedVC);
                VectorClock originalVC = (VectorClock) value.getVersion();
                originalVC.copyFromVectorClock(updatedVC);
            }

            final ByteString entity = response.getEntity();
            if(entity == null) {
                if(logger.isDebugEnabled()) {
                    logger.debug("Empty response !");
                }
            }
View Full Code Here

                RestRequest request = rb.build();
                Future<RestResponse> f = client.restRequest(request);

                // This will block
                RestResponse response = f.get();

                // Parse the response
                final ByteString entity = response.getEntity();

                String contentType = response.getHeader(CONTENT_TYPE);
                if(entity != null) {
                    if(contentType.equalsIgnoreCase(MULTIPART_CONTENT_TYPE)) {

                        resultMap = parseGetAllResults(entity);
                    } else {
View Full Code Here

            String timeoutStr = Long.toString(this.config.getTimeoutConfig()
                                                         .getOperationTimeout(VoldemortOpCode.GET_VERSION_OP_CODE));

            rb.setHeader(RestMessageHeaders.X_VOLD_GET_VERSION, "true");

            RestResponse response = fetchGetResponse(rb, timeoutStr);
            final ByteString entity = response.getEntity();
            if(entity != null) {
                resultList = parseGetVersionResponse(entity);
            } else {
                if(logger.isDebugEnabled()) {
                    logger.debug("Did not get any response!");
View Full Code Here

            requestBuilder.setHeader(RestMessageHeaders.X_VOLD_REQUEST_TIMEOUT_MS, timeoutStr);
            requestBuilder = setCommonRequestHeader(requestBuilder);
            RestRequest request = requestBuilder.build();
            Future<RestResponse> future = client.restRequest(request);
            // This will block
            RestResponse response = future.get();
            ByteString entity = response.getEntity();
            return entity.asString("UTF-8");
        } catch(Exception e) {
            if(e.getCause() instanceof RestException) {
                return ((RestException) e.getCause()).getResponse().getEntity().asString("UTF-8");
            }
View Full Code Here

            RestRequest request = requestBuilder.build();
            Future<RestResponse> future = client.restRequest(request);

            // This will block
            RestResponse response = future.get();
            final ByteString entity = response.getEntity();
            if(entity == null) {
                if(logger.isDebugEnabled()) {
                    logger.debug("Empty response !");
                }
                responseMessage = "Received empty response from " + coordinatorUrl;
View Full Code Here

TOP

Related Classes of com.linkedin.r2.sample.echo.rest.RestEchoServer

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.