Back to home page

OSCL-LXR

 
 

    


0001 /**
0002  * Licensed to the Apache Software Foundation (ASF) under one
0003  * or more contributor license agreements.  See the NOTICE file
0004  * distributed with this work for additional information
0005  * regarding copyright ownership.  The ASF licenses this file
0006  * to you under the Apache License, Version 2.0 (the
0007  * "License"); you may not use this file except in compliance
0008  * with the License.  You may obtain a copy of the License at
0009  *
0010  *     http://www.apache.org/licenses/LICENSE-2.0
0011  *
0012  * Unless required by applicable law or agreed to in writing, software
0013  * distributed under the License is distributed on an "AS IS" BASIS,
0014  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0015  * See the License for the specific language governing permissions and
0016  * limitations under the License.
0017  */
0018 
0019 package org.apache.hive.service;
0020 
0021 import org.apache.hadoop.hive.conf.HiveConf;
0022 
0023 /**
0024  * Service.
0025  *
0026  */
0027 public interface Service {
0028 
0029   /**
0030    * Service states
0031    */
0032   enum STATE {
0033     /** Constructed but not initialized */
0034     NOTINITED,
0035 
0036     /** Initialized but not started or stopped */
0037     INITED,
0038 
0039     /** started and not stopped */
0040     STARTED,
0041 
0042     /** stopped. No further state transitions are permitted */
0043     STOPPED
0044   }
0045 
0046   /**
0047    * Initialize the service.
0048    *
0049    * The transition must be from {@link STATE#NOTINITED} to {@link STATE#INITED} unless the
0050    * operation failed and an exception was raised.
0051    *
0052    * @param conf
0053    *          the configuration of the service
0054    */
0055   void init(HiveConf conf);
0056 
0057 
0058   /**
0059    * Start the service.
0060    *
0061    * The transition should be from {@link STATE#INITED} to {@link STATE#STARTED} unless the
0062    * operation failed and an exception was raised.
0063    */
0064   void start();
0065 
0066   /**
0067    * Stop the service.
0068    *
0069    * This operation must be designed to complete regardless of the initial state
0070    * of the service, including the state of all its internal fields.
0071    */
0072   void stop();
0073 
0074   /**
0075    * Register an instance of the service state change events.
0076    *
0077    * @param listener
0078    *          a new listener
0079    */
0080   void register(ServiceStateChangeListener listener);
0081 
0082   /**
0083    * Unregister a previously instance of the service state change events.
0084    *
0085    * @param listener
0086    *          the listener to unregister.
0087    */
0088   void unregister(ServiceStateChangeListener listener);
0089 
0090   /**
0091    * Get the name of this service.
0092    *
0093    * @return the service name
0094    */
0095   String getName();
0096 
0097   /**
0098    * Get the configuration of this service.
0099    * This is normally not a clone and may be manipulated, though there are no
0100    * guarantees as to what the consequences of such actions may be
0101    *
0102    * @return the current configuration, unless a specific implementation chooses
0103    *         otherwise.
0104    */
0105   HiveConf getHiveConf();
0106 
0107   /**
0108    * Get the current service state
0109    *
0110    * @return the state of the service
0111    */
0112   STATE getServiceState();
0113 
0114   /**
0115    * Get the service start time
0116    *
0117    * @return the start time of the service. This will be zero if the service
0118    *         has not yet been started.
0119    */
0120   long getStartTime();
0121 
0122 }