Search in sources :

Example 61 with BucketId

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

the class VisitorIteratorTestCase method testRangeDistributionBitInitialDrop.

// Test a drop from 31->11 bits upon iteration start
public void testRangeDistributionBitInitialDrop() throws ParseException {
    int db = 31;
    BucketIdFactory idFactory = new BucketIdFactory();
    ProgressToken p = new ProgressToken();
    VisitorIterator iter = VisitorIterator.createFromDocumentSelection("id.group != \"yahoo.com\"", idFactory, db, p);
    VisitorIterator.BucketProgress[] bp = new VisitorIterator.BucketProgress[3];
    bp[0] = iter.getNext();
    bp[1] = iter.getNext();
    bp[2] = iter.getNext();
    iter.update(bp[2].getSuperbucket(), new BucketId());
    iter.update(bp[1].getSuperbucket(), new BucketId());
    assertEquals(p.getActiveBucketCount(), 1);
    iter.setDistributionBitCount(11);
    assertFalse(iter.hasNext());
    assertFalse(iter.isDone());
    assertEquals(p.getActiveBucketCount(), 1);
    // Updating the active bucket allows the merging to take place
    iter.update(new BucketId(31, 0), new BucketId());
    assertTrue(iter.hasNext());
    assertFalse(iter.isDone());
    // All pending buckets should have been merged down to just 1 now
    // Update: now rather gets reset
    assertEquals(p.getPendingBucketCount(), 0);
    assertEquals(p.getActiveBucketCount(), 0);
    assertEquals(p.getFinishedBucketCount(), 0);
    assertEquals(p.getBucketCursor(), 0);
    bp[0] = iter.getNext();
    assertEquals(bp[0].getSuperbucket(), new BucketId(11, 0));
}
Also used : VisitorIterator(com.yahoo.documentapi.VisitorIterator) BucketId(com.yahoo.document.BucketId) BucketIdFactory(com.yahoo.document.BucketIdFactory) ProgressToken(com.yahoo.documentapi.ProgressToken)

Example 62 with BucketId

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

the class StoragePolicy method doSelect.

@Override
public void doSelect(RoutingContext context) {
    if (context.shouldTrace(1)) {
        context.trace(1, "Selecting route");
    }
    BucketId bucketId = bucketIdCalculator.handleBucketIdCalculation(context);
    if (context.hasReply())
        return;
    String targetSpec = distributorSelectionLogic.getTargetSpec(context, bucketId);
    if (context.hasReply())
        return;
    if (targetSpec != null) {
        Route route = new Route(context.getRoute());
        route.setHop(0, new Hop().addDirective(new VerbatimDirective(targetSpec)));
        context.addChild(route);
    } else {
        context.setError(ErrorCode.NO_ADDRESS_FOR_SERVICE, "Could not resolve any distributors to send to in cluster " + parameters.clusterName);
    }
}
Also used : BucketId(com.yahoo.document.BucketId)

Example 63 with BucketId

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

the class MessageBusVisitorSessionTestCase method testVisitingCompletedFromSufficientFirstPassHits.

@Test
public void testVisitingCompletedFromSufficientFirstPassHits() {
    VisitorParameters visitorParameters = createVisitorParameters("id.user==1234");
    visitorParameters.setMaxFirstPassHits(10);
    ReplyModifier replyModifier1 = (reply) -> {
        VisitorStatistics stats = new VisitorStatistics();
        stats.setBucketsVisited(1);
        stats.setDocumentsReturned(9);
        reply.setVisitorStatistics(stats);
        reply.setLastBucket(new BucketId(33, 1234 | (1L << 32)));
    };
    ReplyModifier replyModifier2 = (reply) -> {
        VisitorStatistics stats = new VisitorStatistics();
        stats.setBucketsVisited(1);
        stats.setDocumentsReturned(1);
        reply.setVisitorStatistics(stats);
        reply.setLastBucket(new BucketId(34, 1234 | (1L << 33)));
    };
    doTestEarlyCompletion(visitorParameters, replyModifier1, replyModifier2);
}
Also used : java.util(java.util) CyclicBarrier(java.util.concurrent.CyclicBarrier) com.yahoo.documentapi(com.yahoo.documentapi) com.yahoo.messagebus(com.yahoo.messagebus) DocumentId(com.yahoo.document.DocumentId) ParseException(com.yahoo.document.select.parser.ParseException) com.yahoo.documentapi.messagebus.protocol(com.yahoo.documentapi.messagebus.protocol) Test(org.junit.Test) Callable(java.util.concurrent.Callable) MessageBusVisitorSession(com.yahoo.documentapi.messagebus.MessageBusVisitorSession) Result(com.yahoo.messagebus.Result) Error(com.yahoo.messagebus.Error) RoutingTable(com.yahoo.messagebus.routing.RoutingTable) TimeUnit(java.util.concurrent.TimeUnit) Route(com.yahoo.messagebus.routing.Route) RoutingTableSpec(com.yahoo.messagebus.routing.RoutingTableSpec) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) Charset(java.nio.charset.Charset) VisitorStatistics(com.yahoo.vdslib.VisitorStatistics) LoadType(com.yahoo.documentapi.messagebus.loadtypes.LoadType) Assert(org.junit.Assert) RouteSpec(com.yahoo.messagebus.routing.RouteSpec) BucketId(com.yahoo.document.BucketId) Assert.assertEquals(org.junit.Assert.assertEquals) VisitorStatistics(com.yahoo.vdslib.VisitorStatistics) BucketId(com.yahoo.document.BucketId) Test(org.junit.Test)

Example 64 with BucketId

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

the class MessageBusVisitorSessionTestCase method testVisitingCompletedFromSecondPassHits.

@Test
public void testVisitingCompletedFromSecondPassHits() {
    VisitorParameters visitorParameters = createVisitorParameters("id.user==1234");
    visitorParameters.setMaxTotalHits(10);
    ReplyModifier replyModifier1 = (reply) -> {
        VisitorStatistics stats = new VisitorStatistics();
        stats.setBucketsVisited(1);
        stats.setDocumentsReturned(5);
        stats.setSecondPassDocumentsReturned(4);
        reply.setVisitorStatistics(stats);
        reply.setLastBucket(new BucketId(33, 1234 | (1L << 32)));
    };
    ReplyModifier replyModifier2 = (reply) -> {
        VisitorStatistics stats = new VisitorStatistics();
        stats.setBucketsVisited(1);
        stats.setSecondPassDocumentsReturned(1);
        reply.setVisitorStatistics(stats);
        reply.setLastBucket(new BucketId(34, 1234 | (1L << 33)));
    };
    doTestEarlyCompletion(visitorParameters, replyModifier1, replyModifier2);
}
Also used : java.util(java.util) CyclicBarrier(java.util.concurrent.CyclicBarrier) com.yahoo.documentapi(com.yahoo.documentapi) com.yahoo.messagebus(com.yahoo.messagebus) DocumentId(com.yahoo.document.DocumentId) ParseException(com.yahoo.document.select.parser.ParseException) com.yahoo.documentapi.messagebus.protocol(com.yahoo.documentapi.messagebus.protocol) Test(org.junit.Test) Callable(java.util.concurrent.Callable) MessageBusVisitorSession(com.yahoo.documentapi.messagebus.MessageBusVisitorSession) Result(com.yahoo.messagebus.Result) Error(com.yahoo.messagebus.Error) RoutingTable(com.yahoo.messagebus.routing.RoutingTable) TimeUnit(java.util.concurrent.TimeUnit) Route(com.yahoo.messagebus.routing.Route) RoutingTableSpec(com.yahoo.messagebus.routing.RoutingTableSpec) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) Charset(java.nio.charset.Charset) VisitorStatistics(com.yahoo.vdslib.VisitorStatistics) LoadType(com.yahoo.documentapi.messagebus.loadtypes.LoadType) Assert(org.junit.Assert) RouteSpec(com.yahoo.messagebus.routing.RouteSpec) BucketId(com.yahoo.document.BucketId) Assert.assertEquals(org.junit.Assert.assertEquals) VisitorStatistics(com.yahoo.vdslib.VisitorStatistics) BucketId(com.yahoo.document.BucketId) Test(org.junit.Test)

Example 65 with BucketId

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

the class MessageBusVisitorSessionTestCase method createVisitorToString.

private String createVisitorToString(CreateVisitorMessage msg) {
    StringBuilder sb = new StringBuilder();
    sb.append("CreateVisitorMessage(buckets=[\n");
    for (BucketId id : msg.getBuckets()) {
        sb.append(id).append("\n");
    }
    sb.append("]\n");
    if (!"".equals(msg.getDocumentSelection())) {
        sb.append("selection='").append(msg.getDocumentSelection()).append("'\n");
    }
    if (msg.getTimeRemaining() != 5 * 60 * 1000) {
        sb.append("time remaining=").append(msg.getTimeRemaining()).append("\n");
    }
    if (msg.getFromTimestamp() != 0) {
        sb.append("from timestamp=").append(msg.getFromTimestamp()).append("\n");
    }
    if (msg.getToTimestamp() != 0) {
        sb.append("to timestamp=").append(msg.getToTimestamp()).append("\n");
    }
    if (msg.getMaxPendingReplyCount() != 32) {
        sb.append("max pending=").append(msg.getMaxPendingReplyCount()).append("\n");
    }
    if (!"[all]".equals(msg.getFieldSet())) {
        sb.append("fieldset=").append(msg.getFieldSet()).append("\n");
    }
    if (msg.getVisitInconsistentBuckets()) {
        sb.append("visit inconsistent=").append(msg.getVisitInconsistentBuckets()).append("\n");
    }
    if (msg.getVisitRemoves()) {
        sb.append("visit removes=").append(msg.getVisitRemoves()).append("\n");
    }
    if (!msg.getParameters().isEmpty()) {
        sb.append("parameters=[\n");
        for (Map.Entry<String, byte[]> kv : msg.getParameters().entrySet()) {
            sb.append(kv.getKey()).append(" -> ");
            sb.append(new String(kv.getValue(), Charset.defaultCharset()));
            sb.append("\n");
        }
        sb.append("]\n");
    }
    if (msg.getRoute() != null && !"storage".equals(msg.getRoute().toString())) {
        sb.append("route=").append(msg.getRoute()).append("\n");
    }
    if (msg.getVisitorOrdering() != 0) {
        sb.append("ordering=").append(msg.getVisitorOrdering()).append("\n");
    }
    if (msg.getMaxBucketsPerVisitor() != 1) {
        sb.append("max buckets per visitor=").append(msg.getMaxBucketsPerVisitor()).append("\n");
    }
    if (msg.getLoadType() != LoadType.DEFAULT) {
        sb.append("load type=").append(msg.getLoadType().getName()).append("\n");
    }
    if (msg.getPriority() != DocumentProtocol.Priority.NORMAL_3) {
        sb.append("priority=").append(msg.getPriority()).append("\n");
    }
    if (!"DumpVisitor".equals(msg.getLibraryName())) {
        sb.append("visitor library=").append(msg.getLibraryName()).append("\n");
    }
    if (msg.getTrace().getLevel() != 0) {
        sb.append("trace level=").append(msg.getTrace().getLevel()).append("\n");
    }
    sb.append(")");
    return sb.toString();
}
Also used : BucketId(com.yahoo.document.BucketId)

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