Package com.linkedin.r2.sample

Examples of com.linkedin.r2.sample.Bootstrap


  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


    @Override
    public boolean delete(ByteArray key, Version version) throws VoldemortException {
        try {
            // 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(DELETE);
            rb.setHeader(CONTENT_LENGTH, "0");
            String timeoutStr = Long.toString(this.config.getTimeoutConfig()
                                                         .getOperationTimeout(VoldemortOpCode.DELETE_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) version;

            // 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 && vc.getEntries().size() != 0) {
                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
            RestResponse response = f.get();
            final ByteString entity = response.getEntity();
View Full Code Here

    @Override
    public List<Versioned<byte[]>> get(ByteArray key, byte[] transforms) throws VoldemortException {
        List<Versioned<byte[]>> resultList = new ArrayList<Versioned<byte[]>>();
        String base64Key = RestUtils.encodeVoldemortKey(key.get());
        RestRequestBuilder rb = null;
        try {
            rb = new RestRequestBuilder(new URI(this.restBootstrapURL + "/" + getName() + "/"
                                                + 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);
View Full Code Here

        return results;

    }

    public String getSerializerInfoXml() throws VoldemortException {
        RestRequestBuilder rb = null;
        try {
            String base64Key = new String(Base64.encodeBase64(getName().getBytes("UTF-8")));
            rb = new RestRequestBuilder(new URI(this.restBootstrapURL + "/" + SCHEMATA_STORE_NAME
                                                + "/" + base64Key));
            rb.setHeader("Accept", "binary");
            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));
            }

            RestResponse response = fetchGetResponse(rb, FETCH_SCHEMA_TIMEOUT_MS);
            return response.getEntity().asString("UTF-8");
        } catch(ExecutionException e) {
View Full Code Here

        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();
View Full Code Here

                }
                resultList = this.get(key, singleKeyTransforms);
                resultMap.put(key, resultList);
            } else {

                RestRequestBuilder rb = new RestRequestBuilder(new URI(this.restBootstrapURL + "/"
                                                                       + getName() + "/"
                                                                       + keyArgs.toString()));

                rb.setMethod(GET);
                rb.setHeader("Accept", MULTIPART_CONTENT_TYPE);
                String timeoutStr = Long.toString(this.config.getTimeoutConfig()
                                                             .getOperationTimeout(VoldemortOpCode.GET_ALL_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));
                }

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

                // This will block
                RestResponse response = f.get();
View Full Code Here

    @Override
    public List<Version> getVersions(ByteArray key) {
        List<Version> resultList = new ArrayList<Version>();
        String base64Key = RestUtils.encodeVoldemortKey(key.get());
        RestRequestBuilder rb = null;
        try {
            rb = new RestRequestBuilder(new URI(this.restBootstrapURL + "/" + getName() + "/"
                                                + base64Key));
            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);
View Full Code Here

                                                                .append(STORE_CLIENT_CONFIG_OPS)
                                                                .append(URL_SEPARATOR)
                                                                .append(Joiner.on(",")
                                                                              .join(storeNames));

            RestRequestBuilder requestBuilder = new RestRequestBuilder(new URI(URIStringBuilder.toString()));

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

            requestBuilder.setMethod(requestType.GET.toString());
            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");
View Full Code Here

            // Create the REST request
            StringBuilder URIStringBuilder = new StringBuilder().append(coordinatorUrl)
                                                                .append(URL_SEPARATOR)
                                                                .append(STORE_CLIENT_CONFIG_OPS)
                                                                .append(URL_SEPARATOR);
            RestRequestBuilder requestBuilder = new RestRequestBuilder(new URI(URIStringBuilder.toString()));

            byte[] payload = storeClientConfigAvro.getBytes("UTF-8");

            // Create a HTTP POST request
            requestBuilder.setMethod(requestType.POST.toString());
            requestBuilder.setEntity(payload);
            requestBuilder.setHeader(CONTENT_TYPE, "binary");
            requestBuilder.setHeader(CONTENT_LENGTH, "" + payload.length);
            String timeoutStr = Long.toString(this.config.getTimeoutConfig()
                                                         .getOperationTimeout(VoldemortOpCode.PUT_OP_CODE));
            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();
            final ByteString entity = response.getEntity();
View Full Code Here

                                                                .append(URL_SEPARATOR)
                                                                .append(STORE_CLIENT_CONFIG_OPS)
                                                                .append(URL_SEPARATOR)
                                                                .append(Joiner.on(",")
                                                                              .join(storeNames));
            RestRequestBuilder requestBuilder = new RestRequestBuilder(new URI(URIStringBuilder.toString()));
            String timeoutStr = Long.toString(this.config.getTimeoutConfig()
                                                         .getOperationTimeout(VoldemortOpCode.GET_OP_CODE));
            // Create a HTTP POST request
            requestBuilder.setMethod(requestType.DELETE.toString());
            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();
            final ByteString entity = response.getEntity();
            if(entity == null) {
View Full Code Here

TOP

Related Classes of com.linkedin.r2.sample.Bootstrap

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.