private synchronized void handleRpcList(Request req) { Values dst = req.returnValues(); dst.add(new StringArray(names.toArray(new String[names.size()]))); }
private void dumpServices(Request req) { List<String> names = new ArrayList<>(); List<String> specs = new ArrayList<>(); for (Map.Entry<String,String> entry : services.entrySet()) { names.add(entry.getKey()); specs.add(entry.getValue()); } req.returnValues().add(new StringArray(names.toArray(new String[names.size()]))); req.returnValues().add(new StringArray(specs.toArray(new String[specs.size()]))); req.returnValues().add(new Int32Value(gencnt)); }
@SuppressWarnings({"UnusedDeclaration"}) public final void getActiveFileReferencesStatus(Request req) { Map<FileReference, Double> downloadStatus = downloader.downloadStatus(); String[] fileRefArray = new String[downloadStatus.keySet().size()]; fileRefArray = downloadStatus.keySet().stream() .map(FileReference::value) .collect(Collectors.toList()) .toArray(fileRefArray); double[] downloadStatusArray = new double[downloadStatus.values().size()]; int i = 0; for (Double d : downloadStatus.values()) { downloadStatusArray[i++] = d; } req.returnValues().add(new StringArray(fileRefArray)); req.returnValues().add(new DoubleArray(downloadStatusArray)); }
public void getMethodList(Request req) { int cnt = parent.methodMap().size(); String[] ret0_names = new String[cnt]; String[] ret1_params = new String[cnt]; String[] ret2_return = new String[cnt]; int i = 0; Iterator<Method> itr = parent.methodMap().values().iterator(); while (itr.hasNext()) { Method m = itr.next(); ret0_names[i] = m.name(); ret1_params[i] = m.paramTypes(); ret2_return[i] = m.returnTypes(); i++; } req.returnValues().add(new StringArray(ret0_names)); req.returnValues().add(new StringArray(ret1_params)); req.returnValues().add(new StringArray(ret2_return)); }
private void handleFetchMirrorTimeout(FetchMirror fetch) { pendingFetch.remove(fetch); fetch.req.returnValues().add(new StringArray(new String[0])); fetch.req.returnValues().add(new StringArray(new String[0])); fetch.req.returnValues().add(new Int32Value(gencnt)); fetch.req.returnRequest(); }
public void RPC_getPartitionStates(Request req) { PartitionStateListResult result = provider.getPartitionStates(); addResult(result, req); int[] states = new int[result.getPartitionStates().size()]; String[] reasons = new String[result.getPartitionStates().size()]; for (int i = 0; i < states.length; ++i) { states[i] = result.getPartitionStates().get(i).getState().ordinal(); reasons[i] = result.getPartitionStates().get(i).getReason(); } req.returnValues().add(new Int32Array(states)); req.returnValues().add(new StringArray(reasons)); }
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 getMethodInfo(Request req) { Method method = parent.methodMap().get(req.parameters().get(0).asString()); if (method == null) { req.setError(ErrorCode.METHOD_FAILED, "No Such Method"); return; } req.returnValues().add(new StringValue(method.methodDesc())); req.returnValues().add(new StringValue(method.paramTypes())); req.returnValues().add(new StringValue(method.returnTypes())); int paramCnt = method.paramTypes().length(); int returnCnt = method.returnTypes().length(); String[] ret3_paramName = new String[paramCnt]; String[] ret4_paramDesc = new String[paramCnt]; String[] ret5_returnName = new String[returnCnt]; String[] ret6_returnDesc = new String[returnCnt]; for (int i = 0; i < paramCnt; i++) { ret3_paramName[i] = method.paramName(i); ret4_paramDesc[i] = method.paramDesc(i); } for (int i = 0; i < returnCnt; i++) { ret5_returnName[i] = method.returnName(i); ret6_returnDesc[i] = method.returnDesc(i); } req.returnValues().add(new StringArray(ret3_paramName)); req.returnValues().add(new StringArray(ret4_paramDesc)); req.returnValues().add(new StringArray(ret5_returnName)); req.returnValues().add(new StringArray(ret6_returnDesc)); } }
/** * Decode a value from the given buffer. This method also acts as * a factory for value objects * * @return the decoded value * @param type value type identifier * @param src where the value is stored * @throws IllegalArgumentException if the given type identifier is illegal **/ static Value decode(byte type, ByteBuffer src) { switch (type) { case INT8: return new Int8Value(src); case INT8_ARRAY: return new Int8Array(src); case INT16: return new Int16Value(src); case INT16_ARRAY: return new Int16Array(src); case INT32: return new Int32Value(src); case INT32_ARRAY: return new Int32Array(src); case INT64: return new Int64Value(src); case INT64_ARRAY: return new Int64Array(src); case FLOAT: return new FloatValue(src); case FLOAT_ARRAY: return new FloatArray(src); case DOUBLE: return new DoubleValue(src); case DOUBLE_ARRAY: return new DoubleArray(src); case STRING: return new StringValue(src); case STRING_ARRAY: return new StringArray(src); case DATA: return new DataValue(src); case DATA_ARRAY: return new DataArray(src); } throw new IllegalArgumentException(); }
req.returnValues().add(new StringArray(docIds)); req.returnValues().add(new DataArray(documents)); req.returnValues().add(new Int8Value(result.isCompleted() ? (byte)1 : (byte)0));
@Override protected void createResponse(Values ret, Reply reply, Version version, byte [] payload) { int[] eCodes = new int[reply.getNumErrors()]; String[] eMessages = new String[reply.getNumErrors()]; String[] eServices = new String[reply.getNumErrors()]; for (int i = 0; i < reply.getNumErrors(); ++i) { Error error = reply.getError(i); eCodes[i] = error.getCode(); eMessages[i] = error.getMessage(); eServices[i] = error.getService() != null ? error.getService() : ""; } ret.add(new StringValue(version.toString())); ret.add(new DoubleValue(reply.getRetryDelay())); ret.add(new Int32Array(eCodes)); ret.add(new StringArray(eMessages)); ret.add(new StringArray(eServices)); ret.add(new StringValue(reply.getProtocol())); ret.add(new DataValue(payload)); ret.add(new StringValue(reply.getTrace().getRoot() != null ? reply.getTrace().getRoot().encode() : "")); }