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();
}
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;
}
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);
}
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);
}
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"));
}
Aggregations