Java Code Examples for org.apache.hadoop.service.Service#STATE

The following examples show how to use org.apache.hadoop.service.Service#STATE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MRApp.java    From hadoop with Apache License 2.0 6 votes vote down vote up
public void waitForState(Service.STATE finalState) throws Exception {
  if (finalState == Service.STATE.STOPPED) {
     Assert.assertTrue("Timeout while waiting for MRApp to stop",
         waitForServiceToStop(20 * 1000));
  } else {
    int timeoutSecs = 0;
    while (!finalState.equals(getServiceState()) && timeoutSecs++ < 20) {
      System.out.println("MRApp State is : " + getServiceState()
          + " Waiting for state : " + finalState);
      Thread.sleep(500);
    }
    System.out.println("MRApp State is : " + getServiceState());
    Assert.assertEquals("MRApp state is not correct (timedout)", finalState,
        getServiceState());
  }
}
 
Example 2
Source File: MRApp.java    From big-c with Apache License 2.0 6 votes vote down vote up
public void waitForState(Service.STATE finalState) throws Exception {
  if (finalState == Service.STATE.STOPPED) {
     Assert.assertTrue("Timeout while waiting for MRApp to stop",
         waitForServiceToStop(20 * 1000));
  } else {
    int timeoutSecs = 0;
    while (!finalState.equals(getServiceState()) && timeoutSecs++ < 20) {
      System.out.println("MRApp State is : " + getServiceState()
          + " Waiting for state : " + finalState);
      Thread.sleep(500);
    }
    System.out.println("MRApp State is : " + getServiceState());
    Assert.assertEquals("MRApp state is not correct (timedout)", finalState,
        getServiceState());
  }
}
 
Example 3
Source File: BreakableStateChangeListener.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized String toString() {
  String s =
    name + " - event count = " + eventCount + " last state " + lastState;
  StringBuilder history = new StringBuilder(stateEventList.size()*10);
  for (Service.STATE state: stateEventList) {
    history.append(state).append(" ");
  }
  return s + " [ " + history + "]";
}
 
Example 4
Source File: ServiceAssert.java    From hadoop with Apache License 2.0 5 votes vote down vote up
/**
 * Assert that the breakable service has entered a state exactly the number
 * of time asserted.
 * @param service service -if null an assertion is raised.
 * @param state state to check.
 * @param expected expected count.
 */
public static void assertStateCount(BreakableService service,
                      Service.STATE state,
                      int expected) {
  assertNotNull("Null service", service);
  int actual = service.getCount(state);
  if (expected != actual) {
    fail("Expected entry count for state [" + state +"] of " + service
             + " to be " + expected + " but was " + actual);
  }
}
 
Example 5
Source File: BreakableStateChangeListener.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized String toString() {
  String s =
    name + " - event count = " + eventCount + " last state " + lastState;
  StringBuilder history = new StringBuilder(stateEventList.size()*10);
  for (Service.STATE state: stateEventList) {
    history.append(state).append(" ");
  }
  return s + " [ " + history + "]";
}
 
Example 6
Source File: ServiceAssert.java    From big-c with Apache License 2.0 5 votes vote down vote up
/**
 * Assert that the breakable service has entered a state exactly the number
 * of time asserted.
 * @param service service -if null an assertion is raised.
 * @param state state to check.
 * @param expected expected count.
 */
public static void assertStateCount(BreakableService service,
                      Service.STATE state,
                      int expected) {
  assertNotNull("Null service", service);
  int actual = service.getCount(state);
  if (expected != actual) {
    fail("Expected entry count for state [" + state +"] of " + service
             + " to be " + expected + " but was " + actual);
  }
}
 
Example 7
Source File: BreakableStateChangeListener.java    From hadoop with Apache License 2.0 4 votes vote down vote up
public synchronized Service.STATE getLastState() {
  return lastState;
}
 
Example 8
Source File: BreakableStateChangeListener.java    From hadoop with Apache License 2.0 4 votes vote down vote up
public synchronized void setFailingState(Service.STATE failingState) {
  this.failingState = failingState;
}
 
Example 9
Source File: BreakableStateChangeListener.java    From hadoop with Apache License 2.0 4 votes vote down vote up
public List<Service.STATE> getStateEventList() {
  return stateEventList;
}
 
Example 10
Source File: ServiceAssert.java    From hadoop with Apache License 2.0 4 votes vote down vote up
public static void assertServiceInState(Service service, Service.STATE state) {
  assertNotNull("Null service", service);
  assertEquals("Service in wrong state: " + service, state,
               service.getServiceState());
}
 
Example 11
Source File: BreakableStateChangeListener.java    From big-c with Apache License 2.0 4 votes vote down vote up
public synchronized Service.STATE getLastState() {
  return lastState;
}
 
Example 12
Source File: BreakableStateChangeListener.java    From big-c with Apache License 2.0 4 votes vote down vote up
public synchronized void setFailingState(Service.STATE failingState) {
  this.failingState = failingState;
}
 
Example 13
Source File: BreakableStateChangeListener.java    From big-c with Apache License 2.0 4 votes vote down vote up
public List<Service.STATE> getStateEventList() {
  return stateEventList;
}
 
Example 14
Source File: ServiceAssert.java    From big-c with Apache License 2.0 4 votes vote down vote up
public static void assertServiceInState(Service service, Service.STATE state) {
  assertNotNull("Null service", service);
  assertEquals("Service in wrong state: " + service, state,
               service.getServiceState());
}
 
Example 15
Source File: TestGlobalStateChangeListener.java    From hadoop with Apache License 2.0 2 votes vote down vote up
/**
 * Assert that the last state of the listener is that the test expected.
 * @param breakable a breakable listener
 * @param state the expected state
 */
public void assertListenerState(BreakableStateChangeListener breakable,
                                Service.STATE state) {
  assertEquals("Wrong state in " + breakable, state, breakable.getLastState());
}
 
Example 16
Source File: TestGlobalStateChangeListener.java    From big-c with Apache License 2.0 2 votes vote down vote up
/**
 * Assert that the last state of the listener is that the test expected.
 * @param breakable a breakable listener
 * @param state the expected state
 */
public void assertListenerState(BreakableStateChangeListener breakable,
                                Service.STATE state) {
  assertEquals("Wrong state in " + breakable, state, breakable.getLastState());
}