Examples of JdkHttpClientPathBuilder


Examples of com.fasterxml.clustermate.std.JdkHttpClientPathBuilder

    /**********************************************************************
     */

    protected RequestPathBuilder rootPath(ServiceConfig config)
    {
        return new JdkHttpClientPathBuilder("localhost")
            .addPathSegments(config.servicePathRoot);
    }
View Full Code Here

Examples of com.fasterxml.clustermate.std.JdkHttpClientPathBuilder

        // first: if we can't spend at least 10 msecs, let's give up:
        if (timeoutMsecs < MIN_TIMEOUT_MSECS) {
            return null;
        }

        RequestPathBuilder pathBuilder = new JdkHttpClientPathBuilder(ip)
            .addPathSegments(_clientConfig.getBasePath());
        pathBuilder = _clientConfig.getPathStrategy().appendNodeStatusPath(pathBuilder);
        String endpoint = pathBuilder.toString();

        HttpURLConnection conn;
View Full Code Here

Examples of com.fasterxml.clustermate.std.JdkHttpClientPathBuilder

        final long timeoutMsecs = Math.min(endOfTime - startTime, config.getGetCallTimeoutMsecs());
        if (timeoutMsecs < config.getMinimumTimeoutMsecs()) {
            return new JdkHttpGetCallResult<T>(CallFailure.timeout(_server, startTime, startTime));
        }
        try {
            JdkHttpClientPathBuilder path = _server.rootPath();
            path = _pathFinder.appendPath(path, PathType.STORE_ENTRY);
            path = _keyConverter.appendToPath(path, contentId);
            if (params != null) {
                path = params.appendToPath(path, contentId);
            }
            URL url = path.asURL();
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            // plus, allow use of GZIP and LZF
            path = path.setHeader(ClusterMateConstants.HTTP_HEADER_ACCEPT_COMPRESSION,
                    "lzf, gzip, identity");
            // and may use range as well
            if (range != null) {
                path = path.setHeader(ClusterMateConstants.HTTP_HEADER_RANGE_FOR_REQUEST,
                        range.asRequestHeader());
            }
            int statusCode = sendRequest("GET", conn, path, timeoutMsecs);

            // one thing first: handle standard headers, if any?
View Full Code Here

Examples of com.fasterxml.clustermate.std.JdkHttpClientPathBuilder

        final long timeoutMsecs = Math.min(endOfTime - startTime, config.getDeleteCallTimeoutMsecs());
        if (timeoutMsecs < config.getMinimumTimeoutMsecs()) {
            return CallFailure.timeout(_server, startTime, startTime);
        }
        try {
            JdkHttpClientPathBuilder path = _server.rootPath();
            path = _pathFinder.appendPath(path, PathType.STORE_ENTRY);
            path = _keyConverter.appendToPath(path, contentId);
            URL url = path.asURL();
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            int statusCode = sendRequest("DELETE", conn, path, timeoutMsecs);
           
            // one thing first: handle standard headers, if any?
            handleHeaders(_server, conn, startTime);
View Full Code Here

Examples of com.fasterxml.clustermate.std.JdkHttpClientPathBuilder

        long timeoutMsecs = Math.min(endOfTime - startTime, config.getGetCallTimeoutMsecs());
        if (timeoutMsecs < config.getMinimumTimeoutMsecs()) {
            return new JdkHttpHeadCallResult(CallFailure.timeout(_server, startTime, startTime));
        }
        try {
            JdkHttpClientPathBuilder path = _server.rootPath();
            path = _pathFinder.appendPath(path, PathType.STORE_ENTRY);
            path = _keyConverter.appendToPath(path, contentId);
            URL url = path.asURL();
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            int statusCode = sendRequest("HEAD", conn, path, timeoutMsecs);
           
            // one thing first: handle standard headers, if any?
            handleHeaders(_server, conn, startTime);
View Full Code Here

Examples of com.fasterxml.clustermate.std.JdkHttpClientPathBuilder

            long endOfTime,
            K contentId, PutContentProvider content,
            final long startTime, final long timeoutMsecs)
        throws IOException, ExecutionException, InterruptedException
    {
        JdkHttpClientPathBuilder path = _server.rootPath();
        path = _pathFinder.appendPath(path, PathType.STORE_ENTRY);
        path = _keyConverter.appendToPath(path, contentId);

        // Is compression known?
        Compression comp = content.getExistingCompression();
        if (comp != null) { // if so, must be indicated
            path = path.setHeader(ClusterMateConstants.HTTP_HEADER_COMPRESSION, comp.asContentEncoding());
        }
        if (params != null) {
            path = params.appendToPath(path, contentId);
        }
        // Ok; and then figure out most optimal way for getting content:

        OutputStream out = null;
        HttpURLConnection conn;
        int hash = content.getContentHash();

        try {
            ByteContainer bc = content.contentAsBytes();
            if (bc != null) { // most efficient, yay
                if (hash == HashConstants.NO_CHECKSUM) {
                    hash = _keyConverter.contentHashFor(bc);
                    content.setContentHash(hash);
                }
                path = addChecksum(path, hash);
                URL url = path.asURL();
                conn = (HttpURLConnection) url.openConnection();
                conn.setDoOutput(true);
                conn.setFixedLengthStreamingMode(bc.byteLength());
                conn = initRequest("PUT", conn, path, timeoutMsecs);
                out = conn.getOutputStream();
                bc.writeBytes(out);
            } else {
                InputStream in; // closed in copy()
                File f = content.contentAsFile();
                // !!! TODO: add wrapper for calculating hash sum, if not yet calculated
                if (f != null) {
                    in = new FileInputStream(f);
                } else {
                    in = content.contentAsStream();
                }
                if (hash != HashConstants.NO_CHECKSUM) {
                    path = addChecksum(path, hash);
                }
                URL url = path.asURL();
                conn = (HttpURLConnection) url.openConnection();
                conn.setDoOutput(true);
                conn.setChunkedStreamingMode(CHUNK_SIZE);
                conn = initRequest("PUT", conn, path, timeoutMsecs);
                out = conn.getOutputStream();
View Full Code Here

Examples of com.fasterxml.clustermate.std.JdkHttpClientPathBuilder

        final long timeoutMsecs = Math.min(endOfTime - startTime, config.getGetCallTimeoutMsecs());
        if (timeoutMsecs < config.getMinimumTimeoutMsecs()) {
            return new JdkHttpGetCallResult<T>(CallFailure.timeout(_server, startTime, startTime));
        }
        try {
            JdkHttpClientPathBuilder path = _server.rootPath();
            path = _pathFinder.appendPath(path, PathType.STORE_ENTRY);
            path = _keyConverter.appendToPath(path, contentId);
            URL url = path.asURL();
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            // plus, allow use of GZIP and LZF
            path = path.setHeader(ClusterMateConstants.HTTP_HEADER_ACCEPT_COMPRESSION,
                    "lzf, gzip, identity");
            // and may use range as well
            if (range != null) {
                path = path.setHeader(ClusterMateConstants.HTTP_HEADER_RANGE_FOR_REQUEST,
                        range.asRequestHeader());
            }
            int statusCode = sendRequest("GET", conn, path, timeoutMsecs);

            // one thing first: handle standard headers, if any?
View Full Code Here

Examples of com.fasterxml.clustermate.std.JdkHttpClientPathBuilder

        long endOfTime,
        K contentId, PutContentProvider content,
            final long startTime, final long timeout)
        throws IOException, ExecutionException, InterruptedException
    {
        JdkHttpClientPathBuilder path = _server.rootPath();
        path = _pathFinder.appendPath(path, PathType.STORE_ENTRY);
        path = _keyConverter.appendToPath(path, contentId);
        if (params != null) {
          path = params.appendToPath(path, contentId);
        }
        // Ok; and then figure out most optimal way for getting content:

        OutputStream out = null;
        HttpURLConnection conn;
        int hash = content.getContentHash();

        try {
            ByteContainer bc = content.contentAsBytes();
            if (bc != null) { // most efficient, yay
                if (hash == HashConstants.NO_CHECKSUM) {
                    hash = _keyConverter.contentHashFor(bc);
                    content.setContentHash(hash);
                }
                path = addChecksum(path, hash);
                URL url = path.asURL();
                conn = (HttpURLConnection) url.openConnection();
                conn.setDoOutput(true);
                conn.setFixedLengthStreamingMode(bc.byteLength());
                conn.setRequestMethod("PUT");
                out = conn.getOutputStream();
                bc.writeBytes(out);
            } else {
                InputStream in; // closed in copy()
                File f = content.contentAsFile();
                // !!! TODO: add wrapper for calculating hash sum, if not yet calculated
                if (f != null) {
                    in = new FileInputStream(f);
                } else {
                    in = content.contentAsStream();
                }
                if (hash != HashConstants.NO_CHECKSUM) {
                    path = addChecksum(path, hash);
                }
                URL url = path.asURL();
                conn = (HttpURLConnection) url.openConnection();
                conn.setDoOutput(true);
                conn.setChunkedStreamingMode(CHUNK_SIZE);
                conn.setRequestMethod("PUT");
                out = conn.getOutputStream();
View Full Code Here

Examples of com.fasterxml.clustermate.std.JdkHttpClientPathBuilder

    /**********************************************************************
     */

    protected RequestPathBuilder rootPath(ServiceConfig config)
    {
        return new JdkHttpClientPathBuilder("localhost")
            .addPathSegments(config.servicePathRoot);
    }
View Full Code Here

Examples of com.fasterxml.clustermate.std.JdkHttpClientPathBuilder

    /**********************************************************************
     */

    protected JdkHttpClientPathBuilder rootPath(ServiceConfig config)
    {
        return new JdkHttpClientPathBuilder("localhost")
            .addPathSegments(config.servicePathRoot);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.