/** * Convenience method for connecting to a peer, invoking a method * and disconnecting. * * @param spec the address to connect to * @param req the invocation request * @param timeout request timeout in seconds **/ public void invokeBatch(Spec spec, Request req, double timeout) { Target target = connectSync(spec); try { target.invokeSync(req, timeout); } finally { target.close(); } }
void receive(FileReference reference, String filename, byte[] content) { log.log(LogLevel.INFO, "Preparing receive call for " + reference.value() + " and file " + filename); XXHash64 hasher = XXHashFactory.fastestInstance().hash64(); Request fileBlob = new Request("filedistribution.receiveFile"); log.log(LogLevel.INFO, "Calling " + fileBlob.methodName() + " with target " + target); fileBlob.parameters().add(new StringValue(reference.value())); fileBlob.parameters().add(new StringValue(filename)); fileBlob.parameters().add(new DataValue(content)); fileBlob.parameters().add(new Int64Value(hasher.hash(ByteBuffer.wrap(content), 0))); fileBlob.parameters().add(new Int32Value(0)); fileBlob.parameters().add(new StringValue("OK")); log.log(LogLevel.INFO, "Doing invokeSync"); target.invokeSync(fileBlob, 5); log.log(LogLevel.INFO, "Done with invokeSync"); } }
target.invokeSync(request, rpcTimeout);
target = supervisor.connect(new Spec(connectspec)); Request request=createRequest(method,arguments); target.invokeSync(request,10.0); if (request.isError()) { System.err.println("error(" + request.errorCode() + "): " + request.errorMessage());