本文整理汇总了Java中org.apache.hadoop.yarn.server.nodemanager.containermanager.application.ApplicationState类的典型用法代码示例。如果您正苦于以下问题:Java ApplicationState类的具体用法?Java ApplicationState怎么用?Java ApplicationState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ApplicationState类属于org.apache.hadoop.yarn.server.nodemanager.containermanager.application包,在下文中一共展示了ApplicationState类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testNodeAppsState
import org.apache.hadoop.yarn.server.nodemanager.containermanager.application.ApplicationState; //导入依赖的package包/类
@Test
public void testNodeAppsState() throws JSONException, Exception {
WebResource r = resource();
Application app = new MockApp(1);
nmContext.getApplications().put(app.getAppId(), app);
addAppContainers(app);
MockApp app2 = new MockApp("foo", 1234, 2);
nmContext.getApplications().put(app2.getAppId(), app2);
HashMap<String, String> hash2 = addAppContainers(app2);
app2.setState(ApplicationState.RUNNING);
ClientResponse response = r.path("ws").path("v1").path("node").path("apps")
.queryParam("state", ApplicationState.RUNNING.toString())
.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
JSONObject json = response.getEntity(JSONObject.class);
JSONObject info = json.getJSONObject("apps");
assertEquals("incorrect number of elements", 1, info.length());
JSONArray appInfo = info.getJSONArray("app");
assertEquals("incorrect number of elements", 1, appInfo.length());
verifyNodeAppInfo(appInfo.getJSONObject(0), app2, hash2);
}
示例2: testNodeAppsStateNone
import org.apache.hadoop.yarn.server.nodemanager.containermanager.application.ApplicationState; //导入依赖的package包/类
@Test
public void testNodeAppsStateNone() throws JSONException, Exception {
WebResource r = resource();
Application app = new MockApp(1);
nmContext.getApplications().put(app.getAppId(), app);
addAppContainers(app);
Application app2 = new MockApp("foo", 1234, 2);
nmContext.getApplications().put(app2.getAppId(), app2);
addAppContainers(app2);
ClientResponse response = r.path("ws").path("v1").path("node").path("apps")
.queryParam("state", ApplicationState.INITING.toString())
.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
JSONObject json = response.getEntity(JSONObject.class);
assertEquals("apps is not null", JSONObject.NULL, json.get("apps"));
}
示例3: waitForApplicationState
import org.apache.hadoop.yarn.server.nodemanager.containermanager.application.ApplicationState; //导入依赖的package包/类
static void waitForApplicationState(ContainerManagerImpl containerManager,
ApplicationId appID, ApplicationState finalState)
throws InterruptedException {
// Wait for app-finish
Application app =
containerManager.getContext().getApplications().get(appID);
int timeout = 0;
while (!(app.getApplicationState().equals(finalState))
&& timeout++ < 15) {
LOG.info("Waiting for app to reach " + finalState
+ ".. Current state is "
+ app.getApplicationState());
Thread.sleep(1000);
}
Assert.assertTrue("App is not in " + finalState + " yet!! Timedout!!",
app.getApplicationState().equals(finalState));
}
示例4: testNodeAppsState
import org.apache.hadoop.yarn.server.nodemanager.containermanager.application.ApplicationState; //导入依赖的package包/类
@Test
public void testNodeAppsState() throws JSONException, Exception {
WebResource r = resource();
Application app = new MockApp(1);
nmContext.getApplications().put(app.getAppId(), app);
addAppContainers(app);
MockApp app2 = new MockApp("foo", 1234, 2, "foosFolder");
nmContext.getApplications().put(app2.getAppId(), app2);
HashMap<String, String> hash2 = addAppContainers(app2);
app2.setState(ApplicationState.RUNNING);
ClientResponse response = r.path("ws").path("v1").path("node").path("apps")
.queryParam("state", ApplicationState.RUNNING.toString())
.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
JSONObject json = response.getEntity(JSONObject.class);
JSONObject info = json.getJSONObject("apps");
assertEquals("incorrect number of elements", 1, info.length());
JSONArray appInfo = info.getJSONArray("app");
assertEquals("incorrect number of elements", 1, appInfo.length());
verifyNodeAppInfo(appInfo.getJSONObject(0), app2, hash2);
}
示例5: testNodeAppsStateNone
import org.apache.hadoop.yarn.server.nodemanager.containermanager.application.ApplicationState; //导入依赖的package包/类
@Test
public void testNodeAppsStateNone() throws JSONException, Exception {
WebResource r = resource();
Application app = new MockApp(1);
nmContext.getApplications().put(app.getAppId(), app);
addAppContainers(app);
Application app2 = new MockApp("foo", 1234, 2, "foosFolder");
nmContext.getApplications().put(app2.getAppId(), app2);
addAppContainers(app2);
ClientResponse response = r.path("ws").path("v1").path("node").path("apps")
.queryParam("state", ApplicationState.INITING.toString())
.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
JSONObject json = response.getEntity(JSONObject.class);
assertEquals("apps is not null", JSONObject.NULL, json.get("apps"));
}
示例6: getNodeApps
import org.apache.hadoop.yarn.server.nodemanager.containermanager.application.ApplicationState; //导入依赖的package包/类
@GET
@Path("/apps")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public AppsInfo getNodeApps(@QueryParam("state") String stateQuery,
@QueryParam("user") String userQuery) {
init();
AppsInfo allApps = new AppsInfo();
for (Entry<ApplicationId, Application> entry : this.nmContext
.getApplications().entrySet()) {
AppInfo appInfo = new AppInfo(entry.getValue());
if (stateQuery != null && !stateQuery.isEmpty()) {
ApplicationState.valueOf(stateQuery);
if (!appInfo.getState().equalsIgnoreCase(stateQuery)) {
continue;
}
}
if (userQuery != null) {
if (userQuery.isEmpty()) {
String msg = "Error: You must specify a non-empty string for the user";
throw new BadRequestException(msg);
}
if (!appInfo.getUser().toString().equals(userQuery)) {
continue;
}
}
allApps.add(appInfo);
}
return allApps;
}
示例7: isApplicationStopped
import org.apache.hadoop.yarn.server.nodemanager.containermanager.application.ApplicationState; //导入依赖的package包/类
private boolean isApplicationStopped(ApplicationId applicationId) {
if (!this.context.getApplications().containsKey(applicationId)) {
return true;
}
ApplicationState applicationState = this.context.getApplications().get(
applicationId).getApplicationState();
if (applicationState == ApplicationState.FINISHING_CONTAINERS_WAIT
|| applicationState == ApplicationState.APPLICATION_RESOURCES_CLEANINGUP
|| applicationState == ApplicationState.FINISHED) {
return true;
} else {
return false;
}
}
示例8: MockApp
import org.apache.hadoop.yarn.server.nodemanager.containermanager.application.ApplicationState; //导入依赖的package包/类
public MockApp(String user, long clusterTimeStamp, int uniqId) {
super();
this.user = user;
// Add an application and the corresponding containers
RecordFactory recordFactory = RecordFactoryProvider
.getRecordFactory(new Configuration());
this.appId = BuilderUtils.newApplicationId(recordFactory, clusterTimeStamp,
uniqId);
appState = ApplicationState.NEW;
}
示例9: waitForAppState
import org.apache.hadoop.yarn.server.nodemanager.containermanager.application.ApplicationState; //导入依赖的package包/类
private void waitForAppState(Application app, ApplicationState state)
throws Exception {
final int msecPerSleep = 10;
int msecLeft = 5000;
while (app.getApplicationState() != state && msecLeft > 0) {
Thread.sleep(msecPerSleep);
msecLeft -= msecPerSleep;
}
assertEquals(state, app.getApplicationState());
}
示例10: getNodeApps
import org.apache.hadoop.yarn.server.nodemanager.containermanager.application.ApplicationState; //导入依赖的package包/类
@GET
@Path("/apps")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public AppsInfo getNodeApps(@QueryParam("state") String stateQuery,
@QueryParam("user") String userQuery) {
init();
AppsInfo allApps = new AppsInfo();
for (Entry<ApplicationId, Application> entry : this.nmContext
.getApplications().entrySet()) {
AppInfo appInfo = new AppInfo(entry.getValue());
if (stateQuery != null && !stateQuery.isEmpty()) {
ApplicationState.valueOf(stateQuery);
if (!appInfo.getState().equalsIgnoreCase(stateQuery)) {
continue;
}
}
if (userQuery != null) {
if (userQuery.isEmpty()) {
String msg = "Error: You must specify a non-empty string for the user";
throw new BadRequestException(msg);
}
if (!appInfo.getUser().equals(userQuery)) {
continue;
}
}
allApps.add(appInfo);
}
return allApps;
}
示例11: testCompletedContainersIsRecentlyStopped
import org.apache.hadoop.yarn.server.nodemanager.containermanager.application.ApplicationState; //导入依赖的package包/类
@Test(timeout = 10000)
public void testCompletedContainersIsRecentlyStopped() throws Exception {
NodeManager nm = new NodeManager();
nm.init(conf);
NodeStatusUpdaterImpl nodeStatusUpdater =
(NodeStatusUpdaterImpl) nm.getNodeStatusUpdater();
ApplicationId appId = ApplicationId.newInstance(0, 0);
Application completedApp = mock(Application.class);
when(completedApp.getApplicationState()).thenReturn(
ApplicationState.FINISHED);
ApplicationAttemptId appAttemptId =
ApplicationAttemptId.newInstance(appId, 0);
ContainerId containerId = ContainerId.newContainerId(appAttemptId, 1);
Token containerToken =
BuilderUtils.newContainerToken(containerId, "host", 1234, "user",
BuilderUtils.newResource(1024, 1), 0, 123,
"password".getBytes(), 0);
Container completedContainer = new ContainerImpl(conf, null,
null, null, null, null,
BuilderUtils.newContainerTokenIdentifier(containerToken)) {
@Override
public ContainerState getCurrentState() {
return ContainerState.COMPLETE;
}
};
nm.getNMContext().getApplications().putIfAbsent(appId, completedApp);
nm.getNMContext().getContainers().put(containerId, completedContainer);
Assert.assertEquals(1, nodeStatusUpdater.getContainerStatuses().size());
Assert.assertTrue(nodeStatusUpdater.isContainerRecentlyStopped(
containerId));
}