/** * Copyright 2016 LinkedIn Corp. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this * file except in compliance with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ package com.linkedin.kmf.services; /** * Services are components of a monitoring application that are expected to be running continuously in order to perform * monitoring. */ public interface Service { static final String JMX_PREFIX = "kmf.services"; /** * The start logic must only execute once. If an error occurs then the implementer of this class must assume that * stop() will be called to clean up. This method must be thread safe and must assume that stop() may be called * concurrently. This can happen if the monitoring application's life cycle is being managed by a container. Start * will only be called once. */ void start(); /** * This may be called multiple times. This method must be thread safe and must assume that start() may be called * concurrently. This can happen if the monitoring application's life cycle is being managed by a container. * Implementations must be non-blocking and should release the resources acquired by the service during start(). */ void stop(); /** * Implementations of this method must be thread safe as it can be called at any time. Implementations must be * non-blocking. * @return true if this start() has returned successfully else this must return false. This must also return false if * the service can no longer perform its function. */ boolean isRunning(); /** * Implementations of this method must be thread safe and must be blocking. */ void awaitShutdown(); }