001: /*
002: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
003: */
004: package com.tc;
005:
006: public class ProcessStatus {
007: private String m_processName;
008: private int m_status;
009: private boolean m_restarting;
010:
011: public static final int READY = 1;
012: public static final int WAITING = 2;
013: public static final int FAILED = 3;
014: public static final int INACTIVE = 4;
015:
016: public ProcessStatus(String processName) {
017: m_processName = processName;
018: setStatus(INACTIVE);
019: }
020:
021: public String getProcessName() {
022: return m_processName;
023: }
024:
025: public int getStatus() {
026: return m_status;
027: }
028:
029: public void setStatus(int status) {
030: m_status = status;
031: }
032:
033: public boolean isRestarting() {
034: return m_restarting;
035: }
036:
037: public void setRestarting(boolean restarting) {
038: m_restarting = restarting;
039: }
040:
041: public void setReady() {
042: setStatus(READY);
043: setRestarting(false);
044: }
045:
046: public boolean isReady() {
047: return getStatus() == READY;
048: }
049:
050: public void setWaiting() {
051: setStatus(WAITING);
052: }
053:
054: public boolean isWaiting() {
055: return getStatus() == WAITING;
056: }
057:
058: public void setFailed() {
059: setStatus(FAILED);
060: setRestarting(false);
061: }
062:
063: public boolean isFailed() {
064: return getStatus() == FAILED;
065: }
066:
067: public void setInactive() {
068: setStatus(INACTIVE);
069: }
070:
071: public boolean isInactive() {
072: return getStatus() == INACTIVE;
073: }
074:
075: public String getStatusString() {
076: String s;
077:
078: switch (getStatus()) {
079: case READY: {
080: s = "ready";
081: break;
082: }
083: case WAITING: {
084: s = "waiting";
085: break;
086: }
087: case FAILED: {
088: s = "failed";
089: break;
090: }
091: case INACTIVE: {
092: s = "inactive";
093: break;
094: }
095: default: {
096: s = "invalid status";
097: break;
098: }
099: }
100:
101: if (isRestarting()) {
102: s += ", restarting";
103: }
104:
105: return s;
106: }
107:
108: public String toString() {
109: return getProcessName() + " is " + getStatusString();
110: }
111: }
|