try {
insts = client.getWorkflowInstances();
if (insts != null) {
for (Iterator i = insts.iterator(); i.hasNext();) {
WorkflowInstance inst = (WorkflowInstance) i.next();
System.out
.println("Instance: [id="
+ inst.getId()
+ ", status="
+ inst.getStatus()
+ ", currentTask="
+ inst.getCurrentTaskId()
+ ", workflow="
+ inst.getWorkflow().getName()
+ ",wallClockTime="
+ client
.getWorkflowWallClockMinutes(inst
.getId())
+ ",currentTaskWallClockTime="
+ client
.getWorkflowCurrentTaskWallClockMinutes(inst
.getId()) + "]");
}
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
} else if (operation.equals("--stopWorkflowInst")) {
XmlRpcWorkflowManagerClient client = new XmlRpcWorkflowManagerClient(
new URL(url));
String workflowInstId = null;
for (int i = 4; i < args.length; i++) {
if (args[i].equals("--id")) {
workflowInstId = args[++i];
}
}
try {
boolean stopped = client.stopWorkflowInstance(workflowInstId);
if (stopped) {
System.out.println("Successfully stopped workflow: ["
+ workflowInstId + "]");
}
} catch (Exception e) {
throw new RuntimeException(e.getMessage());
}
} else if (operation.equals("--pauseWorkflowInst")) {
XmlRpcWorkflowManagerClient client = new XmlRpcWorkflowManagerClient(
new URL(url));
String workflowInstId = null;
for (int i = 4; i < args.length; i++) {
if (args[i].equals("--id")) {
workflowInstId = args[++i];
}
}
try {
boolean paused = client.pauseWorkflowInstance(workflowInstId);
if (paused) {
System.out.println("Successfully paused workflow: ["
+ workflowInstId + "]");
}
} catch (Exception e) {
throw new RuntimeException(e.getMessage());
}
} else if (operation.equals("--resumeWorkflowInst")) {
XmlRpcWorkflowManagerClient client = new XmlRpcWorkflowManagerClient(
new URL(url));
String workflowInstId = null;
for (int i = 4; i < args.length; i++) {
if (args[i].equals("--id")) {
workflowInstId = args[++i];
}
}
try {
boolean resumed = client.resumeWorkflowInstance(workflowInstId);
if (resumed) {
System.out.println("Successfully resumed workflow: ["
+ workflowInstId + "]");
}
} catch (Exception e) {
throw new RuntimeException(e.getMessage());
}
}
else if (operation.equals("--getTaskWallClockTime")) {
XmlRpcWorkflowManagerClient client = new XmlRpcWorkflowManagerClient(
new URL(url));
String workflowInstId = null;
for (int i = 4; i < args.length; i++) {
if (args[i].equals("--id")) {
workflowInstId = args[++i];
}
}
try {
double wallClockTime = client
.getWorkflowCurrentTaskWallClockMinutes(workflowInstId);
System.out.println(wallClockTime + " minutes");
} catch (Exception e) {
throw new RuntimeException(e.getMessage());
}
} else if (operation.equals("--getWallClockTime")) {
XmlRpcWorkflowManagerClient client = new XmlRpcWorkflowManagerClient(
new URL(url));
String workflowInstId = null;
for (int i = 4; i < args.length; i++) {
if (args[i].equals("--id")) {
workflowInstId = args[++i];
}
}
try {
double wallClockTime = client
.getWorkflowWallClockMinutes(workflowInstId);
System.out.println(wallClockTime + " minutes");
} catch (Exception e) {
throw new RuntimeException(e.getMessage());
}
}
else if (operation.equals("--getFirstPage")) {
XmlRpcWorkflowManagerClient client = new XmlRpcWorkflowManagerClient(
new URL(url));
WorkflowInstancePage page = null;
String status = null;
for (int i = 4; i < args.length; i++) {
if (args[i].equals("--status")) {
status = args[++i];
}
}
try {
if (status != null && !status.equals("")) {
page = client.paginateWorkflowInstances(1, status);
} else {
page = client.getFirstPage();
}
System.out.println("Page: [num=" + page.getPageNum() + ","
+ "pageSize=" + page.getPageSize() + ",totalPages="
+ page.getTotalPages() + "]");
if (page.getPageWorkflows() != null
&& page.getPageWorkflows().size() > 0) {
for (Iterator i = page.getPageWorkflows().iterator(); i
.hasNext();) {
WorkflowInstance inst = (WorkflowInstance) i.next();
System.out
.println("Instance: [id="
+ inst.getId()
+ ", status="
+ inst.getStatus()
+ ", currentTask="
+ inst.getCurrentTaskId()
+ ", workflow="
+ inst.getWorkflow().getName()
+ ",wallClockTime="
+ client
.getWorkflowWallClockMinutes(inst
.getId())
+ ",currentTaskWallClockTime="
+ client
.getWorkflowCurrentTaskWallClockMinutes(inst
.getId()) + "]");
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
} else if (operation.equals("--getLastPage")) {
XmlRpcWorkflowManagerClient client = new XmlRpcWorkflowManagerClient(
new URL(url));
WorkflowInstancePage page = null;
String status = null;
for (int i = 4; i < args.length; i++) {
if (args[i].equals("--status")) {
status = args[++i];
}
}
try {
if (status != null && !status.equals("")) {
WorkflowInstancePage firstPage = client
.paginateWorkflowInstances(1, status);
page = client.paginateWorkflowInstances(firstPage
.getTotalPages(), status);
} else {
page = client.getLastPage();
}
System.out.println("Page: [num=" + page.getPageNum() + ","
+ "pageSize=" + page.getPageSize() + ",totalPages="
+ page.getTotalPages() + "]");
if (page.getPageWorkflows() != null
&& page.getPageWorkflows().size() > 0) {
for (Iterator i = page.getPageWorkflows().iterator(); i
.hasNext();) {
WorkflowInstance inst = (WorkflowInstance) i.next();
System.out
.println("Instance: [id="
+ inst.getId()
+ ", status="
+ inst.getStatus()
+ ", currentTask="
+ inst.getCurrentTaskId()
+ ", workflow="
+ inst.getWorkflow().getName()
+ ",wallClockTime="
+ client
.getWorkflowWallClockMinutes(inst
.getId())
+ ",currentTaskWallClockTime="
+ client
.getWorkflowCurrentTaskWallClockMinutes(inst
.getId()) + "]");
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
} else if (operation.equals("--getNextPage")) {
XmlRpcWorkflowManagerClient client = new XmlRpcWorkflowManagerClient(
new URL(url));
WorkflowInstancePage page = null;
String status = null;
int pageNum = -1;
for (int i = 4; i < args.length; i++) {
if (args[i].equals("--status")) {
status = args[++i];
} else if (args[i].equals("--pageNum")) {
pageNum = Integer.parseInt(args[++i]);
}
}
if (pageNum == -1) {
System.err.println(getNextPageOperation);
System.exit(1);
}
try {
if (status != null && !status.equals("")) {
page = client
.paginateWorkflowInstances(pageNum + 1, status);
} else {
page = client.paginateWorkflowInstances(pageNum + 1);
}
System.out.println("Page: [num=" + page.getPageNum() + ","
+ "pageSize=" + page.getPageSize() + ",totalPages="
+ page.getTotalPages() + "]");
if (page.getPageWorkflows() != null
&& page.getPageWorkflows().size() > 0) {
for (Iterator i = page.getPageWorkflows().iterator(); i
.hasNext();) {
WorkflowInstance inst = (WorkflowInstance) i.next();
System.out
.println("Instance: [id="
+ inst.getId()
+ ", status="
+ inst.getStatus()
+ ", currentTask="
+ inst.getCurrentTaskId()
+ ", workflow="
+ inst.getWorkflow().getName()
+ ",wallClockTime="
+ client
.getWorkflowWallClockMinutes(inst
.getId())
+ ",currentTaskWallClockTime="
+ client
.getWorkflowCurrentTaskWallClockMinutes(inst
.getId()) + "]");
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
} else if (operation.equals("--getPrevPage")) {
XmlRpcWorkflowManagerClient client = new XmlRpcWorkflowManagerClient(
new URL(url));
WorkflowInstancePage page = null;
String status = null;
int pageNum = -1;
for (int i = 4; i < args.length; i++) {
if (args[i].equals("--status")) {
status = args[++i];
} else if (args[i].equals("--pageNum")) {
pageNum = Integer.parseInt(args[++i]);
}
}
if (pageNum == -1) {
System.err.println(getPrevPageOperation);
System.exit(1);
}
try {
if (status != null && !status.equals("")) {
page = client
.paginateWorkflowInstances(pageNum - 1, status);
} else {
page = client.paginateWorkflowInstances(pageNum - 1);
}
System.out.println("Page: [num=" + page.getPageNum() + ","
+ "pageSize=" + page.getPageSize() + ",totalPages="
+ page.getTotalPages() + "]");
if (page.getPageWorkflows() != null
&& page.getPageWorkflows().size() > 0) {
for (Iterator i = page.getPageWorkflows().iterator(); i
.hasNext();) {
WorkflowInstance inst = (WorkflowInstance) i.next();
System.out
.println("Instance: [id="
+ inst.getId()
+ ", status="
+ inst.getStatus()
+ ", currentTask="
+ inst.getCurrentTaskId()
+ ", workflow="
+ inst.getWorkflow().getName()
+ ",wallClockTime="
+ client
.getWorkflowWallClockMinutes(inst
.getId())
+ ",currentTaskWallClockTime="
+ client
.getWorkflowCurrentTaskWallClockMinutes(inst
.getId()) + "]");
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
else if (operation.equals("--getWorkflowInst")) {
XmlRpcWorkflowManagerClient client = new XmlRpcWorkflowManagerClient(
new URL(url));
WorkflowInstance inst = null;
String wInstId = null;
for (int i = 4; i < args.length; i++) {
if (args[i].equals("--id")) {
wInstId = args[++i];
}
}
try {
inst = client.getWorkflowInstanceById(wInstId);
if (inst != null) {
System.out
.println("Instance: [id="
+ inst.getId()
+ ", status="
+ inst.getStatus()
+ ", currentTask="
+ inst.getCurrentTaskId()
+ ", workflow="
+ inst.getWorkflow().getName()
+ ",wallClockTime="
+ client.getWorkflowWallClockMinutes(inst
.getId())
+ ",currentTaskWallClockTime="
+ client
.getWorkflowCurrentTaskWallClockMinutes(inst
.getId()) + "]");
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e.getMessage());