use of com.yahoo.vespa.clustercontroller.core.hostinfo.HostInfo in project vespa by vespa-engine.
the class NodeStateGatherer method processResponses.
/**
* Reads replies to get node state requests and create events.
*/
public boolean processResponses(NodeStateOrHostInfoChangeHandler listener) {
boolean processedAnyResponses = false;
long currentTime = timer.getCurrentTimeInMillis();
synchronized (monitor) {
for (GetNodeStateRequest req : replies) {
processedAnyResponses = true;
NodeInfo info = req.getNodeInfo();
if (!info.isPendingGetNodeStateRequest(req)) {
log.log(LogLevel.DEBUG, "Ignoring getnodestate response from " + info.getNode() + " as request replied to is not the most recent pending request.");
continue;
}
info.removePendingGetNodeStateRequest(req);
GetNodeStateRequest.Reply reply = req.getReply();
if (reply.isError()) {
if (reply.getReturnCode() != ErrorCode.ABORT) {
NodeState newState = handleError(req, info, currentTime);
if (newState != null) {
listener.handleNewNodeState(info, newState.clone());
info.setReportedState(newState, currentTime);
} else {
log.log(LogLevel.DEBUG, "Ignoring get node state error. Need to resend");
}
} else {
log.log(LogLevel.DEBUG, "Ignoring getnodestate response from " + info.getNode() + " as it was aborted by client");
}
continue;
}
try {
NodeState state = NodeState.deserialize(info.getNode().getType(), reply.getStateString());
// For version 0 responses, we poll, so we likely have not altered the state
if (!state.equals(info.getReportedState()))
listener.handleNewNodeState(info, state.clone());
info.setReportedState(state, currentTime);
} catch (Exception e) {
log.log(LogLevel.WARNING, "Failed to process get node state response", e);
info.setReportedState(new NodeState(info.getNode().getType(), State.DOWN), currentTime);
}
// Important: The old host info should be accessible in info.getHostInfo(), see interface.
// Therefore, setHostInfo() must be called AFTER handleUpdatedHostInfo().
HostInfo hostInfo = HostInfo.createHostInfo(reply.getHostInfo());
listener.handleUpdatedHostInfo(info, hostInfo);
info.setHostInfo(hostInfo);
}
replies.clear();
}
return processedAnyResponses;
}
use of com.yahoo.vespa.clustercontroller.core.hostinfo.HostInfo in project vespa by vespa-engine.
the class ClusterStateViewTest method testSuccessCase.
@Test
public void testSuccessCase() {
when(nodeInfo.isDistributor()).thenReturn(true);
HostInfo hostInfo = HostInfo.createHostInfo("{" + " \"cluster-state-version\": 101," + " \"distributor\": {\n" + " \"storage-nodes\": [\n" + " {\n" + " \"node-index\": 3\n" + " }\n" + " ]}}");
when(nodeInfo.getNodeIndex()).thenReturn(3);
when(clusterState.getVersion()).thenReturn(101);
clusterStateView.handleUpdatedHostInfo(nodeInfo, hostInfo);
verify(statsAggregator).updateForDistributor(3, StorageNodeStatsBridge.generate(hostInfo.getDistributor()));
}
use of com.yahoo.vespa.clustercontroller.core.hostinfo.HostInfo in project vespa by vespa-engine.
the class NodeStateChangeChecker method canSetStateDownPermanently.
private Result canSetStateDownPermanently(NodeInfo nodeInfo, ClusterState clusterState) {
State reportedState = nodeInfo.getReportedState().getState();
if (reportedState != State.UP) {
return Result.createDisallowed("Reported state (" + reportedState + ") is not UP, so no bucket data is available");
}
State currentState = clusterState.getNodeState(nodeInfo.getNode()).getState();
if (currentState != State.RETIRED) {
return Result.createDisallowed("Only retired nodes are allowed to be set to DOWN in safe mode - is " + currentState);
}
Result thresholdCheckResult = checkUpThresholds(clusterState);
if (!thresholdCheckResult.settingWantedStateIsAllowed()) {
return thresholdCheckResult;
}
HostInfo hostInfo = nodeInfo.getHostInfo();
Integer hostInfoNodeVersion = hostInfo.getClusterStateVersionOrNull();
int clusterControllerVersion = clusterState.getVersion();
if (hostInfoNodeVersion == null || hostInfoNodeVersion != clusterControllerVersion) {
return Result.createDisallowed("Cluster controller at version " + clusterControllerVersion + " got info for storage node " + nodeInfo.getNodeIndex() + " at a different version " + hostInfoNodeVersion);
}
Optional<Metrics.Value> bucketsMetric = hostInfo.getMetrics().getValue(BUCKETS_METRIC_NAME);
if (!bucketsMetric.isPresent() || bucketsMetric.get().getLast() == null) {
return Result.createDisallowed("Missing last value of the " + BUCKETS_METRIC_NAME + " metric for storage node " + nodeInfo.getNodeIndex());
}
long lastBuckets = bucketsMetric.get().getLast();
if (lastBuckets > 0) {
return Result.createDisallowed("The storage node manages " + lastBuckets + " buckets");
}
return Result.allowSettingOfWantedState();
}
Aggregations