public void RPC_put(Request req) { try { GrowableByteBuffer buffer = new GrowableByteBuffer(ByteBuffer.wrap(req.parameters().get(3).asData())); Document doc = new Document(DocumentDeserializerFactory.create42(docTypeManager, buffer)); addResult(provider.put(getBucket(req, 0), req.parameters().get(2).asInt64(), doc), req); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e); } }
public void RPC_setClusterState(Request req) throws java.text.ParseException { ClusterStateImpl state = new ClusterStateImpl(req.parameters().get(0).asData()); addResult(provider.setClusterState(state), req); }
public void RPC_update(Request req) { try { GrowableByteBuffer buffer = new GrowableByteBuffer(ByteBuffer.wrap(req.parameters().get(3).asData())); DocumentUpdate update = new DocumentUpdate(DocumentDeserializerFactory.createHead(docTypeManager, buffer)); UpdateResult result = provider.update(getBucket(req, 0), req.parameters().get(2).asInt64(), update); addResult(result, req); req.returnValues().add(new Int64Value(result.getExistingTimestamp())); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e); } }
@SuppressWarnings({"UnusedDeclaration"}) public final void receiveFilePart(Request req) { log.log(LogLevel.DEBUG, () -> "Received method call '" + req.methodName() + "' with parameters : " + req.parameters()); FileReference reference = new FileReference(req.parameters().get(0).asString()); int sessionId = req.parameters().get(1).asInt32(); int partId = req.parameters().get(2).asInt32(); byte [] part = req.parameters().get(3).asData(); Session session = getSession(sessionId); int retval = verifySession(session, sessionId, reference); try { session.addPart(partId, part); } catch (Exception e) { log.severe("Got exception " + e); retval = 1; } double completeness = (double) session.currentFileSize / (double) session.fileSize; log.log(LogLevel.DEBUG, () -> String.format("%.1f percent of '%s' downloaded", completeness * 100, reference.value())); downloader.setDownloadStatus(reference, completeness); req.returnValues().add(new Int32Value(retval)); }
protected Params toParams(Values args) { Params p = new Params(); p.version = new Version(args.get(0).asUtf8Array()); p.route = args.get(1).asString(); p.session = args.get(2).asString(); p.retryEnabled = (args.get(3).asInt8() != 0); p.retry = args.get(4).asInt32(); p.timeRemaining = args.get(5).asInt64(); p.protocolName = args.get(6).asUtf8Array(); p.payload = args.get(7).asData(); p.traceLevel = args.get(8).asInt32(); return p; }
@Override public void handleRequestDone(Request requestWithResponse) { if (requestWithResponse.isError()) { handler.receive(GetDocsumsResponseOrError.fromError("Error response from " + node + ": " + requestWithResponse.errorMessage())); return; } Values returnValues = requestWithResponse.returnValues(); if (returnValues.size() < 3) { handler.receive(GetDocsumsResponseOrError.fromError("Invalid getDocsums response from " + node + ": Expected 3 return arguments, got " + returnValues.size())); return; } byte compression = returnValues.get(0).asInt8(); int uncompressedSize = returnValues.get(1).asInt32(); byte[] compressedSlimeBytes = returnValues.get(2).asData(); List<FastHit> hits = (List<FastHit>) requestWithResponse.getContext(); handler.receive(GetDocsumsResponseOrError.fromResponse(new GetDocsumsResponse(compression, uncompressedSize, compressedSlimeBytes, hits))); }
String[] errorServices = ret.get(4).asStringArray(); Utf8Array protocolName = ret.get(5).asUtf8Array(); byte[] payload = ret.get(6).asData(); String replyTrace = ret.get(7).asString();
protected Params toParams(Values args) { CompressionType compression = CompressionType.valueOf(args.get(3).asInt8()); byte[] slimeBytes = compressor.decompress(args.get(5).asData(), compression, args.get(4).asInt32()); Slime slime = BinaryFormat.decode(slimeBytes); Inspector root = slime.get(); Params p = new Params(); p.version = new Version(root.field(VERSION_F).asString()); p.route = root.field(ROUTE_F).asString(); p.session = root.field(SESSION_F).asString(); p.retryEnabled = root.field(USERETRY_F).asBool(); p.retry = (int)root.field(RETRY_F).asLong(); p.timeRemaining = root.field(TIMEREMAINING_F).asLong(); p.protocolName = new Utf8Array(Utf8.toBytes(root.field(PROTOCOL_F).asString())); p.payload = root.field(BLOB_F).asData(); p.traceLevel = (int)root.field(TRACELEVEL_F).asLong(); return p; }
@Override protected Reply createReply(Values ret, String serviceName, Trace trace) { CompressionType compression = CompressionType.valueOf(ret.get(3).asInt8()); byte[] slimeBytes = compressor.decompress(ret.get(5).asData(), compression, ret.get(4).asInt32()); Slime slime = BinaryFormat.decode(slimeBytes); Inspector root = slime.get();