use of com.yahoo.vdslib.state.ClusterState in project vespa by vespa-engine.
the class StateWaiter method waitForState.
/**
* WARNING: If timeIntervalToProvokeRetry is set != 0 that means time will can be set far into future
* and thus hit various unintended timeout periods. Only auto-step time if this is a non-issue.
*/
public void waitForState(String stateRegex, long timeout, long timeIntervalToProvokeRetry) {
Pattern p = Pattern.compile(stateRegex);
long startTime = System.currentTimeMillis();
final long endTime = startTime + timeout;
int iteration = 0;
while (true) {
ClusterState currentClusterState;
synchronized (timer) {
currentClusterState = current;
if (currentClusterState != null) {
Matcher m = p.matcher(currentClusterState.toString());
if (m.matches()) {
return;
}
}
try {
if (timeIntervalToProvokeRetry == 0) {
timer.wait(endTime - startTime);
} else {
if (++iteration % 10 == 0) {
timer.advanceTime(timeIntervalToProvokeRetry);
}
timer.wait(10);
}
} catch (InterruptedException e) {
}
}
startTime = System.currentTimeMillis();
if (startTime >= endTime) {
throw new IllegalStateException("Timeout. Did not find a state matching " + stateRegex + " within timeout of " + timeout + " milliseconds. Current state is " + currentClusterState);
}
}
}
use of com.yahoo.vdslib.state.ClusterState in project vespa by vespa-engine.
the class StateWaiter method waitForInitProgressPassed.
public void waitForInitProgressPassed(Node node, double minProgress, int timeoutMS) {
long startTime = System.currentTimeMillis();
long endTime = startTime + timeoutMS;
while (true) {
ClusterState currentClusterState;
synchronized (timer) {
currentClusterState = current;
if (currentClusterState != null) {
if (currentClusterState.getNodeState(node).getInitProgress() >= minProgress) {
return;
}
}
try {
timer.wait(endTime - startTime);
} catch (InterruptedException e) {
}
}
startTime = System.currentTimeMillis();
if (startTime >= endTime) {
throw new IllegalStateException("Timeout. Did not get to " + minProgress + " init progress on node " + node + " within timeout of " + timeoutMS + " ms. Current init progress is " + currentClusterState.getNodeState(node).getInitProgress());
}
}
}
use of com.yahoo.vdslib.state.ClusterState in project vespa by vespa-engine.
the class DistributionTestCase method testDistributorNoGroupTakeover.
@Test
public void testDistributorNoGroupTakeover() throws Exception {
test = new DistributionTestFactory("hierarchical-grouping-distributor-notakeover").setDistribution(buildHierarchicalConfig(6, 3, 1, "1|2|*", 3).distributor_auto_ownership_transfer_on_whole_group_down(false)).setNodeType(NodeType.DISTRIBUTOR).setClusterState(new ClusterState("distributor:2 storage:9"));
int[] counts = new int[10];
int noneExisting = 0;
for (BucketId bucket : getTestBuckets()) {
DistributionTestFactory.Test t = test.recordResult(bucket);
List<Integer> nodes = t.getNodes();
if (nodes.isEmpty()) {
++noneExisting;
t.assertFailure(DistributionTestFactory.Failure.NO_DISTRIBUTORS_AVAILABLE);
} else {
t.assertNodeCount(1);
for (int i : nodes) {
++counts[i];
}
}
}
for (int i = 2; i < 10; ++i) {
assertEquals(0, counts[i]);
}
for (int i = 0; i < 2; ++i) {
assertTrue(counts[i] > 0);
}
assertEquals(15, noneExisting);
}
use of com.yahoo.vdslib.state.ClusterState in project vespa by vespa-engine.
the class DistributionTestCase method testMinimalMovement.
@Test
public void testMinimalMovement() throws Exception {
test = new DistributionTestFactory("minimal-movement").setClusterState(new ClusterState("distributor:4 .2.s:d"));
DistributionTestFactory control = new DistributionTestFactory("minimal-movement-reference").setClusterState(new ClusterState("distributor:4"));
int moved = 0;
int staying = 0;
for (BucketId bucket : getTestBuckets()) {
DistributionTestFactory.Test org = control.recordResult(bucket).assertNodeCount(1);
DistributionTestFactory.Test res = test.recordResult(bucket).assertNodeCount(1);
if (org.getNodes().get(0) == 2) {
assertTrue(res.getNodes().get(0) != 2);
++moved;
} else {
assertEquals(org, res);
++staying;
}
}
assertEquals(63, moved);
assertEquals(81, staying);
}
use of com.yahoo.vdslib.state.ClusterState in project vespa by vespa-engine.
the class LegacyIndexPageRequestHandler method calculateDerivedClusterStateTransitions.
private List<ClusterStateTransition> calculateDerivedClusterStateTransitions(ClusterStateHistoryEntry currentEntry, ClusterStateHistoryEntry lastEntry) {
List<ClusterStateTransition> result = new ArrayList<>();
currentEntry.getDerivedBucketSpaceStates().forEach((bucketSpace, currentState) -> {
ClusterState lastState = (lastEntry != null ? lastEntry.getDerivedBucketSpaceStates().get(bucketSpace) : null);
if ((!currentState.equals(currentEntry.getBaselineState())) || ((lastState != null) && (!lastState.equals(lastEntry.getBaselineState())))) {
result.add(ClusterStateTransition.forBucketSpace(currentState, lastState, bucketSpace));
}
});
return result;
}
Aggregations