public void RPC_destroyIterator(Request req) { try { addResult(provider.destroyIterator(req.parameters().get(0).asInt64()), req); } catch (Exception e) { e.printStackTrace(); } }
public void RPC_listBuckets(Request req) { addBucketIdListResult(provider.listBuckets((short) req.parameters().get(0).asInt64()), req); }
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_removeEntry(Request req) { addResult( provider.removeEntry( getBucket(req, 0), req.parameters().get(2).asInt64()), req); }
public void RPC_move(Request req) { addResult(provider.move( getBucket(req, 0), (short)req.parameters().get(2).asInt64()), 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); } }
public void RPC_removeById(Request req) { addRemoveResult( provider.remove( getBucket(req, 0), req.parameters().get(2).asInt64(), new DocumentId(req.parameters().get(3).asString())), req); }
public void RPC_removeIfFound(Request req) { addRemoveResult( provider.removeIfFound( getBucket(req, 0), req.parameters().get(2).asInt64(), new DocumentId(req.parameters().get(3).asString())), req); }
@SuppressWarnings({"UnusedDeclaration"}) public final void receiveFileMeta(Request req) { log.log(LogLevel.DEBUG, () -> "Received method call '" + req.methodName() + "' with parameters : " + req.parameters()); FileReference reference = new FileReference(req.parameters().get(0).asString()); String fileName = req.parameters().get(1).asString(); String type = req.parameters().get(2).asString(); long fileSize = req.parameters().get(3).asInt64(); int sessionId = nextSessionId.getAndIncrement(); int retval = 0; synchronized (sessions) { if (sessions.containsKey(sessionId)) { retval = 1; log.severe("Session id " + sessionId + " already exist, impossible. Request from(" + req.target() + ")"); } else { try { sessions.put(sessionId, new Session(downloadDirectory, tmpDirectory, sessionId, reference, FileReferenceData.Type.valueOf(type),fileName, fileSize)); } catch (Exception e) { retval = 1; } } } req.returnValues().add(new Int32Value(retval)); req.returnValues().add(new Int32Value(sessionId)); }
@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)); }
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; }