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

org.apache.flume.lifecycle.LifecycleAware Maven / Gradle / Ivy

There is a newer version: 4.15.0-HBase-1.5
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package org.apache.flume.lifecycle;

import org.apache.flume.annotations.InterfaceAudience;
import org.apache.flume.annotations.InterfaceStability;


/**
 * 

* An interface implemented by any class that has a defined, stateful, * lifecycle. *

*

* Implementations of {@link LifecycleAware} conform to a standard method of * starting, stopping, and reporting their current state. Additionally, this * interface creates a standard method of communicating failure to perform a * lifecycle operation to the caller (i.e. via {@link LifecycleException}). It * is never considered valid to call {@link #start()} or * {@link #stop()} more than once or to call them in the wrong order. * While this is not strictly enforced, it may be in the future. *

*

* Example services may include Flume nodes and the master, but also lower level * components that can be controlled in a similar manner. *

*

* Example usage *

* * public class MyService implements LifecycleAware { * * private LifecycleState lifecycleState; * * public MyService() { * lifecycleState = LifecycleState.IDLE; * } * * @Override * public void start(Context context) throws LifecycleException, * InterruptedException { * * ...your code does something. * * lifecycleState = LifecycleState.START; * } * * @Override * public void stop(Context context) throws LifecycleException, * InterruptedException { * * try { * ...you stop services here. * } catch (SomethingException) { * lifecycleState = LifecycleState.ERROR; * } * * lifecycleState = LifecycleState.STOP; * } * * @Override * public LifecycleState getLifecycleState() { * return lifecycleState; * } * * } * */ @InterfaceAudience.Public @InterfaceStability.Stable public interface LifecycleAware { /** *

* Starts a service or component. *

*

* Implementations should determine the result of any start logic and effect * the return value of {@link #getLifecycleState()} accordingly. *

* * @throws LifecycleException * @throws InterruptedException */ public void start(); /** *

* Stops a service or component. *

*

* Implementations should determine the result of any stop logic and effect * the return value of {@link #getLifecycleState()} accordingly. *

* * @throws LifecycleException * @throws InterruptedException */ public void stop(); /** *

* Return the current state of the service or component. *

*/ public LifecycleState getLifecycleState(); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy