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));
}
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);
}
}
}
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));
}
}));
}
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);
}
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());
}
Aggregations