public StreamRequestHandler handleRequest( DataInputStream inputStream, DataOutputStream outputStream) throws IOException { VoldemortRequest.Builder request = ProtoUtils.readToBuilder(inputStream, VoldemortRequest.newBuilder()); boolean shouldRoute = request.getShouldRoute(); RequestRoutingType type = RequestRoutingType.getRequestRoutingType(shouldRoute, false); if (request.hasRequestRouteType()) { type = RequestRoutingType.getRequestRoutingType(request.getRequestRouteType()); } String storeName = request.getStore(); Store<ByteArray, byte[]> store = getStore(storeName, type); Message response; if (store == null) { response = unknownStore(storeName, request.getType()); } else { switch (request.getType()) { case GET: response = handleGet(request.getGet(), store); break; case GET_ALL: response = handleGetAll(request.getGetAll(), store); break; case PUT: response = handlePut(request.getPut(), store); break; case DELETE: response = handleDelete(request.getDelete(), store); break; case GET_VERSION: response = handleGetVersion(request.getGet(), store); break; default: throw new VoldemortException("Unknown operation " + request.getType()); } } ProtoUtils.writeMessage(outputStream, response); return null; }
public SocketStoreClientFactory(ClientConfig config) { super(config); this.requestRoutingType = RequestRoutingType.getRequestRoutingType( RoutingTier.SERVER.equals(config.getRoutingTier()), false); this.storeFactory = new ClientRequestExecutorPool( config.getSelectors(), config.getMaxConnectionsPerNode(), config.getConnectionTimeout(TimeUnit.MILLISECONDS), config.getSocketTimeout(TimeUnit.MILLISECONDS), config.getSocketBufferSize(), config.getSocketKeepAlive()); if (config.isJmxEnabled()) JmxUtils.registerMbean(storeFactory, JmxUtils.createObjectName(storeFactory.getClass())); }