/** * Verify that that a service is in a given state. * * @param currentState * the desired state * @throws IllegalStateException * if the service state is different from * the desired state */ private void ensureCurrentState(STATE currentState) { ServiceOperations.ensureCurrentState(state, currentState); }
private void resetResultReader() { if (resultReader != null) { ServiceUtils.cleanup(LOG, resultReader); resultReader = null; } }
@Override public synchronized void stop() { if (this.getServiceState() == STATE.STOPPED) { // The base composite-service is already stopped, don't do anything again. return; } if (serviceList.size() > 0) { stop(serviceList.size() - 1); } super.stop(); }
/** * Start a service. * <p/> * The service state is checked <i>before</i> the operation begins. * This process is <i>not</i> thread safe. * @param service a service that must be in the state * {@link Service.STATE#INITED} * @throws RuntimeException on a state change failure * @throws IllegalStateException if the service is in the wrong state */ public static void start(Service service) { Service.STATE state = service.getServiceState(); ensureCurrentState(state, Service.STATE.INITED); service.start(); }
/** * Initialize a service. * <p/> * The service state is checked <i>before</i> the operation begins. * This process is <i>not</i> thread safe. * @param service a service that must be in the state * {@link Service.STATE#NOTINITED} * @param configuration the configuration to initialize the service with * @throws RuntimeException on a state change failure * @throws IllegalStateException if the service is in the wrong state */ public static void init(Service service, HiveConf configuration) { Service.STATE state = service.getServiceState(); ensureCurrentState(state, Service.STATE.NOTINITED); service.init(configuration); }
/** * Stop a service. * <p/>Do nothing if the service is null or not * in a state in which it can be/needs to be stopped. * <p/> * The service state is checked <i>before</i> the operation begins. * This process is <i>not</i> thread safe. * @param service a service or null */ public static void stop(Service service) { if (service != null) { Service.STATE state = service.getServiceState(); if (state == Service.STATE.STARTED) { service.stop(); } } }
/** * Initialize then start a service. * <p/> * The service state is checked <i>before</i> the operation begins. * This process is <i>not</i> thread safe. * @param service a service that must be in the state * {@link Service.STATE#NOTINITED} * @param configuration the configuration to initialize the service with * @throws RuntimeException on a state change failure * @throws IllegalStateException if the service is in the wrong state */ public static void deploy(Service service, HiveConf configuration) { init(service, configuration); start(service); }
@Override public synchronized void start() { super.start(); }
@Override public String getName() { return service.getName(); }
@Override public STATE getServiceState() { return service.getServiceState(); }
@Override public synchronized void start() { super.start(); }
@Override public synchronized void stop() { super.stop(); }
@Override public void init(HiveConf config) { service.init(config); }
@Override public void unregister(ServiceStateChangeListener listener) { service.unregister(listener); }
@Override public void register(ServiceStateChangeListener listener) { service.register(listener); }
@Override public HiveConf getHiveConf() { return service.getHiveConf(); }
@Override public void start() { service.start(); }
@Override public void stop() { service.stop(); }
/** * Check for a domain part in the provided username. * <br> * <b>Example:</b> * <br> * <pre> * LdapUtils.hasDomain("user1@mycorp.com") = true * LdapUtils.hasDomain("user1") = false * </pre> * @param userName username * @return true if {@code userName} contains {@code @<domain>} part */ public static boolean hasDomain(String userName) { return (ServiceUtils.indexOfDomainMatch(userName) > 0); }