/** * Create a new Register using the given Supervisor, slobrok * connect specs, hostname and port * * @param orb the Supervisor to use * @param slobroks slobrok connect spec list * @param myHost the hostname of this host * @param myPort the port number we are listening to */ public Register(Supervisor orb, SlobrokList slobroks, String myHost, int myPort) { this(orb, slobroks, new Spec(myHost, myPort)); }
/** * Constructs a service address from the given specifications. The last component of the service is stored as the * session name. * * @param serviceName The full service name of the address. * @param connectionSpec The connection specification. */ public RPCServiceAddress(String serviceName, String connectionSpec) { this.serviceName = serviceName; int pos = serviceName.lastIndexOf('/'); if (pos > 0 && pos < serviceName.length() - 1) { sessionName = serviceName.substring(pos + 1); } else { sessionName = null; } this.connectionSpec = new Spec(connectionSpec); }
public void start() { try { acceptor = supervisor.listen(new Spec(port)); log.info("Listening for RPC requests on port " + port); } catch (Exception e) { throw new RuntimeException(e); } }
@Override public void configure(FiledistributorrpcConfig filedistributorrpcConfig) { spec = new Spec(filedistributorrpcConfig.connectionspec()); }
/** * Obtain the Spec for the local port and host interface this Acceptor * is listening to. If this Acceptor is no longer listening (it has * been shut down), null will be returned. * * @return listening spec, or null if not listening. **/ public Spec spec() { if ( ! serverChannel.isOpen()) { return null; } return new Spec(serverChannel.socket().getInetAddress().getHostName(), serverChannel.socket().getLocalPort()); }
/** * Returns the raw config needed to connect to the given slobrok. * * @param slobrok The slobrok whose connection spec to include. * @return The raw config string. */ public static String getSlobrokConfig(Slobrok slobrok) { return "raw:slobrok[1]\n" + "slobrok[0].connectionspec \"" + new Spec("localhost", slobrok.port()).toString() + "\"\n"; }
public String configId() { return "raw:slobrok[1]\n" + "slobrok[0].connectionspec \"" + new Spec("localhost", listener.port()).toString() + "\"\n"; }
public void invokeAsync(Request req, double timeout, RequestWaiter waiter) { // TODO: Consider replacing this by a watcher on the target synchronized(this) { // ensure we have exactly 1 valid connection across threads if (target == null || ! target.isValid()) target = supervisor.connect(new Spec(hostname, port)); } target.invokeAsync(req, timeout, waiter); }
public static void main(String[] args) { //String fileReference = args[0]; String fileReference = "59f93f445438c9db7ccbf1629f583c2aa004a68b"; String filename = "com.yahoo.vespatest.ExtraHitSearcher-1.0.0-deploy.jar"; File file = new File(String.format("/tmp/%s/%s", fileReference, filename)); byte[] blob = null; try { blob = IOUtils.readFileBytes(file); } catch (IOException e) { e.printStackTrace(); } log.log(LogLevel.INFO, "Read blob from " + file.getAbsolutePath()); Supervisor supervisor = new Supervisor(new Transport()); Spec spec = new Spec("tcp/localhost:19090"); log.log(LogLevel.INFO, "Connecting to " + spec); Target target = supervisor.connect(spec); if (! target.isValid()) { log.log(LogLevel.INFO, "Could not connect"); System.exit(1); } else { log.log(LogLevel.INFO, "Connected to " + spec); } new RpcTester(target).call(fileReference, filename, blob); }
public RegisterCallback(Request req, String name, String spec) { req.detach(); registerReq = req; this.name = name; this.spec = spec; target = orb.connect(new Spec(spec)); Request cbReq = new Request("slobrok.callback.listNamesServed"); target.invokeAsync(cbReq, 5.0, this); }
/** * The container has no rpc methods, but we still need an RPC sever * to register in Slobrok to enable orchestration */ private Register registerInSlobrok(SlobroksConfig slobrokConfig, QrConfig qrConfig) { if ( ! qrConfig.rpc().enabled()) return null; // 1. Set up RPC server supervisor = new Supervisor(new Transport()); Spec listenSpec = new Spec(qrConfig.rpc().port()); try { acceptor = supervisor.listen(listenSpec); } catch (ListenFailedException e) { throw new RuntimeException("Could not create rpc server listening on " + listenSpec, e); } // 2. Register it in slobrok SlobrokList slobrokList = new SlobrokList(); slobrokList.setup(slobrokConfig.slobrok().stream().map(SlobroksConfig.Slobrok::connectionspec).toArray(String[]::new)); Spec mySpec = new Spec(HostName.getLocalhost(), acceptor.port()); slobrokRegistrator = new Register(supervisor, slobrokList, mySpec); slobrokRegistrator.registerName(qrConfig.rpc().slobrokId()); log.log(LogLevel.INFO, "Registered name '" + qrConfig.rpc().slobrokId() + "' at " + mySpec + " with: " + slobrokList); return slobrokRegistrator; }
target = orb.connect(new Spec(currSlobrok)); String namesString = null; final boolean logFine = log.isLoggable(Level.FINE);
public Slobrok(int port) throws ListenFailedException { orb = new Supervisor(new Transport()); registerMethods(); try { listener = orb.listen(new Spec(port)); } catch (ListenFailedException e) { orb.transport().shutdown().join(); throw e; } }
target = supervisor.connect(new Spec(connectspec)); Request request=createRequest(method,arguments); target.invokeSync(request,10.0);
target = orb.connect(new Spec(currSlobrok)); specsGeneration = 0;
listener = orb.listen(new Spec(params.getListenPort())); } catch (ListenFailedException e) { orb.transport().shutdown().join();