Search in sources :

Example 1 with VisitorDestinationParameters

use of com.yahoo.documentapi.VisitorDestinationParameters 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)

Aggregations

VisitorControlHandler (com.yahoo.documentapi.VisitorControlHandler)1 VisitorDataHandler (com.yahoo.documentapi.VisitorDataHandler)1 VisitorDestinationParameters (com.yahoo.documentapi.VisitorDestinationParameters)1 MessageBusDocumentAccess (com.yahoo.documentapi.messagebus.MessageBusDocumentAccess)1 MessageBusParams (com.yahoo.documentapi.messagebus.MessageBusParams)1 LoadTypeSet (com.yahoo.documentapi.messagebus.loadtypes.LoadTypeSet)1 Identity (com.yahoo.messagebus.network.Identity)1 Constructor (java.lang.reflect.Constructor)1