beautypg.com

Shutdownclient.java sample program – HP Integrity NonStop H-Series User Manual

Page 102

background image

}

public static void main(String[] args) {
NSASJEJBStatisticsClient obj = null;
// Initialize the logger
System.setProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager");
System.setProperty("logging.configuration", "file:logging.properties");
Logger logger1 = Logger.getLogger("NSASJClient", "com.hp.nonstop.nsasj.client.demo");
// Get the args
if (args.length > 2) {
System.out
.println("Usage : java com.hp.nonstop.nsasj.client.demo.NSASJVersionClient
");
System.exit(0);
} else if (args.length == 2)
obj = new NSASJEJBStatisticsClient(args[0], Boolean.valueOf(args[1]));
else if (args.length == 1)
obj = new NSASJEJBStatisticsClient(args[0]);
else
obj = new NSASJEJBStatisticsClient(null);
obj.logger = logger1;
// Connect to Host Controller
obj.connectToHC();
// Create and execute the command
obj.executeCommand();
// Disconnect and exit
obj.disconnectFromHC();

}
boolean enableEJB3Stats = false;

}

ShutdownClient.java

sample program

ShutdownClient .java
/* Copyright 2013 Hewlett-Packard Development Company, L.P. */
package com.hp.nsk.nsasj.client.demo;

import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import org.jboss.dmr.ModelNode;
import org.jboss.logging.Logger;
import com.hp.nsk.nsasj.client.NSASJClient;
import com.hp.nsk.tsmp.SvClassInstances;

/**
*
* @File ShutdownClient.java This file implements the various shutdown commands of NSASJ
*
*/
public class ShutdownClient extends NSASJClient {

public ShutdownClient(String propFile, String operation, String serverName) {
super(propFile);
this.operation = operation;
this.serverName = serverName;

}

public ShutdownClient(String propFile, String operation, String pmon, String svclass) {
super(propFile);
this.operation = operation;
this.pmon = pmon;
this.serverClassName = svclass;

}
public ShutdownClient(String propFile, String operation) {
super(propFile);
this.operation = operation;

}

public void executeCommand() {
String command = null;
command = this.operation;
if(command.equals("ShutdownHC")){
shutdownHostController();
}else if(command.equals("ShutdownAllServers")){
this.serverName = "*";
shutdownAllServers();
}else if(command.equals("ShutdownServer")){
shutdownServer(this.serverName);

}else if(command.equals("ShutdownServerClass")){
shutdownServerClass();
}else{
System.out.println("Improper command");
System.exit(0);
}

102 Programmatic Management of NSASJ using API

This manual is related to the following products: