use of com.yahoo.jrt.Spec in project vespa by vespa-engine.
the class ContainerRpcAdaptor method registerInSlobrok.
public synchronized void registerInSlobrok(List<String> slobrokConnectionSpecs) {
shutdownSlobrokRegistrator();
if (slobrokConnectionSpecs.isEmpty()) {
return;
}
if (!slobrokId.isPresent()) {
throw new AssertionError("Slobrok id must be set first");
}
SlobrokList slobrokList = new SlobrokList();
slobrokList.setup(slobrokConnectionSpecs.stream().toArray(String[]::new));
Spec mySpec = new Spec(hostname, acceptor.port());
Register register = new Register(supervisor, slobrokList, mySpec);
register.registerName(slobrokId.get());
slobrokRegistrator = Optional.of(register);
log.log(LogLevel.INFO, "Registered name '" + slobrokId.get() + "' at " + mySpec + " with: " + slobrokList);
}
use of com.yahoo.jrt.Spec in project vespa by vespa-engine.
the class RpcServer method connect.
public void connect() throws ListenFailedException, UnknownHostException {
disconnect();
log.log(LogLevel.DEBUG, "Fleetcontroller " + fleetControllerIndex + ": Connecting RPC server.");
if (supervisor != null)
disconnect();
supervisor = new Supervisor(new Transport());
addMethods();
log.log(LogLevel.DEBUG, "Fleetcontroller " + fleetControllerIndex + ": Attempting to bind to port " + port);
acceptor = supervisor.listen(new Spec(port));
log.log(LogLevel.DEBUG, "Fleetcontroller " + fleetControllerIndex + ": RPC server listening to port " + acceptor.port());
StringBuffer slobroks = new StringBuffer("(");
for (String s : slobrokConnectionSpecs) {
slobroks.append(" ").append(s);
}
slobroks.append(" )");
SlobrokList slist = new SlobrokList();
slist.setup(slobrokConnectionSpecs);
Spec spec = new Spec(HostName.getLocalhost(), acceptor.port());
log.log(LogLevel.INFO, "Registering " + spec + " with slobrok at " + slobroks);
if (slobrokBackOffPolicy != null) {
register = new Register(supervisor, slist, spec, slobrokBackOffPolicy);
} else {
register = new Register(supervisor, slist, spec);
}
register.registerName(getSlobrokName());
}
use of com.yahoo.jrt.Spec in project vespa by vespa-engine.
the class ConfigProxyRpcServerTest method basic.
@Test
public void basic() {
ProxyServer proxy = ProxyServer.createTestServer(new MockConfigSource(new MockClientUpdater()));
Spec spec = new Spec("localhost", 12345);
ConfigProxyRpcServer server = new ConfigProxyRpcServer(proxy, new Supervisor(new Transport()), spec);
assertThat(server.getSpec(), is(spec));
}
use of com.yahoo.jrt.Spec in project vespa by vespa-engine.
the class RpcConfigSourceClient method checkConfigSources.
/**
* Checks if config sources are available
*/
private void checkConfigSources() {
if (configSourceSet == null || configSourceSet.getSources() == null || configSourceSet.getSources().size() == 0) {
log.log(LogLevel.WARNING, "No config sources defined, could not check connection");
} else {
Request req = new Request("ping");
for (String configSource : configSourceSet.getSources()) {
Spec spec = new Spec(configSource);
Target target = supervisor.connect(spec);
target.invokeSync(req, 30.0);
if (target.isValid()) {
log.log(LogLevel.DEBUG, () -> "Created connection to config source at " + spec.toString());
return;
} else {
log.log(LogLevel.INFO, "Could not connect to config source at " + spec.toString());
}
target.close();
}
String extra = "";
log.log(LogLevel.INFO, "Could not connect to any config source in set " + configSourceSet.toString() + ", please make sure config server(s) are running. " + extra);
}
}
use of com.yahoo.jrt.Spec in project vespa by vespa-engine.
the class FileDistributionImpl method startDownloadingFileReferences.
// Notifies config proxy which file references it should start downloading. It's OK if the call does not succeed,
// as downloading will then start synchronously when a service requests a file reference instead
private void startDownloadingFileReferences(String hostName, int port, Set<FileReference> fileReferences) {
Target target = supervisor.connect(new Spec(hostName, port));
double timeout = 0.1;
Request request = new Request("filedistribution.setFileReferencesToDownload");
request.parameters().add(new StringArray(fileReferences.stream().map(FileReference::value).toArray(String[]::new)));
log.log(LogLevel.DEBUG, "Executing " + request.methodName() + " against " + target.toString());
target.invokeSync(request, timeout);
if (request.isError() && request.errorCode() != ErrorCode.CONNECTION) {
log.log(LogLevel.DEBUG, request.methodName() + " failed: " + request.errorCode() + " (" + request.errorMessage() + ")");
}
target.close();
}
Aggregations