Search in sources :

Example 36 with BucketId

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

the class DistributionTestCase method testHierarchicalDistributionDeep.

@Test
public void testHierarchicalDistributionDeep() throws Exception {
    System.out.println(new StorDistributionConfig(buildHierarchicalConfig(8, 5, 3, "*|*", 3)));
    test = new DistributionTestFactory("hierarchical-grouping-deep").setNodeCount(500).setDistribution(buildHierarchicalConfig(8, 5, 3, "*|*", 3));
    for (BucketId bucket : getTestBuckets()) {
        test.recordResult(bucket).assertNodeCount(1);
    }
    Set<ConfiguredNode> nodes = test.getDistribution().getNodes();
    // Despite setNodeCount(500) above, the actual distribution config
    // itself only has 375 actual leaf nodes.
    assertEquals(375, nodes.size());
}
Also used : StorDistributionConfig(com.yahoo.vespa.config.content.StorDistributionConfig) BucketId(com.yahoo.document.BucketId) Test(org.junit.Test)

Example 37 with BucketId

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

the class BucketDistributionTestCase method testNumBucketBits.

public void testNumBucketBits() {
    Random rnd = new Random();
    BucketDistribution bd = new BucketDistribution(1, 4);
    for (int i = 0; i <= 0xf; ++i) {
        assertEquals(0, bd.getColumn(new BucketId(32, (rnd.nextLong() << 4) & i)));
    }
    bd = new BucketDistribution(1, 8);
    for (int i = 0; i <= 0xff; ++i) {
        assertEquals(0, bd.getColumn(new BucketId(32, (rnd.nextLong() << 8) & i)));
    }
    bd = new BucketDistribution(1, 16);
    for (int i = 0; i <= 0xffff; ++i) {
        assertEquals(0, bd.getColumn(new BucketId(32, (rnd.nextLong() << 16) & i)));
    }
}
Also used : Random(java.util.Random) BucketId(com.yahoo.document.BucketId)

Example 38 with BucketId

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

the class DistributionTestFactory method parse.

public void parse(String serialized) throws Exception {
    JSONObject json = new JSONObject(serialized);
    upStates = json.getString("up-states");
    nodeCount = json.getInt("redundancy");
    redundancy = json.getInt("redundancy");
    state = new ClusterState(json.getString("cluster-state"));
    distributionConfig = deserializeConfig(json.getString("distribution"));
    nodeType = NodeType.get(json.getString("node-type"));
    JSONArray results = json.getJSONArray("result");
    for (int i = 0; i < results.length(); ++i) {
        JSONObject result = results.getJSONObject(i);
        Test t = new Test(new BucketId(Long.parseLong(result.getString("bucket"), 16)));
        {
            JSONArray nodes = result.getJSONArray("nodes");
            for (int j = 0; j < nodes.length(); ++j) {
                t.nodes.add(nodes.getInt(j));
            }
        }
        if (nodeType == NodeType.STORAGE) {
            JSONArray disks = result.getJSONArray("disks");
            for (int j = 0; j < disks.length(); ++j) {
                t.disks.add(disks.getInt(j));
            }
        }
        t.failure = Failure.valueOf(result.getString("failure"));
        this.results.add(t);
    }
}
Also used : ClusterState(com.yahoo.vdslib.state.ClusterState) JSONObject(org.codehaus.jettison.json.JSONObject) JSONArray(org.codehaus.jettison.json.JSONArray) BucketId(com.yahoo.document.BucketId)

Example 39 with BucketId

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

the class ContinuationHitTest method createMultiBucketProgress.

/**
 * Returns a ProgressToken whose base 64 representation will be _more_ than 76 bytes (MIME line limit)
 */
private ProgressToken createMultiBucketProgress() {
    ProgressToken token = new ProgressToken(16);
    Set<BucketId> buckets = new TreeSet<>();
    buckets.add(new BucketId(58, 0x123456789abcfeffL));
    buckets.add(new BucketId(58, 0x123456789abcfefaL));
    buckets.add(new BucketId(58, 0x123456789abcfefbL));
    // "Prime" the token.
    VisitorIterator.createFromExplicitBucketSet(buckets, 16, token);
    return token;
}
Also used : TreeSet(java.util.TreeSet) BucketId(com.yahoo.document.BucketId) ProgressToken(com.yahoo.documentapi.ProgressToken)

Example 40 with BucketId

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

the class ContinuationHitTest method createSingleBucketProgress.

/**
 * Returns a ProgressToken whose base 64 representation will be _less_ than 76 bytes (MIME line limit)
 */
private ProgressToken createSingleBucketProgress() {
    ProgressToken token = new ProgressToken(16);
    // Use explicit bucket set so we can better control the binary representation
    // of the buckets, and thus the values written as base 64.
    Set<BucketId> buckets = new TreeSet<>();
    // This particular bucket ID will contain +/ chars when output as non-URL safe base 64.
    buckets.add(new BucketId(58, 0x123456789abcfeffL));
    // "Prime" the token.
    VisitorIterator.createFromExplicitBucketSet(buckets, 16, token);
    return token;
}
Also used : TreeSet(java.util.TreeSet) BucketId(com.yahoo.document.BucketId) ProgressToken(com.yahoo.documentapi.ProgressToken)

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