All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.kiwiproject.dropwizard.util.task.ServerLoadTask Maven / Gradle / Ivy

There is a newer version: 4.0.1
Show newest version
package org.kiwiproject.dropwizard.util.task;

import io.dropwizard.servlets.tasks.Task;
import org.kiwiproject.dropwizard.util.metrics.ServerLoadFetcher;

import java.io.PrintWriter;
import java.util.List;
import java.util.Map;

/**
 * Send a POST on the admin port to {@code /tasks/serverLoad} to get the current server load average.
 * 

* If the load average was not obtainable for some reason, returns {@link ServerLoadFetcher#NO_VALUE}. */ public class ServerLoadTask extends Task { private static final String TASK_NAME = "serverLoad"; private final ServerLoadFetcher serverLoad; public ServerLoadTask() { super(TASK_NAME); serverLoad = new ServerLoadFetcher(); } @Override public void execute(Map> parameters, PrintWriter output) { var value = serverLoad.get().orElse(ServerLoadFetcher.NO_VALUE); output.println(value); output.flush(); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy