/** * This constructor requires an array of protocols that it is to support, as well as the host application's config * identifier. That identifier is necessary so that all created sessions can be uniquely identified on the network. * * @param protocols An array of known protocols. * @param rpcParams A complete set of network parameters. * @param routingCfgId The config id for message bus routing specs. */ public RPCMessageBus(List<Protocol> protocols, RPCNetworkParams rpcParams, String routingCfgId) { this(new MessageBusParams().addProtocols(protocols), rpcParams, routingCfgId); }
/** * Registers multiple protocols with this by calling {@link #addProtocol(Protocol)} multiple times. * * @param protocols The protocols to register. * @return This, to allow chaining. */ public MessageBusParams addProtocols(List<Protocol> protocols) { for (Protocol protocol : protocols) { addProtocol(protocol); } return this; }
private RemoteClient(Slobrok slobrok, String slobrokId, Protocol protocol) { this.slobrok = slobrok; this.slobrokId = slobrok != null ? slobrok.configId() : slobrokId; mbus = new MessageBus(new RPCNetwork(new RPCNetworkParams().setSlobrokConfigId(this.slobrokId)), new MessageBusParams().addProtocol(protocol)); session = mbus.createSourceSession(new SourceSessionParams().setThrottlePolicy(null).setReplyHandler(queue)); }
maxPendingCount = params.getMaxPendingCount(); maxPendingSize = params.getMaxPendingSize(); for (int i = 0, len = params.getNumProtocols(); i < len; ++i) { protocolRepository.putProtocol(params.getProtocol(i)); if (params.getProtocol(i).getMetrics() != null) { metrics.protocols.addMetric(params.getProtocol(i).getMetrics()); RetryPolicy retryPolicy = params.getRetryPolicy(); if (retryPolicy != null) { resender = new Resender(retryPolicy);
/** * Sets the params object used to instantiate the message bus. * * @param params The params object. * @return This object for chaining. */ public MessageBusParams setMessageBusParams(com.yahoo.messagebus.MessageBusParams params) { mbusParams = new com.yahoo.messagebus.MessageBusParams(params); return this; }
/** * Create a new test server. * * @param name The service name prefix for this server. * @param table The routing table spec to be used, may be null for no routing. * @param slobrok The slobrok to register with (local). * @param protocol The protocol that this server should support in addition to SimpleProtocol. */ public TestServer(String name, RoutingTableSpec table, Slobrok slobrok, Protocol protocol) { this(new MessageBusParams().addProtocol(new SimpleProtocol()), new RPCNetworkParams() .setIdentity(new Identity(name)) .setSlobrokConfigId(getSlobrokConfig(slobrok))); if (protocol != null) { mb.putProtocol(protocol); } if (table != null) { setupRouting(table); } }
private RemoteServer(Slobrok slobrok, String slobrokId, Protocol protocol, String identity) { this.slobrok = slobrok; this.slobrokId = slobrok != null ? slobrok.configId() : slobrokId; mbus = new MessageBus(new RPCNetwork(new RPCNetworkParams() .setSlobrokConfigId(this.slobrokId) .setIdentity(new Identity(identity))), new MessageBusParams().addProtocol(protocol)); session = mbus.createDestinationSession(new DestinationSessionParams().setMessageHandler(queue)); }
/** * <p>Convenience constructor that proxies {@link #MessageBus(Network, * MessageBusParams)} by adding the given protocols to a default {@link * MessageBusParams} object.</p> * * @param net The network to associate with. * @param protocols An array of protocols to register. */ public MessageBus(Network net, List<Protocol> protocols) { this(net, new MessageBusParams().addProtocols(protocols)); }
/** * Creates a new document access using the supplied parameters. * * @param params All parameters for construction. */ public MessageBusDocumentAccess(MessageBusParams params) { super(params); this.params = params; try { com.yahoo.messagebus.MessageBusParams mbusParams = new com.yahoo.messagebus.MessageBusParams(params.getMessageBusParams()); mbusParams.addProtocol(new DocumentProtocol(getDocumentTypeManager(), params.getProtocolConfigId(), params.getLoadTypes())); if (System.getProperty("vespa.local", "false").equals("true")) { // set by Application when running locally LocalNetwork network = new LocalNetwork(); bus = new NetworkMessageBus(network, new MessageBus(network, mbusParams)); } else { bus = new RPCMessageBus(mbusParams, params.getRPCNetworkParams(), params.getRoutingConfigId()); } } catch (Exception e) { throw new DocumentAccessException(e); } }
private ClientTestDriver(RemoteServer server, Protocol protocol) { this.server = server; MessageBusParams mbusParams = new MessageBusParams().addProtocol(protocol); RPCNetworkParams netParams = new RPCNetworkParams().setSlobrokConfigId(server.slobrokId()); SharedMessageBus mbus = SharedMessageBus.newInstance(mbusParams, netParams); session = mbus.newSourceSession(new SourceSessionParams()); client = new MbusClient(session); client.start(); mbus.release(); driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); ContainerBuilder builder = driver.newContainerBuilder(); builder.clientBindings().bind("mbus://*/*", client); driver.activateContainer(builder); }
private ServerTestDriver(RemoteClient client, boolean activateContainer, RequestHandler requestHandler, Protocol protocol, Module... guiceModules) { this.client = client; driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(guiceModules); if (activateContainer) { ContainerBuilder builder = driver.newContainerBuilder(); if (requestHandler != null) { builder.serverBindings().bind("mbus://*/*", requestHandler); } driver.activateContainer(builder); } MessageBusParams mbusParams = new MessageBusParams().addProtocol(protocol); RPCNetworkParams netParams = new RPCNetworkParams().setSlobrokConfigId(client.slobrokId()); SharedMessageBus mbus = SharedMessageBus.newInstance(mbusParams, netParams); ServerSession session = mbus.newDestinationSession(new DestinationSessionParams()); server = new MbusServer(driver, session); server.start(); session.release(); mbus.release(); }