Search in sources :

Example 26 with BucketId

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

the class MessageBusVisitorSessionTestCase method testSkipBucketOnFatalErrorReply.

@Test
public void testSkipBucketOnFatalErrorReply() {
    VisitorParameters visitorParameters = createVisitorParameters("");
    visitorParameters.skipBucketsOnFatalErrors(true);
    MockComponents mc = createDefaultMock(visitorParameters);
    mc.controlHandler.resetMock();
    mc.visitorSession.start();
    // create visitors
    mc.executor.expectAndProcessTasks(1);
    assertEquals(2, mc.sender.getMessageCount());
    replyErrorToCreateVisitor(mc.sender, new Error(DocumentProtocol.ERROR_INTERNAL_FAILURE, "borked"));
    mc.executor.expectAndProcessTasks(1);
    // no more buckets to send for--all either failed or active
    mc.executor.expectNoTasks();
    assertEquals(1, mc.sender.getMessageCount());
    assertFalse(mc.controlHandler.isDone());
    // partial bucket progress which must be remembered
    assertEquals("CreateVisitorMessage(buckets=[\n" + "BucketId(0x0400000000000001)\n" + "BucketId(0x0000000000000000)\n" + "]\n)", replyToCreateVisitor(mc.sender, new BucketId(33, 1L | (1L << 32))));
    // reply
    mc.executor.expectAndProcessTasks(1);
    // create visitors
    mc.executor.expectAndProcessTasks(1);
    assertEquals(1, mc.sender.getMessageCount());
    assertFalse(mc.controlHandler.isDone());
    // then fail bucket #2
    replyErrorToCreateVisitor(mc.sender, new Error(DocumentProtocol.ERROR_INTERNAL_FAILURE, "more borked"));
    // reply
    mc.executor.expectAndProcessTasks(1);
    mc.executor.expectNoTasks();
    assertEquals(0, mc.sender.getMessageCount());
    assertTrue(mc.controlHandler.isDone());
    // make sure progress token was updated with bad buckets and
    // remembers the initial error message
    assertNotNull(mc.controlHandler.getProgress());
    assertTrue(mc.controlHandler.getProgress().containsFailedBuckets());
    assertEquals("INTERNAL_FAILURE: borked", mc.controlHandler.getProgress().getFirstErrorMsg());
    assertEquals("#total: 2\n" + "#finished: 2\n" + "failed:\n" + "BucketId(0x0400000000000000) : BucketId(0x0000000000000000)\n" + "BucketId(0x0400000000000001) : BucketId(0x8400000100000001)\n", dumpProgressToken(mc.controlHandler.getProgress()));
    assertEquals("onVisitorError : INTERNAL_FAILURE: borked\n" + "onProgress : 0 active, 1 pending, 1 finished, 2 total\n" + "onVisitorStatistics : 0 buckets visited, 0 docs returned\n" + "onVisitorError : INTERNAL_FAILURE: more borked\n" + "onDone : FAILURE - 'INTERNAL_FAILURE: borked'\n", mc.controlHandler.toString());
}
Also used : Error(com.yahoo.messagebus.Error) BucketId(com.yahoo.document.BucketId) Test(org.junit.Test)

Example 27 with BucketId

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

the class Simulator method getIdealTarget.

private Integer getIdealTarget(String idString, String clusterState) {
    DocumentId did = new DocumentId(idString);
    BucketIdFactory factory = new BucketIdFactory();
    BucketId bid = factory.getBucketId(did);
    try {
        return policyFactory.getLastParameters().createDistribution(null).getIdealDistributorNode(new ClusterState(clusterState), bid, "uim");
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : DocumentId(com.yahoo.document.DocumentId) BucketId(com.yahoo.document.BucketId) BucketIdFactory(com.yahoo.document.BucketIdFactory)

Example 28 with BucketId

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

the class BucketIdFactoryTestCase method testBidContainsDocId.

public void testBidContainsDocId() {
    DocumentId docId = new DocumentId("userdoc:recovery:18:99999");
    BucketIdFactory factory = new BucketIdFactory(32, 26, 6);
    BucketId bid = new BucketId(16, 0x12L);
    assert (bid.contains(docId, factory));
    // split on '0'
    bid = new BucketId(17, 0x12L);
    assert (bid.contains(docId, factory));
    // split on '1'
    bid = new BucketId(17, (1L << 16) + 0x12L);
    assert (!bid.contains(docId, factory));
}
Also used : DocumentId(com.yahoo.document.DocumentId) BucketId(com.yahoo.document.BucketId) BucketIdFactory(com.yahoo.document.BucketIdFactory)

Example 29 with BucketId

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

the class BucketIdFactoryTestCase method testBucketGeneration.

public void testBucketGeneration() {
    BucketIdFactory factory = new BucketIdFactory(32, 26, 6);
    DocumentId doc1 = new DocumentId(new DocIdString("ns", "spec"));
    DocumentId doc2 = new DocumentId(new DocIdString("ns2", "spec"));
    DocumentId doc3 = new DocumentId(new DocIdString("ns", "spec2"));
    DocumentId userDoc1 = new DocumentId(new UserDocIdString("ns", 0x12, "spec"));
    DocumentId userDoc2 = new DocumentId(new UserDocIdString("ns2", 0x12, "spec2"));
    DocumentId userDoc3 = new DocumentId(new UserDocIdString("ns", 0x13, "spec"));
    DocumentId groupDoc1 = new DocumentId(new GroupDocIdString("ns", "yahoo.com", "spec"));
    DocumentId groupDoc2 = new DocumentId(new GroupDocIdString("ns2", "yahoo.com", "spec2"));
    DocumentId groupDoc3 = new DocumentId(new GroupDocIdString("ns", "yahoo", "spec"));
    DocumentId orderDoc1 = new DocumentId(new OrderDocIdString("ns", "13", 31, 19, 1268182861, "foo"));
    DocumentId orderDoc2 = new DocumentId(new OrderDocIdString("ns", "13", 31, 19, 1205110861, "foo"));
    DocumentId orderDoc3 = new DocumentId(new OrderDocIdString("ns", "13", 31, 19, 1205715661, "foo"));
    DocumentId orderDoc4 = new DocumentId(new OrderDocIdString("ns", "13", 4, 0, 2, "foo"));
    DocumentId orderDoc5 = new DocumentId(new OrderDocIdString("ns", "13", 4, 0, 4, "foo"));
    DocumentId orderDoc6 = new DocumentId(new OrderDocIdString("ns", "13", 4, 0, 11, "foo"));
    BucketId docBucket1 = factory.getBucketId(doc1);
    BucketId docBucket2 = factory.getBucketId(doc2);
    BucketId docBucket3 = factory.getBucketId(doc3);
    BucketId userDocBucket1 = factory.getBucketId(userDoc1);
    BucketId userDocBucket2 = factory.getBucketId(userDoc2);
    BucketId userDocBucket3 = factory.getBucketId(userDoc3);
    BucketId groupDocBucket1 = factory.getBucketId(groupDoc1);
    BucketId groupDocBucket2 = factory.getBucketId(groupDoc2);
    BucketId groupDocBucket3 = factory.getBucketId(groupDoc3);
    BucketId orderDocBucket1 = factory.getBucketId(orderDoc1);
    BucketId orderDocBucket2 = factory.getBucketId(orderDoc2);
    BucketId orderDocBucket3 = factory.getBucketId(orderDoc3);
    BucketId orderDocBucket4 = factory.getBucketId(orderDoc4);
    BucketId orderDocBucket5 = factory.getBucketId(orderDoc5);
    BucketId orderDocBucket6 = factory.getBucketId(orderDoc6);
    assertEquals(new Hex(0xe99703f200000012l), new Hex(userDocBucket1.getRawId()));
    assertEquals(new Hex(0xebfa518a00000012l), new Hex(userDocBucket2.getRawId()));
    assertEquals(new Hex(0xeac1850800000013l), new Hex(userDocBucket3.getRawId()));
    assertEquals(new Hex(0xe90ce4b09a1acd50l), new Hex(groupDocBucket1.getRawId()));
    assertEquals(new Hex(0xe9cedaa49a1acd50l), new Hex(groupDocBucket2.getRawId()));
    assertEquals(new Hex(0xe8cdb18bafe81f24l), new Hex(groupDocBucket3.getRawId()));
    assertEquals(new Hex(0xe980c9abd5fd8d11l), new Hex(docBucket1.getRawId()));
    assertEquals(new Hex(0xeafe870c5f9c37b9l), new Hex(docBucket2.getRawId()));
    assertEquals(new Hex(0xeaebe9473ecbcd69l), new Hex(docBucket3.getRawId()));
    assertEquals(new Hex(0xeae764e90000000dl), new Hex(orderDocBucket1.getRawId()));
    assertEquals(new Hex(0xeacb85f10000000dl), new Hex(orderDocBucket2.getRawId()));
    assertEquals(new Hex(0xea68ddf10000000dl), new Hex(orderDocBucket3.getRawId()));
    assertEquals(new Hex(0xe87526540000000dl), new Hex(orderDocBucket4.getRawId()));
    assertEquals(new Hex(0xea59f8f20000000dl), new Hex(orderDocBucket5.getRawId()));
    assertEquals(new Hex(0xe9eb703d0000000dl), new Hex(orderDocBucket6.getRawId()));
}
Also used : DocumentId(com.yahoo.document.DocumentId) BucketId(com.yahoo.document.BucketId) BucketIdFactory(com.yahoo.document.BucketIdFactory)

Example 30 with BucketId

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

the class ComparisonNode method compare.

private BucketSet compare(BucketIdFactory factory, IdNode id, LiteralNode literal, String operator) {
    String field = id.getField();
    Object value = literal.getValue();
    if (field == null) {
        if (value instanceof String) {
            String name = (String) value;
            if ((operator.equals("=") && name.contains("*")) || (operator.equals("=~") && ((name.contains("*") || name.contains("?"))))) {
                // no idea
                return null;
            }
            return new BucketSet(factory.getBucketId(new DocumentId(name)));
        }
    } else if (field.equalsIgnoreCase("user")) {
        if (value instanceof Long) {
            return new BucketSet(new BucketId(factory.getLocationBitCount(), (Long) value));
        }
    } else if (field.equalsIgnoreCase("group")) {
        if (value instanceof String) {
            String name = (String) value;
            if ((operator.equals("=") && name.contains("*")) || (operator.equals("=~") && ((name.contains("*") || name.contains("?"))))) {
                // no idea
                return null;
            }
            return new BucketSet(new BucketId(factory.getLocationBitCount(), new GroupDocIdString("", name, "").getLocation()));
        }
    } else if (field.equalsIgnoreCase("bucket")) {
        if (value instanceof Long) {
            return new BucketSet(new BucketId((Long) value));
        }
    }
    return null;
}
Also used : DocumentId(com.yahoo.document.DocumentId) GroupDocIdString(com.yahoo.document.idstring.GroupDocIdString) GroupDocIdString(com.yahoo.document.idstring.GroupDocIdString) 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