use of com.yahoo.documentapi.messagebus.loadtypes.LoadTypeSet 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);
}
use of com.yahoo.documentapi.messagebus.loadtypes.LoadTypeSet in project vespa by vespa-engine.
the class DocumentRetrieverTest method testSendSingleMessage.
@Test
public void testSendSingleMessage() throws DocumentRetrieverException {
ClientParameters params = createParameters().setDocumentIds(asIterator(DOC_ID_1)).setPriority(DocumentProtocol.Priority.HIGH_1).setNoRetry(true).setLoadTypeName("loadtype").build();
when(mockedSession.syncSend(any())).thenReturn(createDocumentReply(DOC_ID_1));
LoadTypeSet loadTypeSet = new LoadTypeSet();
loadTypeSet.addLoadType(1, "loadtype", DocumentProtocol.Priority.HIGH_1);
DocumentRetriever documentRetriever = new DocumentRetriever(new ClusterList(), mockedFactory, loadTypeSet, params);
documentRetriever.retrieveDocuments();
verify(mockedSession, times(1)).syncSend(argThat(new ArgumentMatcher<GetDocumentMessage>() {
@Override
public boolean matches(Object o) {
GetDocumentMessage msg = (GetDocumentMessage) o;
return msg.getPriority().equals(DocumentProtocol.Priority.HIGH_1) && !msg.getRetryEnabled() && msg.getLoadType().equals(new LoadType(1, "loadtype", DocumentProtocol.Priority.HIGH_1));
}
}));
assertContainsDocument(DOC_ID_1);
}
use of com.yahoo.documentapi.messagebus.loadtypes.LoadTypeSet in project vespa by vespa-engine.
the class SessionCache method start.
private void start() {
ContainerMbusConfig mbusConfig = ConfigGetter.getConfig(ContainerMbusConfig.class, containerMbusConfigId);
if (documentManagerConfigId != null) {
documentTypeManager.configure(documentManagerConfigId);
}
LoadTypeSet loadTypeSet = new LoadTypeSet(loadTypeConfigId);
DocumentProtocol protocol = new DocumentProtocol(documentTypeManager, identity, loadTypeSet);
messageBus = createSharedMessageBus(mbusConfig, slobrokConfigId, identity, protocol);
// TODO: stop doing subscriptions to config when that is to be solved in slobrok as well
configAgent = new ConfigAgent(messagebusConfigId, messageBus.messageBus());
configAgent.subscribe();
}
use of com.yahoo.documentapi.messagebus.loadtypes.LoadTypeSet 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);
}
}
use of com.yahoo.documentapi.messagebus.loadtypes.LoadTypeSet in project vespa by vespa-engine.
the class LoadTypesTestCase method testIdGeneration.
public void testIdGeneration() {
LoadTypeSet set = new LoadTypeSet();
set.addType("vespagrim", "VERY_HIGH");
set.addType("slow", "VERY_LOW");
set.addType("test", null);
assertEquals("vespagrim", set.getNameMap().get("vespagrim").getName());
assertEquals("slow", set.getNameMap().get("slow").getName());
assertEquals("test", set.getNameMap().get("test").getName());
assertEquals("default", set.getNameMap().get("default").getName());
assertEquals(0xc21803d4, set.getNameMap().get("vespagrim").getId());
}
Aggregations