/** * Determine the number of bytes needed to store this value * sequence when encoded into a buffer * * @return number of bytes needed for encoding this value sequence **/ int bytes() { int bytes = 4 + values.size(); for (int i = 0; i < values.size(); i++) { bytes += get(i).bytes(); } return bytes; }
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; }
private void handleRpcUnreg(Request req) { log.log(Level.WARNING, "unregistered name " + req.parameters().get(0).asString()); }
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_destroyIterator(Request req) { try { addResult(provider.destroyIterator(req.parameters().get(0).asInt64()), req); } catch (Exception e) { e.printStackTrace(); } }
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); } }
@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); } }
public void RPC_listBuckets(Request req) { addBucketIdListResult(provider.listBuckets((short) req.parameters().get(0).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); } }
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_removeEntry(Request req) { addResult( provider.removeEntry( getBucket(req, 0), req.parameters().get(2).asInt64()), 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); }
public void RPC_move(Request req) { addResult(provider.move( getBucket(req, 0), (short)req.parameters().get(2).asInt64()), req); } }
public void RPC_maintain(Request req) { addResult(provider.maintain(getBucket(req, 0), PersistenceProvider.MaintenanceLevel.values()[req.parameters().get(2).asInt8()]), req); }
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; }
public void RPC_get(Request req) { GetResult result = provider.get(getBucket(req, 0), getFieldSet(req, 2), new DocumentId(req.parameters().get(3).asString())); addResult(result, req); req.returnValues().add(new Int64Value(result.getLastModifiedTimestamp())); req.returnValues().add(new DataValue(serializeDocument(result.getDocument()))); }