Search in sources :

Example 21 with Spec

use of com.yahoo.jrt.Spec in project vespa by vespa-engine.

the class ProxyServer method main.

public static void main(String[] args) {
    /* Initialize the log handler */
    LogSetup.clearHandlers();
    LogSetup.initVespaLogging("configproxy");
    Properties properties = getSystemProperties();
    int port = DEFAULT_RPC_PORT;
    if (args.length > 0) {
        port = Integer.parseInt(args[0]);
    }
    Event.started("configproxy");
    ConfigProxyStatistics statistics = new ConfigProxyStatistics(properties.eventInterval);
    Thread t = new Thread(statistics);
    t.setName("Metrics generator");
    t.setDaemon(true);
    t.start();
    ConfigSourceSet configSources = new ConfigSourceSet(properties.configSources);
    DelayedResponses delayedResponses = new DelayedResponses(statistics);
    ProxyServer proxyServer = new ProxyServer(new Spec(null, port), delayedResponses, configSources, statistics, defaultTimingValues(), true, new MemoryCache(), null);
    // catch termination signal
    proxyServer.setupSigTermHandler();
    Thread proxyserverThread = new Thread(proxyServer);
    proxyserverThread.setName("configproxy");
    proxyserverThread.start();
    proxyServer.waitForShutdown();
}
Also used : ConfigSourceSet(com.yahoo.config.subscription.ConfigSourceSet) Spec(com.yahoo.jrt.Spec)

Example 22 with Spec

use of com.yahoo.jrt.Spec in project vespa by vespa-engine.

the class SlobrokMonitor method getSlobrokSpecs.

List<String> getSlobrokSpecs(ApplicationInfo applicationInfo) {
    List<String> slobrokSpecs = new ArrayList<>();
    for (HostInfo host : applicationInfo.getModel().getHosts()) {
        for (ServiceInfo service : host.getServices()) {
            if (!Objects.equals(service.getServiceType(), SLOBROK_SERVICE_TYPE)) {
                continue;
            }
            for (PortInfo port : service.getPorts()) {
                if (port.getTags().contains(SLOBROK_RPC_PORT_TAG)) {
                    Spec spec = new Spec(host.getHostname(), port.getPort());
                    slobrokSpecs.add(spec.toString());
                }
            }
        }
    }
    return slobrokSpecs;
}
Also used : ServiceInfo(com.yahoo.config.model.api.ServiceInfo) PortInfo(com.yahoo.config.model.api.PortInfo) ArrayList(java.util.ArrayList) Spec(com.yahoo.jrt.Spec) HostInfo(com.yahoo.config.model.api.HostInfo)

Example 23 with Spec

use of com.yahoo.jrt.Spec in project vespa by vespa-engine.

the class RpcTester method main.

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);
}
Also used : Supervisor(com.yahoo.jrt.Supervisor) Target(com.yahoo.jrt.Target) IOException(java.io.IOException) Transport(com.yahoo.jrt.Transport) Spec(com.yahoo.jrt.Spec) File(java.io.File)

Example 24 with Spec

use of com.yahoo.jrt.Spec in project vespa by vespa-engine.

the class Register method handleUpdate.

/**
 * Invoked by the update task.
 */
private void handleUpdate() {
    if (reqDone) {
        reqDone = false;
        boolean logOnSuccess = false;
        synchronized (this) {
            if (req.methodName().equals(UNREGISTER_METHOD_NAME)) {
                logOnSuccess = true;
                // Why is this remove() here and not in unregisterName? Because at that time there may be
                // an in-flight request for the registration of name, and in case handleUpdate() would
                // anyway have to have special code for handling a removed name, e.g. testing for name
                // being in names which is O(N).
                lastRegisterSucceeded.remove(name);
            } else {
                final Boolean lastSucceeded = lastRegisterSucceeded.get(name);
                if (lastSucceeded == null || lastSucceeded != !req.isError()) {
                    logOnSuccess = true;
                    lastRegisterSucceeded.put(name, !req.isError());
                }
            }
        }
        if (req.isError()) {
            if (req.errorCode() != ErrorCode.METHOD_FAILED) {
                log.log(Level.INFO, logMessagePrefix() + " failed, will disconnect: " + req.errorMessage() + " (code " + req.errorCode() + ")");
                target.close();
                target = null;
            } else {
                log.log(Level.WARNING, logMessagePrefix() + " failed: " + req.errorMessage());
            }
        } else {
            log.log(logOnSuccess ? Level.INFO : Level.FINE, logMessagePrefix() + " completed successfully");
            backOff.reset();
        }
        req = null;
        name = null;
    }
    if (req != null) {
        log.log(Level.FINEST, "req in progress");
        // current request still in progress
        return;
    }
    if (target != null && !slobroks.contains(currSlobrok)) {
        log.log(Level.INFO, "RPC server " + mySpec + ": Slobrok server " + currSlobrok + " removed, will disconnect");
        target.close();
        target = null;
    }
    if (target == null) {
        currSlobrok = slobroks.nextSlobrokSpec();
        if (currSlobrok == null) {
            double delay = backOff.get();
            Level level = backOff.shouldWarn(delay) ? Level.WARNING : Level.FINE;
            log.log(level, "RPC server " + mySpec + ": All Slobrok servers tried, will retry in " + delay + " seconds: " + slobroks);
            updateTask.schedule(delay);
            return;
        }
        lastRegisterSucceeded.clear();
        target = orb.connect(new Spec(currSlobrok));
        String namesString = null;
        final boolean logFine = log.isLoggable(Level.FINE);
        synchronized (this) {
            if (logFine) {
                // 'names' must only be accessed in a synchronized(this) block
                namesString = names.toString();
            }
            pending.clear();
            pending.addAll(names);
        }
        if (logFine) {
            log.log(Level.FINE, "RPC server " + mySpec + ": Connect to Slobrok server " + currSlobrok + " and reregister all Slobrok names: " + namesString);
        }
    }
    synchronized (this) {
        if (unreg.size() > 0) {
            name = unreg.remove(unreg.size() - 1);
            req = new Request(UNREGISTER_METHOD_NAME);
        } else if (pending.size() > 0) {
            name = pending.remove(pending.size() - 1);
            req = new Request(REGISTER_METHOD_NAME);
        } else {
            pending.addAll(names);
            log.log(Level.FINE, "RPC server " + mySpec + ": Reregister all Slobrok names in 30 seconds: " + names);
            updateTask.schedule(30.0);
            return;
        }
    }
    req.parameters().add(new StringValue(name));
    req.parameters().add(new StringValue(mySpec));
    log.log(Level.FINE, logMessagePrefix() + " now");
    target.invokeAsync(req, 35.0, reqWait);
}
Also used : Request(com.yahoo.jrt.Request) Level(java.util.logging.Level) Spec(com.yahoo.jrt.Spec) StringValue(com.yahoo.jrt.StringValue)

Example 25 with Spec

use of com.yahoo.jrt.Spec in project vespa by vespa-engine.

the class ServiceAddressTestCase method setUp.

public void setUp() throws ListenFailedException, UnknownHostException {
    slobrok = new Slobrok();
    network = new RPCNetwork(new RPCNetworkParams().setIdentity(new Identity("foo")).setSlobrokConfigId("raw:slobrok[1]\nslobrok[0].connectionspec \"" + new Spec("localhost", slobrok.port()).toString() + "\"\n"));
}
Also used : Slobrok(com.yahoo.jrt.slobrok.server.Slobrok) Identity(com.yahoo.messagebus.network.Identity) 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