Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you
* may not use this file except in compliance with the License. You
* may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License. See accompanying
* LICENSE file.
*/
package com.gemstone.gemfire.internal.memcached.commands;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.CharacterCodingException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.internal.memcached.Command;
import com.gemstone.gemfire.internal.memcached.KeyWrapper;
import com.gemstone.gemfire.internal.memcached.Reply;
import com.gemstone.gemfire.internal.memcached.RequestReader;
import com.gemstone.gemfire.internal.memcached.ResponseStatus;
import com.gemstone.gemfire.internal.memcached.ValueWrapper;
import com.gemstone.gemfire.memcached.GemFireMemcachedServer.Protocol;
/**
*
* The retrieval commands "get" and "gets" operates like this:
*
* get <key>*\r\n
* gets <key>*\r\n
*
*
* Each item sent by the server looks like this:
*
* VALUE <key> <flags> <bytes> [<cas unique>]\r\n
* <data block>\r\n
*
*
* @author Swapnil Bawaskar
*
*/
public class GetCommand extends AbstractCommand {
private static final String VALUE = "VALUE";
private static final String W_SPACE = " ";
private static final String RN = "\r\n";
private static final ByteBuffer RN_BUF = asciiCharset.encode(RN);
private static final ByteBuffer END_BUF = asciiCharset.encode(Reply.END.toString());
/**
* buffer used to compose one line of reply
*/
private static ThreadLocal lineBuffer = new ThreadLocal();
/**
* defaults to the default send buffer size on socket
*/
private static final int REPLY_BUFFER_CAPACITY = Integer.getInteger("replyBufferCapacity", 146988);
/**
* buffer for sending get replies, one per thread
*/
private static ThreadLocal replyBuffer = new ThreadLocal();
private static final int EXTRAS_LENGTH = 4;
@Override
public ByteBuffer processCommand(RequestReader request, Protocol protocol, Cache cache) {
if (protocol == Protocol.ASCII) {
return processAsciiCommand(request, cache);
}
return processBinaryCommand(request.getRequest(), request, cache, request.getResponse());
}
protected ByteBuffer processBinaryCommand(ByteBuffer buffer, RequestReader request, Cache cache, ByteBuffer response) {
Region