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 Project: hadoop File: MRApp.java License: Apache License 2.0 | 6 votes |
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 Project: big-c File: MRApp.java License: Apache License 2.0 | 6 votes |
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 Project: hadoop File: BreakableStateChangeListener.java License: Apache License 2.0 | 5 votes |
@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 Project: hadoop File: ServiceAssert.java License: Apache License 2.0 | 5 votes |
/** * 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 Project: big-c File: BreakableStateChangeListener.java License: Apache License 2.0 | 5 votes |
@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 Project: big-c File: ServiceAssert.java License: Apache License 2.0 | 5 votes |
/** * 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 Project: hadoop File: BreakableStateChangeListener.java License: Apache License 2.0 | 4 votes |
public synchronized Service.STATE getLastState() { return lastState; }
Example 8
Source Project: hadoop File: BreakableStateChangeListener.java License: Apache License 2.0 | 4 votes |
public synchronized void setFailingState(Service.STATE failingState) { this.failingState = failingState; }
Example 9
Source Project: hadoop File: BreakableStateChangeListener.java License: Apache License 2.0 | 4 votes |
public List<Service.STATE> getStateEventList() { return stateEventList; }
Example 10
Source Project: hadoop File: ServiceAssert.java License: Apache License 2.0 | 4 votes |
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 Project: big-c File: BreakableStateChangeListener.java License: Apache License 2.0 | 4 votes |
public synchronized Service.STATE getLastState() { return lastState; }
Example 12
Source Project: big-c File: BreakableStateChangeListener.java License: Apache License 2.0 | 4 votes |
public synchronized void setFailingState(Service.STATE failingState) { this.failingState = failingState; }
Example 13
Source Project: big-c File: BreakableStateChangeListener.java License: Apache License 2.0 | 4 votes |
public List<Service.STATE> getStateEventList() { return stateEventList; }
Example 14
Source Project: big-c File: ServiceAssert.java License: Apache License 2.0 | 4 votes |
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 Project: hadoop File: TestGlobalStateChangeListener.java License: Apache License 2.0 | 2 votes |
/** * 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 Project: big-c File: TestGlobalStateChangeListener.java License: Apache License 2.0 | 2 votes |
/** * 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()); }