use of com.yahoo.slime.Cursor in project vespa by vespa-engine.
the class ApplicationApiHandler method getGlobalRotationOverride.
private HttpResponse getGlobalRotationOverride(String tenantName, String applicationName, String instanceName, String environment, String region) {
DeploymentId deploymentId = new DeploymentId(ApplicationId.from(tenantName, applicationName, instanceName), ZoneId.from(environment, region));
Slime slime = new Slime();
Cursor c1 = slime.setObject().setArray("globalrotationoverride");
try {
Map<String, EndpointStatus> rotations = controller.applications().getGlobalRotationStatus(deploymentId);
for (String rotation : rotations.keySet()) {
EndpointStatus currentStatus = rotations.get(rotation);
c1.addString(rotation);
Cursor c2 = c1.addObject();
c2.setString("status", currentStatus.getStatus().name());
c2.setString("reason", currentStatus.getReason() == null ? "" : currentStatus.getReason());
c2.setString("agent", currentStatus.getAgent() == null ? "" : currentStatus.getAgent());
c2.setLong("timestamp", currentStatus.getEpoch());
}
} catch (IOException e) {
return ErrorResponse.internalServerError("Unable to get rotation status: " + e.getMessage());
}
return new SlimeJsonResponse(slime);
}
use of com.yahoo.slime.Cursor in project vespa by vespa-engine.
the class ApplicationApiHandler method athenzDomains.
private HttpResponse athenzDomains(HttpRequest request) {
Slime slime = new Slime();
Cursor response = slime.setObject();
Cursor array = response.setArray("data");
for (AthenzDomain athenzDomain : controller.getDomainList(request.getProperty("prefix"))) {
array.addString(athenzDomain.getName());
}
return new SlimeJsonResponse(slime);
}
use of com.yahoo.slime.Cursor in project vespa by vespa-engine.
the class ApplicationApiHandler method toSlime.
private Slime toSlime(ActivateResult result) {
Slime slime = new Slime();
Cursor object = slime.setObject();
object.setString("revisionId", result.revisionId().id());
object.setLong("applicationZipSize", result.applicationZipSizeBytes());
Cursor logArray = object.setArray("prepareMessages");
if (result.prepareResponse().log != null) {
for (Log logMessage : result.prepareResponse().log) {
Cursor logObject = logArray.addObject();
logObject.setLong("time", logMessage.time);
logObject.setString("level", logMessage.level);
logObject.setString("message", logMessage.message);
}
}
Cursor changeObject = object.setObject("configChangeActions");
Cursor restartActionsArray = changeObject.setArray("restart");
for (RestartAction restartAction : result.prepareResponse().configChangeActions.restartActions) {
Cursor restartActionObject = restartActionsArray.addObject();
restartActionObject.setString("clusterName", restartAction.clusterName);
restartActionObject.setString("clusterType", restartAction.clusterType);
restartActionObject.setString("serviceType", restartAction.serviceType);
serviceInfosToSlime(restartAction.services, restartActionObject.setArray("services"));
stringsToSlime(restartAction.messages, restartActionObject.setArray("messages"));
}
Cursor refeedActionsArray = changeObject.setArray("refeed");
for (RefeedAction refeedAction : result.prepareResponse().configChangeActions.refeedActions) {
Cursor refeedActionObject = refeedActionsArray.addObject();
refeedActionObject.setString("name", refeedAction.name);
refeedActionObject.setBool("allowed", refeedAction.allowed);
refeedActionObject.setString("documentType", refeedAction.documentType);
refeedActionObject.setString("clusterName", refeedAction.clusterName);
serviceInfosToSlime(refeedAction.services, refeedActionObject.setArray("services"));
stringsToSlime(refeedAction.messages, refeedActionObject.setArray("messages"));
}
return slime;
}
use of com.yahoo.slime.Cursor in project vespa by vespa-engine.
the class ApplicationApiHandler method setRotationStatus.
private void setRotationStatus(Deployment deployment, Map<String, RotationStatus> healthStatus, Cursor object) {
if (!deployment.zone().environment().equals(Environment.prod))
return;
Cursor bcpStatusObject = object.setObject("bcpStatus");
bcpStatusObject.setString("rotationStatus", findRotationStatus(deployment, healthStatus).name());
}
use of com.yahoo.slime.Cursor in project vespa by vespa-engine.
the class ApplicationApiHandler method toSlime.
private void toSlime(Cursor response, DeploymentId deploymentId, Deployment deployment, HttpRequest request) {
Cursor serviceUrlArray = response.setArray("serviceUrls");
controller.applications().getDeploymentEndpoints(deploymentId).ifPresent(endpoints -> endpoints.forEach(endpoint -> serviceUrlArray.addString(endpoint.toString())));
response.setString("nodes", withPath("/zone/v2/" + deploymentId.zoneId().environment() + "/" + deploymentId.zoneId().region() + "/nodes/v2/node/?&recursive=true&application=" + deploymentId.applicationId().tenant() + "." + deploymentId.applicationId().application() + "." + deploymentId.applicationId().instance(), request.getUri()).toString());
controller.zoneRegistry().getLogServerUri(deploymentId).ifPresent(elkUrl -> response.setString("elkUrl", elkUrl.toString()));
response.setString("yamasUrl", monitoringSystemUri(deploymentId).toString());
response.setString("version", deployment.version().toFullString());
response.setString("revision", deployment.applicationVersion().id());
response.setLong("deployTimeEpochMs", deployment.at().toEpochMilli());
controller.zoneRegistry().getDeploymentTimeToLive(deploymentId.zoneId()).ifPresent(deploymentTimeToLive -> response.setLong("expiryTimeEpochMs", deployment.at().plus(deploymentTimeToLive).toEpochMilli()));
controller.applications().get(deploymentId.applicationId()).flatMap(application -> application.deploymentJobs().projectId()).ifPresent(i -> response.setString("screwdriverId", String.valueOf(i)));
sourceRevisionToSlime(deployment.applicationVersion().source(), response);
// Cost
DeploymentCost appCost = deployment.calculateCost();
Cursor costObject = response.setObject("cost");
toSlime(appCost, costObject);
// Metrics
DeploymentMetrics metrics = deployment.metrics();
Cursor metricsObject = response.setObject("metrics");
metricsObject.setDouble("queriesPerSecond", metrics.queriesPerSecond());
metricsObject.setDouble("writesPerSecond", metrics.writesPerSecond());
metricsObject.setDouble("documentCount", metrics.documentCount());
metricsObject.setDouble("queryLatencyMillis", metrics.queryLatencyMillis());
metricsObject.setDouble("writeLatencyMillis", metrics.writeLatencyMillis());
}
Aggregations