Search in sources :

Example 41 with BucketId

use of com.yahoo.document.BucketId in project vespa by vespa-engine.

the class BucketStatsPrinterTest method testShouldPrintBucketStats.

@Test
public void testShouldPrintBucketStats() throws BucketStatsException {
    String dummyBucketStats = "dummystats";
    GetBucketListReply.BucketInfo bucketInfo = new GetBucketListReply.BucketInfo(new BucketId(0), "dummy");
    when(retriever.retrieveBucketList(any(), any())).thenReturn(Collections.singletonList(bucketInfo));
    when(retriever.retrieveBucketStats(any(), any(), any(), any())).thenReturn(dummyBucketStats);
    String output = retreiveAndPrintBucketStats(ClientParameters.SelectionType.USER, "1234", true);
    assertTrue(output.contains(dummyBucketStats));
}
Also used : GetBucketListReply(com.yahoo.documentapi.messagebus.protocol.GetBucketListReply) BucketId(com.yahoo.document.BucketId) Test(org.junit.Test)

Example 42 with BucketId

use of com.yahoo.document.BucketId in project vespa by vespa-engine.

the class BucketStatsPrinter method retrieveAndPrintBucketStats.

public void retrieveAndPrintBucketStats(ClientParameters.SelectionType type, String id, boolean dumpData, String bucketSpace) throws BucketStatsException {
    BucketId bucketId = retriever.getBucketIdForType(type, id);
    if (type == ClientParameters.SelectionType.GROUP || type == ClientParameters.SelectionType.USER) {
        out.printf("Generated 32-bit bucket id: %s\n", bucketId);
    }
    List<GetBucketListReply.BucketInfo> bucketList = retriever.retrieveBucketList(bucketId, bucketSpace);
    printBucketList(bucketList);
    if (dumpData) {
        for (GetBucketListReply.BucketInfo bucketInfo : bucketList) {
            BucketId bucket = bucketInfo.getBucketId();
            String bucketStats = retriever.retrieveBucketStats(type, id, bucket, bucketSpace);
            printBucketStats(bucket, bucketStats);
        }
    }
}
Also used : GetBucketListReply(com.yahoo.documentapi.messagebus.protocol.GetBucketListReply) BucketId(com.yahoo.document.BucketId)

Example 43 with BucketId

use of com.yahoo.document.BucketId in project vespa by vespa-engine.

the class BucketStatsRetrieverTest method testRoute.

@Test
public void testRoute() throws BucketStatsException {
    String route = "default";
    BucketId bucketId = bucketIdFactory.getBucketId(new DocumentId("id:ns:type::another"));
    GetBucketListReply reply = new GetBucketListReply();
    reply.getBuckets().add(new GetBucketListReply.BucketInfo(bucketId, "I like turtles!"));
    when(mockedSession.syncSend(any())).thenReturn(reply);
    BucketStatsRetriever retriever = new BucketStatsRetriever(mockedFactory, route, t -> {
    });
    retriever.retrieveBucketList(new BucketId(0), bucketSpace);
    verify(mockedSession).syncSend(argThat(new ArgumentMatcher<Message>() {

        @Override
        public boolean matches(Object o) {
            return ((Message) o).getRoute().equals(Route.parse(route));
        }
    }));
}
Also used : GetBucketListReply(com.yahoo.documentapi.messagebus.protocol.GetBucketListReply) ArgumentMatcher(org.mockito.ArgumentMatcher) DocumentId(com.yahoo.document.DocumentId) BucketId(com.yahoo.document.BucketId) Test(org.junit.Test)

Example 44 with BucketId

use of com.yahoo.document.BucketId in project vespa by vespa-engine.

the class BucketStatsRetrieverTest method testShouldFailOnReplyError.

@Test(expected = BucketStatsException.class)
public void testShouldFailOnReplyError() throws BucketStatsException {
    GetBucketListReply reply = new GetBucketListReply();
    reply.addError(new Error(0, "errormsg"));
    when(mockedSession.syncSend(any())).thenReturn(reply);
    createRetriever().retrieveBucketList(new BucketId(1), bucketSpace);
}
Also used : GetBucketListReply(com.yahoo.documentapi.messagebus.protocol.GetBucketListReply) Error(com.yahoo.messagebus.Error) BucketId(com.yahoo.document.BucketId) Test(org.junit.Test)

Example 45 with BucketId

use of com.yahoo.document.BucketId in project vespa by vespa-engine.

the class BucketSelectorTestCase method assertBucketCount.

public void assertBucketCount(String expr, int count) throws Exception {
    BucketIdFactory factory = new BucketIdFactory();
    BucketSelector selector = new BucketSelector(factory);
    Set<BucketId> buckets = selector.getBucketList(expr);
    assertEquals(count, buckets == null ? 0 : buckets.size());
}
Also used : BucketId(com.yahoo.document.BucketId) BucketIdFactory(com.yahoo.document.BucketIdFactory)

Aggregations

BucketId (com.yahoo.document.BucketId)67 BucketIdFactory (com.yahoo.document.BucketIdFactory)25 Test (org.junit.Test)24 ProgressToken (com.yahoo.documentapi.ProgressToken)22 VisitorIterator (com.yahoo.documentapi.VisitorIterator)19 DocumentId (com.yahoo.document.DocumentId)10 ClusterState (com.yahoo.vdslib.state.ClusterState)6 GetBucketListReply (com.yahoo.documentapi.messagebus.protocol.GetBucketListReply)5 Error (com.yahoo.messagebus.Error)5 TreeSet (java.util.TreeSet)5 MessageBusVisitorSession (com.yahoo.documentapi.messagebus.MessageBusVisitorSession)4 ParseException (com.yahoo.document.select.parser.ParseException)3 com.yahoo.documentapi (com.yahoo.documentapi)3 LoadType (com.yahoo.documentapi.messagebus.loadtypes.LoadType)3 com.yahoo.documentapi.messagebus.protocol (com.yahoo.documentapi.messagebus.protocol)3 com.yahoo.messagebus (com.yahoo.messagebus)3 Result (com.yahoo.messagebus.Result)3 Route (com.yahoo.messagebus.routing.Route)3 RouteSpec (com.yahoo.messagebus.routing.RouteSpec)3 RoutingTable (com.yahoo.messagebus.routing.RoutingTable)3