org.apache.hadoop.yarn.api.records.ContainerStatus Maven / Gradle / Ivy
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hadoop.yarn.api.records;
import org.apache.hadoop.classification.InterfaceAudience.Private;
import org.apache.hadoop.classification.InterfaceAudience.Public;
import org.apache.hadoop.classification.InterfaceStability.Evolving;
import org.apache.hadoop.classification.InterfaceStability.Stable;
import org.apache.hadoop.classification.InterfaceStability.Unstable;
import org.apache.hadoop.yarn.util.Records;
import java.util.List;
/**
* {@code ContainerStatus} represents the current status of a
* {@code Container}.
*
* It provides details such as:
*
* - {@code ContainerId} of the container.
* - {@code ExecutionType} of the container.
* - {@code ContainerState} of the container.
* - Exit status of a completed container.
* - Diagnostic message for a failed container.
* - {@link Resource} allocated to the container.
*
*/
@Public
@Stable
public abstract class ContainerStatus {
@Private
@Unstable
public static ContainerStatus newInstance(ContainerId containerId,
ContainerState containerState, String diagnostics, int exitStatus) {
return newInstance(containerId, ExecutionType.GUARANTEED, containerState,
diagnostics, exitStatus);
}
@Private
@Unstable
public static ContainerStatus newInstance(ContainerId containerId,
ExecutionType executionType, ContainerState containerState,
String diagnostics, int exitStatus) {
ContainerStatus containerStatus = Records.newRecord(ContainerStatus.class);
containerStatus.setExecutionType(executionType);
containerStatus.setState(containerState);
containerStatus.setContainerId(containerId);
containerStatus.setDiagnostics(diagnostics);
containerStatus.setExitStatus(exitStatus);
return containerStatus;
}
/**
* Get the ContainerId
of the container.
* @return ContainerId
of the container
*/
@Public
@Stable
public abstract ContainerId getContainerId();
@Private
@Unstable
public abstract void setContainerId(ContainerId containerId);
/**
* Get the ExecutionType
of the container.
* @return ExecutionType
of the container
*/
@Public
@Evolving
public ExecutionType getExecutionType() {
throw new UnsupportedOperationException(
"subclass must implement this method");
}
@Private
@Unstable
public void setExecutionType(ExecutionType executionType) {
throw new UnsupportedOperationException(
"subclass must implement this method");
}
/**
* Get the ContainerState
of the container.
* @return ContainerState
of the container
*/
@Public
@Stable
public abstract ContainerState getState();
@Private
@Unstable
public abstract void setState(ContainerState state);
/**
* Get the exit status for the container.
*
* Note: This is valid only for completed containers i.e. containers
* with state {@link ContainerState#COMPLETE}.
* Otherwise, it returns an ContainerExitStatus.INVALID.
*
*
* Containers killed by the framework, either due to being released by
* the application or being 'lost' due to node failures etc. have a special
* exit code of ContainerExitStatus.ABORTED.
*
* When threshold number of the nodemanager-local-directories or
* threshold number of the nodemanager-log-directories become bad, then
* container is not launched and is exited with ContainersExitStatus.DISKS_FAILED.
*
*
* @return exit status for the container
*/
@Public
@Unstable
public abstract int getExitStatus();
@Private
@Unstable
public abstract void setExitStatus(int exitStatus);
/**
* Get diagnostic messages for failed containers.
* @return diagnostic messages for failed containers
*/
@Public
@Stable
public abstract String getDiagnostics();
@Private
@Unstable
public abstract void setDiagnostics(String diagnostics);
/**
* Get the Resource
allocated to the container.
* @return Resource
allocated to the container
*/
@Public
@Unstable
public Resource getCapability() {
throw new UnsupportedOperationException(
"subclass must implement this method");
}
@Private
@Unstable
public void setCapability(Resource capability) {
throw new UnsupportedOperationException(
"subclass must implement this method");
}
/**
* Get all the IP addresses with which the container run.
* @return The IP address where the container runs.
*/
@Public
@Unstable
public List getIPs() {
throw new UnsupportedOperationException(
"subclass must implement this method");
}
@Private
@Unstable
public void setIPs(List ips) {
throw new UnsupportedOperationException(
"subclass must implement this method");
}
/**
* Get the hostname where the container runs.
* @return The hostname where the container runs.
*/
@Public
@Unstable
public String getHost() {
throw new UnsupportedOperationException(
"subclass must implement this method");
}
@Private
@Unstable
public void setHost(String host) {
throw new UnsupportedOperationException(
"subclass must implement this method");
}
/**
* Add Extra state information of the container (SCHEDULED, LOCALIZING etc.).
* @param subState Extra State Information.
*/
@Private
@Unstable
public void setContainerSubState(ContainerSubState subState) {
throw new UnsupportedOperationException(
"subclass must implement this method");
}
/**
* Get Extra state information of the container (SCHEDULED, LOCALIZING etc.).
* @return Extra State information.
*/
@Private
@Unstable
public ContainerSubState getContainerSubState() {
throw new UnsupportedOperationException(
"subclass must implement this method");
}
/**
* Get exposed ports of the container.
* @return List of exposed ports
*/
@Public
@Unstable
public String getExposedPorts() {
throw new UnsupportedOperationException(
"subclass must implement this method");
}
@Private
@Unstable
public void setExposedPorts(String ports) {
throw new UnsupportedOperationException(
"subclass must implement this method");
}
}