use of com.yahoo.component.Version in project vespa by vespa-engine.
the class MetricsReporter method updateNodeMetrics.
private void updateNodeMetrics(Node node, Map<HostName, List<ServiceInstance>> servicesByHost) {
Metric.Context context;
Optional<Allocation> allocation = node.allocation();
if (allocation.isPresent()) {
ApplicationId applicationId = allocation.get().owner();
context = getContextAt("state", node.state().name(), "host", node.hostname(), "tenantName", applicationId.tenant().value(), "applicationId", applicationId.serializedForm().replace(':', '.'), "app", toApp(applicationId), "clustertype", allocation.get().membership().cluster().type().name(), "clusterid", allocation.get().membership().cluster().id().value());
long wantedRestartGeneration = allocation.get().restartGeneration().wanted();
metric.set("wantedRestartGeneration", wantedRestartGeneration, context);
long currentRestartGeneration = allocation.get().restartGeneration().current();
metric.set("currentRestartGeneration", currentRestartGeneration, context);
boolean wantToRestart = currentRestartGeneration < wantedRestartGeneration;
metric.set("wantToRestart", wantToRestart ? 1 : 0, context);
Version wantedVersion = allocation.get().membership().cluster().vespaVersion();
double wantedVersionNumber = getVersionAsNumber(wantedVersion);
metric.set("wantedVespaVersion", wantedVersionNumber, context);
Optional<Version> currentVersion = node.status().vespaVersion();
boolean converged = currentVersion.isPresent() && currentVersion.get().equals(wantedVersion);
metric.set("wantToChangeVespaVersion", converged ? 0 : 1, context);
} else {
context = getContextAt("state", node.state().name(), "host", node.hostname());
}
Optional<Version> currentVersion = node.status().vespaVersion();
// Node repo checks for !isEmpty(), so let's do that here too.
if (currentVersion.isPresent() && !currentVersion.get().isEmpty()) {
double currentVersionNumber = getVersionAsNumber(currentVersion.get());
metric.set("currentVespaVersion", currentVersionNumber, context);
}
long wantedRebootGeneration = node.status().reboot().wanted();
metric.set("wantedRebootGeneration", wantedRebootGeneration, context);
long currentRebootGeneration = node.status().reboot().current();
metric.set("currentRebootGeneration", currentRebootGeneration, context);
boolean wantToReboot = currentRebootGeneration < wantedRebootGeneration;
metric.set("wantToReboot", wantToReboot ? 1 : 0, context);
metric.set("wantToRetire", node.status().wantToRetire() ? 1 : 0, context);
metric.set("wantToDeprovision", node.status().wantToDeprovision() ? 1 : 0, context);
metric.set("hardwareFailure", node.status().hardwareFailureDescription().isPresent() ? 1 : 0, context);
metric.set("hardwareDivergence", node.status().hardwareDivergence().isPresent() ? 1 : 0, context);
try {
HostStatus status = orchestrator.getNodeStatus(new HostName(node.hostname()));
boolean allowedToBeDown = status == HostStatus.ALLOWED_TO_BE_DOWN;
metric.set("allowedToBeDown", allowedToBeDown ? 1 : 0, context);
} catch (HostNameNotFoundException e) {
// Ignore
}
long numberOfServices;
HostName hostName = new HostName(node.hostname());
List<ServiceInstance> services = servicesByHost.get(hostName);
if (services == null) {
numberOfServices = 0;
} else {
Map<ServiceStatus, Long> servicesCount = services.stream().collect(Collectors.groupingBy(ServiceInstance::serviceStatus, Collectors.counting()));
numberOfServices = servicesCount.values().stream().mapToLong(Long::longValue).sum();
metric.set("numberOfServicesUp", servicesCount.getOrDefault(ServiceStatus.UP, 0L), context);
metric.set("numberOfServicesNotChecked", servicesCount.getOrDefault(ServiceStatus.NOT_CHECKED, 0L), context);
long numberOfServicesDown = servicesCount.getOrDefault(ServiceStatus.DOWN, 0L);
metric.set("numberOfServicesDown", numberOfServicesDown, context);
metric.set("someServicesDown", (numberOfServicesDown > 0 ? 1 : 0), context);
boolean badNode = NodeFailer.badNode(services);
metric.set("nodeFailerBadNode", (badNode ? 1 : 0), context);
boolean nodeDownInNodeRepo = node.history().event(History.Event.Type.down).isPresent();
metric.set("downInNodeRepo", (nodeDownInNodeRepo ? 1 : 0), context);
}
metric.set("numberOfServices", numberOfServices, context);
}
use of com.yahoo.component.Version in project vespa by vespa-engine.
the class DocumentProtocolTest method requireThat50SerializationPrecedes5xSerialization.
@SuppressWarnings("deprecation")
@Test
public void requireThat50SerializationPrecedes5xSerialization() {
DocumentProtocol protocol = new DocumentProtocol(manager);
GetDocumentMessage prev = new GetDocumentMessage(new DocumentId("doc:scheme:"), "foo");
byte[] buf = protocol.encode(new Version(5, 0), prev);
GetDocumentMessage next = (GetDocumentMessage) protocol.decode(new Version(5, 0), buf);
assertEquals(GetDocumentMessage.DEFAULT_FIELD_SET, next.getFieldSet());
}
use of com.yahoo.component.Version in project vespa by vespa-engine.
the class YqlParser method populateLinguisticsAnnotations.
private void populateLinguisticsAnnotations(OperatorNode<ExpressionOperator> filterExpression) {
Map<?, ?> segmenter = getAnnotation(filterExpression, SEGMENTER, Map.class, null, "segmenter engine and version");
if (segmenter == null) {
segmenterVersion = null;
segmenterBackend = null;
resegment = false;
} else {
segmenterBackend = getMapValue(SEGMENTER, segmenter, SEGMENTER_BACKEND, String.class);
try {
segmenterVersion = new Version(getMapValue(SEGMENTER, segmenter, SEGMENTER_VERSION, String.class));
} catch (RuntimeException e) {
segmenterVersion = null;
}
resegment = !localSegmenterBackend.equals(segmenterBackend) || !localSegmenterVersion.equals(segmenterVersion);
}
}
use of com.yahoo.component.Version in project vespa by vespa-engine.
the class Upgrader method maintain.
/**
* Schedule application upgrades. Note that this implementation must be idempotent.
*/
@Override
public void maintain() {
// Determine target versions for each upgrade policy
Optional<Version> canaryTarget = controller().versionStatus().systemVersion().map(VespaVersion::versionNumber);
Optional<Version> defaultTarget = newestVersionWithConfidence(Confidence.normal);
Optional<Version> conservativeTarget = newestVersionWithConfidence(Confidence.high);
// Cancel upgrades to broken targets (let other ongoing upgrades complete to avoid starvation
for (VespaVersion version : controller().versionStatus().versions()) {
if (version.confidence() == Confidence.broken)
cancelUpgradesOf(applications().without(UpgradePolicy.canary).upgradingTo(version.versionNumber()), version.versionNumber() + " is broken");
}
// Canaries should always try the canary target
cancelUpgradesOf(applications().with(UpgradePolicy.canary).upgrading().notUpgradingTo(canaryTarget), "Outdated target version for Canaries");
// Cancel *failed* upgrades to earlier versions, as the new version may fix it
String reason = "Failing on outdated version";
cancelUpgradesOf(applications().with(UpgradePolicy.defaultPolicy).upgrading().failing().notUpgradingTo(defaultTarget), reason);
cancelUpgradesOf(applications().with(UpgradePolicy.conservative).upgrading().failing().notUpgradingTo(conservativeTarget), reason);
// Schedule the right upgrades
canaryTarget.ifPresent(target -> upgrade(applications().with(UpgradePolicy.canary), target));
defaultTarget.ifPresent(target -> upgrade(applications().with(UpgradePolicy.defaultPolicy), target));
conservativeTarget.ifPresent(target -> upgrade(applications().with(UpgradePolicy.conservative), target));
}
use of com.yahoo.component.Version in project vespa by vespa-engine.
the class JobStatus method withCompletion.
public JobStatus withCompletion(long runId, ApplicationVersion applicationVersion, Optional<DeploymentJobs.JobError> jobError, Instant completionTime, Controller controller) {
Version version;
String reason;
if (type == DeploymentJobs.JobType.component) {
// not triggered by us
version = controller.systemVersion();
reason = "Application commit";
} else if (!lastTriggered.isPresent()) {
throw new IllegalStateException("Got notified about completion of " + this + ", but that has neither been triggered nor deployed");
} else {
// TODO jvenstad: This is wrong, because triggering versions are not necessarily the same as deployed versions!
version = lastTriggered.get().version();
applicationVersion = lastTriggered.get().applicationVersion();
reason = lastTriggered.get().reason();
}
JobRun thisCompletion = new JobRun(runId, version, applicationVersion, reason, completionTime);
Optional<JobRun> firstFailing = this.firstFailing;
if (jobError.isPresent() && !this.firstFailing.isPresent())
firstFailing = Optional.of(thisCompletion);
Optional<JobRun> lastSuccess = this.lastSuccess;
if (!jobError.isPresent()) {
lastSuccess = Optional.of(thisCompletion);
firstFailing = Optional.empty();
}
return new JobStatus(type, jobError, lastTriggered, Optional.of(thisCompletion), firstFailing, lastSuccess);
}
Aggregations