Search in sources :

Example 16 with Spec

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);
}
Also used : Register(com.yahoo.jrt.slobrok.api.Register) SlobrokList(com.yahoo.jrt.slobrok.api.SlobrokList) Spec(com.yahoo.jrt.Spec)

Example 17 with Spec

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());
}
Also used : Supervisor(com.yahoo.jrt.Supervisor) Register(com.yahoo.jrt.slobrok.api.Register) SlobrokList(com.yahoo.jrt.slobrok.api.SlobrokList) Transport(com.yahoo.jrt.Transport) Spec(com.yahoo.jrt.Spec)

Example 18 with Spec

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));
}
Also used : Supervisor(com.yahoo.jrt.Supervisor) Spec(com.yahoo.jrt.Spec) Transport(com.yahoo.jrt.Transport) Test(org.junit.Test)

Example 19 with 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);
    }
}
Also used : Target(com.yahoo.jrt.Target) Request(com.yahoo.jrt.Request) JRTServerConfigRequest(com.yahoo.vespa.config.protocol.JRTServerConfigRequest) Spec(com.yahoo.jrt.Spec)

Example 20 with Spec

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();
}
Also used : Target(com.yahoo.jrt.Target) StringArray(com.yahoo.jrt.StringArray) Request(com.yahoo.jrt.Request) Spec(com.yahoo.jrt.Spec)

Aggregations

Spec (com.yahoo.jrt.Spec)26 Request (com.yahoo.jrt.Request)14 Target (com.yahoo.jrt.Target)14 Supervisor (com.yahoo.jrt.Supervisor)13 Transport (com.yahoo.jrt.Transport)13 Test (org.junit.Test)9 StringValue (com.yahoo.jrt.StringValue)8 ConfiguredNode (com.yahoo.vdslib.distribution.ConfiguredNode)4 NodeState (com.yahoo.vdslib.state.NodeState)4 Slobrok (com.yahoo.jrt.slobrok.server.Slobrok)3 Distribution (com.yahoo.vdslib.distribution.Distribution)3 Node (com.yahoo.vdslib.state.Node)3 Register (com.yahoo.jrt.slobrok.api.Register)2 SlobrokList (com.yahoo.jrt.slobrok.api.SlobrokList)2 Identity (com.yahoo.messagebus.network.Identity)2 ClusterState (com.yahoo.vdslib.state.ClusterState)2 ArrayList (java.util.ArrayList)2 TreeSet (java.util.TreeSet)2 HostInfo (com.yahoo.config.model.api.HostInfo)1 PortInfo (com.yahoo.config.model.api.PortInfo)1