use of com.yahoo.vdslib.state.NodeType in project vespa by vespa-engine.
the class SlobrokClient method getSlobrokData.
private Map<Node, SlobrokData> getSlobrokData(String pattern) {
Map<Node, SlobrokData> result = new TreeMap<>();
Mirror.Entry[] entries = mirror.lookup(pattern);
log.log(LogLevel.SPAM, "Looking for slobrok entries with pattern '" + pattern + "'. Found " + entries.length + " entries.");
for (Mirror.Entry entry : entries) {
StringTokenizer st = new StringTokenizer(entry.getName(), "/");
String addressType = st.nextToken();
// skip
String cluster = st.nextToken();
NodeType nodeType = NodeType.get(st.nextToken());
Integer nodeIndex = Integer.valueOf(st.nextToken());
// skip
String service = (st.hasMoreTokens() ? st.nextToken() : "");
assert (addressType.equals("storage"));
Node n = new Node(nodeType, nodeIndex);
result.put(n, new SlobrokData(n, entry.getSpec()));
}
return result;
}
use of com.yahoo.vdslib.state.NodeType in project vespa by vespa-engine.
the class ClusterStateRequest method calculateResult.
@Override
public Response.ClusterResponse calculateResult(RemoteClusterControllerTask.Context context) throws StateRestApiException {
Response.ClusterResponse result = new Response.ClusterResponse();
result.addState("generated", new Response.UnitStateImpl(context.currentConsolidatedState.getClusterState()));
for (NodeType type : NodeType.getTypes()) {
Id.Service serviceId = new Id.Service(id, type);
if (recursive > 0) {
ServiceStateRequest ssr = new ServiceStateRequest(serviceId, recursive - 1);
result.addEntry("service", type.toString(), ssr.calculateResult(context));
} else {
result.addLink("service", type.toString(), serviceId.toString());
}
}
result.setPublishedState(bundleToDistributionState(context.publishedClusterStateBundle));
return result;
}
use of com.yahoo.vdslib.state.NodeType in project vespa by vespa-engine.
the class LegacyNodePageRequestHandler method handle.
@Override
public StatusPageResponse handle(StatusPageServer.HttpRequest request) {
Matcher m = nodePattern.matcher(request.getPath());
if (!m.matches()) {
throw new IllegalStateException("Node request handler invoked but failed to match path");
}
TimeZone tz = TimeZone.getTimeZone("UTC");
long currentTime = timer.getCurrentTimeInMillis();
NodeType nodeType = NodeType.get(m.group(1));
int index = Integer.valueOf(m.group(2));
Node node = new Node(nodeType, index);
StatusPageResponse response = new StatusPageResponse();
response.setContentType("text/html");
StringBuilder content = new StringBuilder();
content.append("<!-- Answer to request " + request + " -->\n");
response.writeHtmlHeader(content, "Cluster Controller Status Page - Node status for " + node);
content.append("<p>UTC time when creating this page: ").append(RealTimer.printDateNoMilliSeconds(currentTime, tz)).append("</p>");
content.append("[ <a href=\"..\">Back to cluster overview</a> ] <br><br>");
eventLog.writeHtmlState(content, node);
NodeInfo nodeInfo = cluster.getNodeInfo(node);
content.append("<h2>Host info</h2>\n");
if (nodeInfo.getHostInfo() != null) {
content.append("<pre>\n").append(nodeInfo.getHostInfo().getRawCreationString()).append("\n</pre>\n");
} else {
content.append("Not retrieved\n");
}
response.writeHtmlFooter(content, "");
response.writeContent(content.toString());
return response;
}
use of com.yahoo.vdslib.state.NodeType in project vespa by vespa-engine.
the class EventDiffCalculator method emitPerNodeDiffEvents.
private static void emitPerNodeDiffEvents(final PerStateParams params, final List<Event> events) {
final ContentCluster cluster = params.cluster;
final ClusterState fromState = params.fromState.getClusterState();
final ClusterState toState = params.toState.getClusterState();
for (ConfiguredNode node : cluster.getConfiguredNodes().values()) {
for (NodeType nodeType : NodeType.getTypes()) {
final Node n = new Node(nodeType, node.index());
emitSingleNodeEvents(params, events, cluster, fromState, toState, n);
}
}
}
use of com.yahoo.vdslib.state.NodeType in project vespa by vespa-engine.
the class StateChangeHandlerTest method startWithStableStateClusterWithNodesUp.
private void startWithStableStateClusterWithNodesUp() {
for (NodeType type : NodeType.getTypes()) {
for (ConfiguredNode i : configuredNodes) {
NodeInfo nodeInfo = cluster.clusterInfo().setRpcAddress(new Node(type, i.index()), null);
nodeInfo.markRpcAddressLive();
nodeStateChangeHandler.handleNewReportedNodeState(currentClusterState(), nodeInfo, new NodeState(type, State.UP), null);
nodeInfo.setReportedState(new NodeState(type, State.UP), clock.getCurrentTimeInMillis());
}
}
for (NodeType type : NodeType.getTypes()) {
for (ConfiguredNode i : configuredNodes) {
Node n = new Node(type, i.index());
assertEquals(State.UP, currentClusterState().getNodeState(n).getState());
}
}
clock.advanceTime(config.stableStateTime);
}
Aggregations