Search in sources :

Example 36 with ClusterState

use of com.yahoo.vdslib.state.ClusterState in project vespa by vespa-engine.

the class DistributionTestFactory method setNodeCount.

public DistributionTestFactory setNodeCount(int count) throws Exception {
    nodeCount = count;
    distributionConfig = deserializeConfig(Distribution.getDefaultDistributionConfig(redundancy, nodeCount));
    state = new ClusterState("distributor:" + nodeCount);
    return this;
}
Also used : ClusterState(com.yahoo.vdslib.state.ClusterState)

Example 37 with ClusterState

use of com.yahoo.vdslib.state.ClusterState 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 38 with ClusterState

use of com.yahoo.vdslib.state.ClusterState in project vespa by vespa-engine.

the class MessageBusVisitorSession method handleWrongDistributionReply.

private void handleWrongDistributionReply(WrongDistributionReply reply) {
    try {
        ClusterState newState = new ClusterState(reply.getSystemState());
        int stateBits = newState.getDistributionBitCount();
        if (stateBits != progress.getIterator().getDistributionBitCount()) {
            log.log(LogLevel.DEBUG, "System state changed; now at " + stateBits + " distribution bits");
            // Update the internal state of the visitor iterator. If we're increasing
            // the number of distribution bits, this may lead to splitting of pending
            // buckets. If we're decreasing, it may lead to merging of pending buckets
            // and potential loss of sub-bucket progress. In either way, the iterator
            // will not let any new buckets out before all active buckets have been
            // updated.
            progress.getIterator().setDistributionBitCount(stateBits);
        }
    } catch (Exception e) {
        log.log(LogLevel.ERROR, "Failed to parse new system state string: " + reply.getSystemState());
        transitionTo(new StateDescription(State.FAILED, "Failed to parse cluster state '" + reply.getSystemState() + "'"));
    }
}
Also used : ClusterState(com.yahoo.vdslib.state.ClusterState) ParseException(com.yahoo.document.select.parser.ParseException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException)

Aggregations

ClusterState (com.yahoo.vdslib.state.ClusterState)38 Test (org.junit.Test)11 NodeState (com.yahoo.vdslib.state.NodeState)10 Node (com.yahoo.vdslib.state.Node)8 BucketId (com.yahoo.document.BucketId)6 ConfiguredNode (com.yahoo.vdslib.distribution.ConfiguredNode)6 State (com.yahoo.vdslib.state.State)4 Request (com.yahoo.jrt.Request)2 Spec (com.yahoo.jrt.Spec)2 Supervisor (com.yahoo.jrt.Supervisor)2 Target (com.yahoo.jrt.Target)2 Transport (com.yahoo.jrt.Transport)2 StringWriter (java.io.StringWriter)2 HashMap (java.util.HashMap)2 ParseException (com.yahoo.document.select.parser.ParseException)1 StringValue (com.yahoo.jrt.StringValue)1 Distribution (com.yahoo.vdslib.distribution.Distribution)1 NodeType (com.yahoo.vdslib.state.NodeType)1 AnnotatedClusterState (com.yahoo.vespa.clustercontroller.core.AnnotatedClusterState)1 HostInfo (com.yahoo.vespa.clustercontroller.core.hostinfo.HostInfo)1