Search in sources :

Example 1 with MessageBusParams

use of com.yahoo.documentapi.messagebus.MessageBusParams in project vespa by vespa-engine.

the class DummyReceiver method init.

public void init() {
    MessageBusParams params = new MessageBusParams(new LoadTypeSet());
    params.setRPCNetworkParams(new RPCNetworkParams().setIdentity(new Identity(name)));
    params.setDocumentManagerConfigId("client");
    params.getMessageBusParams().setMaxPendingCount(maxPendingCount);
    params.getMessageBusParams().setMaxPendingSize(0);
    da = new MessageBusDocumentAccess(params);
    queue = (maxQueueTime < 0) ? new LinkedBlockingDeque<>() : new ThroughputLimitQueue<>(maxQueueTime);
    session = da.getMessageBus().createDestinationSession("default", true, this);
    executor = new ThreadPoolExecutor(threads, threads, 5, TimeUnit.SECONDS, queue, new DaemonThreadFactory());
    System.out.println("Registered listener at " + name + "/default with " + maxPendingCount + " max pending and sleep time of " + sleepTime);
}
Also used : LinkedBlockingDeque(java.util.concurrent.LinkedBlockingDeque) RPCNetworkParams(com.yahoo.messagebus.network.rpc.RPCNetworkParams) MessageBusDocumentAccess(com.yahoo.documentapi.messagebus.MessageBusDocumentAccess) DaemonThreadFactory(com.yahoo.concurrent.DaemonThreadFactory) MessageBusParams(com.yahoo.documentapi.messagebus.MessageBusParams) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) Identity(com.yahoo.messagebus.network.Identity) ThroughputLimitQueue(com.yahoo.documentapi.ThroughputLimitQueue) LoadTypeSet(com.yahoo.documentapi.messagebus.loadtypes.LoadTypeSet)

Example 2 with MessageBusParams

use of com.yahoo.documentapi.messagebus.MessageBusParams in project vespa by vespa-engine.

the class VdsVisitTarget method run.

@SuppressWarnings("unchecked")
public void run() throws Exception {
    initShutdownHook();
    log.log(LogLevel.DEBUG, "Starting VdsVisitTarget");
    MessageBusParams mbusParams = new MessageBusParams(new LoadTypeSet());
    mbusParams.getRPCNetworkParams().setIdentity(new Identity(slobrokAddress));
    if (port > 0) {
        mbusParams.getRPCNetworkParams().setListenPort(port);
    }
    access = new MessageBusDocumentAccess(mbusParams);
    VdsVisitHandler handler;
    Class<?> cls = Thread.currentThread().getContextClassLoader().loadClass(handlerClassName);
    try {
        // Any custom data handlers may have a constructor that takes in args,
        // so that the user can pass cmd line options to them
        Class<?>[] consTypes = new Class<?>[] { boolean.class, boolean.class, boolean.class, boolean.class, boolean.class, boolean.class, int.class, String[].class };
        Constructor<?> cons = cls.getConstructor(consTypes);
        handler = (VdsVisitHandler) cons.newInstance(printIds, verbose, verbose, verbose, false, false, processTime, handlerArgs);
    } catch (NoSuchMethodException e) {
        // Retry, this time matching the StdOutVisitorHandler constructor
        // arg list
        Class<?>[] consTypes = new Class<?>[] { boolean.class, boolean.class, boolean.class, boolean.class, boolean.class, boolean.class, int.class, boolean.class };
        Constructor<?> cons = cls.getConstructor(consTypes);
        handler = (VdsVisitHandler) cons.newInstance(printIds, verbose, verbose, verbose, false, false, processTime, false);
    }
    VisitorDataHandler dataHandler = handler.getDataHandler();
    VisitorControlHandler controlHandler = handler.getControlHandler();
    VisitorDestinationParameters params = new VisitorDestinationParameters("visit-destination", dataHandler);
    session = access.createVisitorDestinationSession(params);
    while (!controlHandler.isDone()) {
        Thread.sleep(1000);
    }
}
Also used : MessageBusDocumentAccess(com.yahoo.documentapi.messagebus.MessageBusDocumentAccess) Constructor(java.lang.reflect.Constructor) VisitorDestinationParameters(com.yahoo.documentapi.VisitorDestinationParameters) MessageBusParams(com.yahoo.documentapi.messagebus.MessageBusParams) VisitorDataHandler(com.yahoo.documentapi.VisitorDataHandler) Identity(com.yahoo.messagebus.network.Identity) LoadTypeSet(com.yahoo.documentapi.messagebus.loadtypes.LoadTypeSet) VisitorControlHandler(com.yahoo.documentapi.VisitorControlHandler)

Example 3 with MessageBusParams

use of com.yahoo.documentapi.messagebus.MessageBusParams in project vespa by vespa-engine.

the class DocumentRetriever method retrieveDocuments.

public void retrieveDocuments() throws DocumentRetrieverException {
    boolean first = true;
    String route = params.cluster.isEmpty() ? params.route : resolveClusterRoute(params.cluster);
    LoadType loadType = params.loadTypeName.isEmpty() ? null : resolveLoadType(params.loadTypeName);
    MessageBusParams messageBusParams = createMessageBusParams(params.configId, params.timeout, route);
    documentAccess = documentAccessFactory.createDocumentAccess(messageBusParams);
    session = documentAccess.createSyncSession(new SyncParameters.Builder().build());
    int trace = params.traceLevel;
    if (trace > 0) {
        session.setTraceLevel(trace);
    }
    Iterator<String> iter = params.documentIds;
    if (params.jsonOutput && !params.printIdsOnly) {
        System.out.println('[');
    }
    while (iter.hasNext()) {
        if (params.jsonOutput && !params.printIdsOnly) {
            if (!first) {
                System.out.println(',');
            } else {
                first = false;
            }
        }
        String docid = iter.next();
        Message msg = createDocumentRequest(docid, loadType);
        Reply reply = session.syncSend(msg);
        printReply(reply);
    }
    if (params.jsonOutput && !params.printIdsOnly) {
        System.out.println(']');
    }
}
Also used : SyncParameters(com.yahoo.documentapi.SyncParameters) Message(com.yahoo.messagebus.Message) GetDocumentMessage(com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage) Reply(com.yahoo.messagebus.Reply) GetDocumentReply(com.yahoo.documentapi.messagebus.protocol.GetDocumentReply) MessageBusParams(com.yahoo.documentapi.messagebus.MessageBusParams) LoadType(com.yahoo.documentapi.messagebus.loadtypes.LoadType)

Example 4 with MessageBusParams

use of com.yahoo.documentapi.messagebus.MessageBusParams in project vespa by vespa-engine.

the class DocumentRetriever method createMessageBusParams.

private MessageBusParams createMessageBusParams(String configId, double timeout, String route) {
    MessageBusParams messageBusParams = new MessageBusParams(loadTypeSet);
    messageBusParams.setRoute(route);
    messageBusParams.setProtocolConfigId(configId);
    messageBusParams.setRoutingConfigId(configId);
    messageBusParams.setDocumentManagerConfigId(configId);
    if (timeout > 0) {
        messageBusParams.getSourceSessionParams().setTimeout(timeout);
    }
    return messageBusParams;
}
Also used : MessageBusParams(com.yahoo.documentapi.messagebus.MessageBusParams)

Example 5 with MessageBusParams

use of com.yahoo.documentapi.messagebus.MessageBusParams in project vespa by vespa-engine.

the class MessageBusDocumentApiTestCase method setUp.

@Before
public void setUp() throws ListenFailedException {
    slobrok = new Slobrok();
    String slobrokConfigId = "raw:slobrok[1]\n" + "slobrok[0].connectionspec tcp/localhost:" + slobrok.port() + "\n";
    MessageBusParams params = new MessageBusParams();
    params.getRPCNetworkParams().setIdentity(new Identity("test/feeder"));
    params.getRPCNetworkParams().setSlobrokConfigId(slobrokConfigId);
    params.setDocumentManagerConfigId("file:src/test/cfg/documentmanager.cfg");
    params.setRouteName("Route");
    params.setRoutingConfigId("file:src/test/cfg/messagebus.cfg");
    params.setTraceLevel(9);
    params.setSourceSessionParams(new SourceSessionParams().setThrottlePolicy(null));
    access = new MessageBusDocumentAccess(params);
    destination = new VisitableDestination(slobrokConfigId, params.getDocumentManagerConfigId());
}
Also used : MessageBusDocumentAccess(com.yahoo.documentapi.messagebus.MessageBusDocumentAccess) Slobrok(com.yahoo.jrt.slobrok.server.Slobrok) MessageBusParams(com.yahoo.documentapi.messagebus.MessageBusParams) Identity(com.yahoo.messagebus.network.Identity) SourceSessionParams(com.yahoo.messagebus.SourceSessionParams) Before(org.junit.Before)

Aggregations

MessageBusParams (com.yahoo.documentapi.messagebus.MessageBusParams)5 MessageBusDocumentAccess (com.yahoo.documentapi.messagebus.MessageBusDocumentAccess)3 Identity (com.yahoo.messagebus.network.Identity)3 LoadTypeSet (com.yahoo.documentapi.messagebus.loadtypes.LoadTypeSet)2 DaemonThreadFactory (com.yahoo.concurrent.DaemonThreadFactory)1 SyncParameters (com.yahoo.documentapi.SyncParameters)1 ThroughputLimitQueue (com.yahoo.documentapi.ThroughputLimitQueue)1 VisitorControlHandler (com.yahoo.documentapi.VisitorControlHandler)1 VisitorDataHandler (com.yahoo.documentapi.VisitorDataHandler)1 VisitorDestinationParameters (com.yahoo.documentapi.VisitorDestinationParameters)1 LoadType (com.yahoo.documentapi.messagebus.loadtypes.LoadType)1 GetDocumentMessage (com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage)1 GetDocumentReply (com.yahoo.documentapi.messagebus.protocol.GetDocumentReply)1 Slobrok (com.yahoo.jrt.slobrok.server.Slobrok)1 Message (com.yahoo.messagebus.Message)1 Reply (com.yahoo.messagebus.Reply)1 SourceSessionParams (com.yahoo.messagebus.SourceSessionParams)1 RPCNetworkParams (com.yahoo.messagebus.network.rpc.RPCNetworkParams)1 Constructor (java.lang.reflect.Constructor)1 LinkedBlockingDeque (java.util.concurrent.LinkedBlockingDeque)1