use of com.yahoo.jrt.Spec in project vespa by vespa-engine.
the class FileDistributionStatus method getHostStatus.
HostStatus getHostStatus(String hostname, int port, Duration timeout) {
Target target = supervisor.connect(new Spec(hostname, port));
Request request = new Request("filedistribution.getActiveFileReferencesStatus");
target.invokeSync(request, timeout.toMillis() / 1000);
HostStatus hostStatus = createHostStatusFromResponse(hostname, request);
target.close();
return hostStatus;
}
use of com.yahoo.jrt.Spec in project vespa by vespa-engine.
the class RPCTargetPool method getTarget.
/**
* This method will return a target for the given address. If a target does not currently exist for the given
* address, it will be created and added to the internal map. Each target is also reference counted so that an
* active target is never expired.
*
* @param orb The supervisor to use to connect to the target.
* @param address The address to resolve to a target.
* @return A target for the given address.
*/
public RPCTarget getTarget(Supervisor orb, RPCServiceAddress address) {
Spec spec = address.getConnectionSpec();
String key = spec.toString();
RPCTarget ret;
synchronized (this) {
Entry entry = targets.get(key);
if (entry != null) {
if (entry.target.getJRTTarget().isValid()) {
entry.target.addRef();
entry.lastUse = timer.milliTime();
return entry.target;
}
entry.target.subRef();
targets.remove(key);
}
ret = new RPCTarget(spec, orb);
targets.put(key, new Entry(ret, timer.milliTime()));
}
ret.addRef();
return ret;
}
use of com.yahoo.jrt.Spec in project vespa by vespa-engine.
the class MessageBusTestCase method testRoutingPolicyCache.
@Test
public void testRoutingPolicyCache() throws ListenFailedException, UnknownHostException {
Slobrok slobrok = new Slobrok();
String config = "slobrok[1]\nslobrok[0].connectionspec \"" + new Spec("localhost", slobrok.port()).toString() + "\"\n";
SimpleProtocol protocol = new SimpleProtocol();
protocol.addPolicyFactory("Custom", new CustomPolicyFactory());
MessageBus bus = new MessageBus(new RPCNetwork(new RPCNetworkParams().setSlobrokConfigId("raw:" + config)), new MessageBusParams().addProtocol(protocol));
RoutingPolicy all = bus.getRoutingPolicy(SimpleProtocol.NAME, "Custom", null);
assertNotNull(all);
RoutingPolicy ref = bus.getRoutingPolicy(SimpleProtocol.NAME, "Custom", null);
assertNotNull(ref);
assertSame(all, ref);
RoutingPolicy allArg = bus.getRoutingPolicy(SimpleProtocol.NAME, "Custom", "Arg");
assertNotNull(allArg);
assertNotSame(all, allArg);
RoutingPolicy refArg = bus.getRoutingPolicy(SimpleProtocol.NAME, "Custom", "Arg");
assertNotNull(refArg);
assertSame(allArg, refArg);
}
use of com.yahoo.jrt.Spec in project vespa by vespa-engine.
the class FleetControllerTest method setWantedState.
protected void setWantedState(DummyVdsNode node, State state, String reason) {
if (supervisor == null) {
supervisor = new Supervisor(new Transport());
}
NodeState ns = new NodeState(node.getType(), state);
if (reason != null)
ns.setDescription(reason);
Target connection = supervisor.connect(new Spec("localhost", fleetController.getRpcPort()));
Request req = new Request("setNodeState");
req.parameters().add(new StringValue(node.getSlobrokName()));
req.parameters().add(new StringValue(ns.serialize()));
connection.invokeSync(req, timeoutS);
if (req.isError()) {
assertTrue("Failed to invoke setNodeState(): " + req.errorCode() + ": " + req.errorMessage(), false);
}
if (!req.checkReturnTypes("s")) {
assertTrue("Failed to invoke setNodeState(): Invalid return types.", false);
}
}
use of com.yahoo.jrt.Spec in project vespa by vespa-engine.
the class DatabaseTest method setWantedState.
// Note: different semantics than FleetControllerTest.setWantedState
protected void setWantedState(Node n, NodeState ns, Map<Node, NodeState> wantedStates) {
int rpcPort = fleetController.getRpcPort();
if (supervisor == null) {
supervisor = new Supervisor(new Transport());
}
Target connection = supervisor.connect(new Spec("localhost", rpcPort));
assertTrue(connection.isValid());
Request req = new Request("setNodeState");
req.parameters().add(new StringValue("storage/cluster.mycluster/" + n.getType().toString() + "/" + n.getIndex()));
req.parameters().add(new StringValue(ns.serialize(true)));
connection.invokeSync(req, timeoutS);
assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
assertTrue(req.toString(), req.checkReturnTypes("s"));
wantedStates.put(n, ns);
}
Aggregations