APISonar


com.yahoo.vespa.hosted.node.admin.nodeagent.NodeAgentContext.log

> com > yahoo > vespa > hosted > node > admin > nodeagent > NodeAgentContext > log
com APIs yahoo APIs vespa APIs hosted APIs node APIs admin APIs nodeagent APIs NodeAgentContext APIs log APIs

Example 1
void processAndReportSingleCoredump(NodeAgentContext context, Path coredumpDirectory, Supplier<Map<String, Object>> nodeAttributesSupplier) {
        try {
            String metadata = getMetadata(context, coredumpDirectory, nodeAttributesSupplier);
            String coredumpId = coredumpDirectory.getFileName().toString();
            coredumpReporter.reportCoredump(coredumpId, metadata);
            finishProcessing(context, coredumpDirectory);
            context.log(logger, "Successfully reported coredump " + coredumpId);
        } catch (Exception e) {
            throw new RuntimeException("Failed to process coredump " + coredumpDirectory, e);
        }
    }
Example 2
Map<String, Object> collect(NodeAgentContext context, Path coredumpPath) {
        Map<String, Object> data = new HashMap<>();
        try {
            Path binPath = readBinPath(context, coredumpPath);

            data.put("bin_path", binPath.toString());
            data.put("backtrace", readBacktrace(context, coredumpPath, binPath, false));
            data.put("backtrace_all_threads", readBacktrace(context, coredumpPath, binPath, true));
        } catch (RuntimeException e) {
            context.log(logger, Level.WARNING, "Failed to extract backtrace", e);
        }
        return data;
    }
Example 3
public Optional<Long> getDiskUsageFor(NodeAgentContext context) {
        try {
            Path path = context.pathOnHostFromPathInNode("/");

            Long cachedDiskUsage = diskUsage.getIfPresent(path);
            if (cachedDiskUsage != null) return Optional.of(cachedDiskUsage);

            long diskUsageBytes = getDiskUsedInBytes(context, path);
            diskUsage.put(path, diskUsageBytes);
            return Optional.of(diskUsageBytes);
        } catch (Exception e) {
            context.log(logger, LogLevel.WARNING, "Failed to get disk usage", e);
            return Optional.empty();
        }
    }
Example 4
public Duration certificateLifetime(NodeAgentContext context) {
        Path containerSiaDirectory = fileSystem.getPath(context.pathOnHostFromPathInNode(CONTAINER_SIA_DIRECTORY).toString());
        Path certificateFile = SiaUtils.getCertificateFile(containerSiaDirectory, context.identity());
        try {
            X509Certificate certificate = readCertificateFromFile(certificateFile);
            Instant now = clock.instant();
            Instant expiry = certificate.getNotAfter().toInstant();
            return Duration.between(now, expiry);
        } catch (IOException e) {
            context.log(logger, LogLevel.ERROR, "Unable to read certificate at " + certificateFile, e);
            return Duration.ZERO;
        }
    }
Example 5
private boolean edit(NodeAgentContext context, String table, IPVersion ipVersion, LineEditor lineEditor, boolean flush) {
        Editor editor = new Editor(
                ipVersion.iptablesCmd() + "-" + table,
                listTable(context, table, ipVersion),
                restoreTable(context, table, ipVersion, flush),
                lineEditor);
        return editor.edit(message -> context.log(logger, message));
    }