Package com.fasterxml.clustermate.std

Examples of com.fasterxml.clustermate.std.JdkHttpClientPathBuilder


    }

    protected String buildLocalSyncListUrl(ClusterViewByServerUpdatable cluster,
            NodeState remote, long lastClusterHash)
    {
        JdkHttpClientPathBuilder pathBuilder = new JdkHttpClientPathBuilder(remote.getAddress())
            .addPathSegments(_stuff.getServiceConfig().servicePathRoot);
        pathBuilder = _pathStrategy.appendSyncListPath(pathBuilder);
        pathBuilder = _buildSyncListUrl(pathBuilder, cluster.getLocalState(), remote.getSyncedUpTo());
        // this will include 'caller' param:
        pathBuilder = cluster.addClusterStateInfo(pathBuilder);
        pathBuilder = pathBuilder.addParameter(QUERY_PARAM_CLUSTER_HASH,
                String.valueOf(lastClusterHash));
        return pathBuilder.toString();
    }
View Full Code Here


    }

    protected String buildRemoteSyncListUrl(NodeState localState, IpAndPort remoteEndpoint,
            long syncedUpTo)
    {
        JdkHttpClientPathBuilder pathBuilder = new JdkHttpClientPathBuilder(remoteEndpoint)
            .addPathSegments(_stuff.getServiceConfig().servicePathRoot);
        pathBuilder = _pathStrategy.appendRemoteSyncListPath(pathBuilder);
        pathBuilder = _buildSyncListUrl(pathBuilder, localState, syncedUpTo);

        // NOTE: no piggy-backing of local cluster info here
        return pathBuilder.toString();
    }
View Full Code Here

   
    protected String _buildNodeStatusUpdateUrl(ClusterViewByServerUpdatable cluster, IpAndPort remote,
            String state)
    {
        final KeyRange syncRange = cluster.getLocalState().totalRange();
        JdkHttpClientPathBuilder pathBuilder = new JdkHttpClientPathBuilder(remote)
            .addPathSegments(_stuff.getServiceConfig().servicePathRoot);
        pathBuilder = _pathStrategy.appendNodeStatusPath(pathBuilder);
        pathBuilder = pathBuilder.addParameter(QUERY_PARAM_KEYRANGE_START, String.valueOf(syncRange.getStart()));
        pathBuilder = pathBuilder.addParameter(QUERY_PARAM_KEYRANGE_LENGTH, String.valueOf(syncRange.getLength()));
        pathBuilder = pathBuilder.addParameter(QUERY_PARAM_TIMESTAMP,
                String.valueOf(_stuff.getTimeMaster().currentTimeMillis()));
        pathBuilder = pathBuilder.addParameter(QUERY_PARAM_STATE, state);
        // this will include 'caller' param:
        pathBuilder = cluster.addClusterStateInfo(pathBuilder);
        return pathBuilder.toString();
    }
View Full Code Here

    }
   
    protected String _buildSyncPullUrl(IpAndPort endpoint)
    {
        final ServiceConfig config = _stuff.getServiceConfig();
        JdkHttpClientPathBuilder pathBuilder = new JdkHttpClientPathBuilder(endpoint)
            .addPathSegments(config.servicePathRoot);
        pathBuilder = _pathStrategy.appendSyncPullPath(pathBuilder);
        return pathBuilder.toString();
    }
View Full Code Here

        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.appendStoreEntryPath(path);
            path = _keyConverter.appendToPath(path, contentId);
            if (params != null) {
                path = params.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

        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.appendStoreEntryPath(path);
            path = _keyConverter.appendToPath(path, contentId);
            if (params != null) {
                path = params.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

        final long startTime = System.currentTimeMillis();
        final long timeoutMsecs = Math.min(endOfTime - startTime, config.getGetCallTimeoutMsecs());
        if (timeoutMsecs < config.getMinimumTimeoutMsecs()) {
            return failed(CallFailure.timeout(_server, startTime, startTime));
        }
        JdkHttpClientPathBuilder path = _server.rootPath();
        path = _pathFinder.appendStoreListPath(path);
        path = _keyConverter.appendToPath(path, prefix);
        path.addParameter(ClusterMateConstants.QUERY_PARAM_MAX_ENTRIES, String.valueOf(maxResults))
                .addParameter(ClusterMateConstants.QUERY_PARAM_TYPE, type.toString())
                ;
        if (lastSeen != null) {
            path = path.addParameter(ClusterMateConstants.QUERY_PARAM_LAST_SEEN, toBase64(lastSeen.asBytes()));
        }
        InputStream in = null;

        try {
            URL url = path.asURL();
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            int statusCode = sendRequest("GET", conn, path, timeoutMsecs);
            // handle std headers first, before anything else
            handleHeaders(_server, conn, startTime);
View Full Code Here

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

    @Override
    public JdkHttpClientPathBuilder pathBuilder(IpAndPort server) {
        return new JdkHttpClientPathBuilder(server);
    }
View Full Code Here

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

        // Is compression known?
        Compression comp = content.getExistingCompression();
        if (comp != null) { // if so, must be indicated
            path = path.addCompression(comp, content.uncompressedLength());
        }
        path = path.setContentType(ClusterMateConstants.HTTP_CONTENT_BINARY);
        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

        final long timeoutMsecs = Math.min(endOfTime - startTime, config.getGetCallTimeoutMsecs());
        if (timeoutMsecs < config.getMinimumTimeoutMsecs()) {
            return new JdkHttpReadCallResult<T>(null, CallFailure.timeout(_server, startTime, startTime));
        }
        try {
            JdkHttpClientPathBuilder path = _server.rootPath();
            path = _pathFinder.appendStoreEntryPath(path);
            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

TOP

Related Classes of com.fasterxml.clustermate.std.JdkHttpClientPathBuilder

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.