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 protected Reply createReply(Values ret, String serviceName, Trace trace) { Version version = new Version(ret.get(0).asUtf8Array()); double retryDelay = ret.get(1).asDouble(); int[] errorCodes = ret.get(2).asInt32Array(); String[] errorMessages = ret.get(3).asStringArray(); String[] errorServices = ret.get(4).asStringArray(); Utf8Array protocolName = ret.get(5).asUtf8Array(); byte[] payload = ret.get(6).asData(); String replyTrace = ret.get(7).asString();
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); } }
@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))); }
@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)); }
private void handleRpcUnreg(Request req) { log.log(Level.WARNING, "unregistered name " + req.parameters().get(0).asString()); }
@SuppressWarnings({"UnusedDeclaration"}) public final void receiveFileEof(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(); long xxhash = req.parameters().get(2).asInt64(); Session session = getSession(sessionId); int retval = verifySession(session, sessionId, reference); File file = session.close(xxhash); downloader.completedDownloading(reference, file); synchronized (sessions) { sessions.remove(sessionId); } req.returnValues().add(new Int32Value(retval)); }
public void RPC_createIterator(Request req) { try { TreeSet<Long> timestampSet = new TreeSet<Long>(); long[] timestamps = req.parameters().get(6).asInt64Array(); for (long l : timestamps) { timestampSet.add(l); } else { selection = new Selection( req.parameters().get(3).asString(), req.parameters().get(4).asInt64(), req.parameters().get(5).asInt64()); getFieldSet(req, 2), selection, PersistenceProvider.IncludedVersions.values()[req.parameters().get(7).asInt8()]);
private void handleUpdate() { if (req.errorCode() == ErrorCode.NONE && req.returnValues().satisfies("SSi") && req.returnValues().get(0).count() == req.returnValues().get(1).count()) if (specsGeneration != answer.get(2).asInt32()) { int numNames = answer.get(0).count(); String[] n = answer.get(0).asStringArray(); String[] s = answer.get(1).asStringArray(); Entry[] newSpecs = new Entry[numNames]; specsGeneration = answer.get(2).asInt32(); int u = (updates + 1); if (u == 0) { || (req.returnValues().get(2).count() != req.returnValues().get(3).count())) int diffFromGeneration = answer.get(0).asInt32(); int diffToGeneration = answer.get(4).asInt32(); if (specsGeneration != diffToGeneration) { int nRemoves = answer.get(1).count(); String[] r = answer.get(1).asStringArray(); int numNames = answer.get(2).count(); String[] n = answer.get(2).asStringArray(); String[] s = answer.get(3).asStringArray();
public void RPC_destroyIterator(Request req) { try { addResult(provider.destroyIterator(req.parameters().get(0).asInt64()), req); } catch (Exception e) { e.printStackTrace(); } }
private void rpc_fetchIncremental(Request req) { int gencnt = req.parameters().get(0).asInt32(); int timeout = req.parameters().get(1).asInt32(); // for now, always make "full diff" from generation 0 req.returnValues().add(new Int32Value(0)); req.returnValues().add(new StringArray(new String[0])); if (gencnt == this.gencnt) { pendingFetch.add(new FetchMirror(req, timeout)); } else { dumpServices(req); } }
public void RPC_setClusterState(Request req) throws java.text.ParseException { ClusterStateImpl state = new ClusterStateImpl(req.parameters().get(0).asData()); addResult(provider.setClusterState(state), req); }
@SuppressWarnings({"UnusedDeclaration"}) public final void setFileReferencesToDownload(Request req) { log.log(LogLevel.DEBUG, () -> "Received method call '" + req.methodName() + "' with parameters : " + req.parameters()); Arrays.stream(req.parameters().get(0).asStringArray()) .map(FileReference::new) .forEach(fileReference -> downloader.downloadIfNeeded(new FileReferenceDownload(fileReference))); req.returnValues().add(new Int32Value(0)); }
public void RPC_setActiveState(Request req) { try { addResult(provider.setActiveState(getBucket(req, 0), BucketInfo.ActiveState.values()[req.parameters().get(2).asInt8()]), req); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e); } }
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; }
private void rpc_register(Request req) { String name = req.parameters().get(0).asString(); String spec = req.parameters().get(1).asString(); String stored = services.get(name); if (stored == null) { new RegisterCallback(req, name, spec); } else { if ( ! stored.equals(spec)) req.setError(ErrorCode.METHOD_FAILED, "service '" + name + "' registered with another spec"); } }
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); } }