[wsas-java-dev] svn commit r1747 - in trunk/wsas/java/modules:
clustering/src/org/wso2/wsas/clustering samples/NodeManagement
svn at wso2.org
svn at wso2.org
Wed Apr 4 03:32:38 PDT 2007
Author: azeez
Date: Wed Apr 4 03:32:21 2007
New Revision: 1747
Added:
trunk/wsas/java/modules/samples/NodeManagement/
trunk/wsas/java/modules/samples/NodeManagement/unloadservicegroups
Modified:
trunk/wsas/java/modules/clustering/src/org/wso2/wsas/clustering/NodeManagerClient.java
Log:
Making the scriptable admin client a bit more user friendly, and adding a sample demostrating how it is used
Modified: trunk/wsas/java/modules/clustering/src/org/wso2/wsas/clustering/NodeManagerClient.java
==============================================================================
--- trunk/wsas/java/modules/clustering/src/org/wso2/wsas/clustering/NodeManagerClient.java (original)
+++ trunk/wsas/java/modules/clustering/src/org/wso2/wsas/clustering/NodeManagerClient.java Wed Apr 4 03:32:21 2007
@@ -27,71 +27,39 @@
stub = new WSO2WSASNodeManagerStub(nodeManagerEPR);
}
- private void reloadConfiguration() throws Exception {
- WSO2WSASNodeManagerStub.ReloadConfigurationResponse r = stub.reloadConfiguration();
- if (r.get_return()) {
- WSO2WSASNodeManagerStub.CommitResponse commitResponse = stub.commit();
- if (commitResponse.get_return()) { // TODO: Don't automatically commit. Let the shell script do it
- System.out.println("Successfully committed");
- } else {
- System.out.println("Commit failed");
- }
- }
+ private boolean reloadConfiguration() throws Exception {
+ return stub.reloadConfiguration().get_return();
}
- private void loadServiceGroup(String serviceGroupName) throws Exception {
- WSO2WSASNodeManagerStub.LoadServiceGroup req = new WSO2WSASNodeManagerStub.LoadServiceGroup();
+ private boolean loadServiceGroup(String serviceGroupName) throws Exception {
+ WSO2WSASNodeManagerStub.LoadServiceGroup req =
+ new WSO2WSASNodeManagerStub.LoadServiceGroup();
req.setServiceGroupName(serviceGroupName);
WSO2WSASNodeManagerStub.LoadServiceGroupResponse resp = stub.loadServiceGroup(req);
- if (resp.get_return()) {
- WSO2WSASNodeManagerStub.CommitResponse commitResponse = stub.commit();
- if (commitResponse.get_return()) {
- System.out.println("Successfully committed");
- } else {
- System.out.println("Commit failed");
- }
- }
+ return resp.get_return();
}
- private void unloadServiceGroup(String serviceGroupName) throws Exception {
- WSO2WSASNodeManagerStub.UnloadServiceGroup req = new WSO2WSASNodeManagerStub.UnloadServiceGroup();
+ private boolean unloadServiceGroup(String serviceGroupName) throws Exception {
+ WSO2WSASNodeManagerStub.UnloadServiceGroup req =
+ new WSO2WSASNodeManagerStub.UnloadServiceGroup();
req.setServiceGroupName(serviceGroupName);
WSO2WSASNodeManagerStub.UnloadServiceGroupResponse resp = stub.unloadServiceGroup(req);
- if (resp.get_return()) {
- WSO2WSASNodeManagerStub.CommitResponse commitResponse = stub.commit();
- if (commitResponse.get_return()) {
- System.out.println("Successfully committed");
- } else {
- System.out.println("Commit failed");
- }
- }
+ return resp.get_return();
}
- private void applyServicePolicy() throws Exception {
+ private boolean applyServicePolicy() throws Exception {
// TODO
+ return false;
}
- private void commit() throws Exception {
- WSO2WSASNodeManagerStub.CommitResponse commitResponse = stub.commit();
- if (commitResponse.get_return()) {
- System.out.println("Successfully committed");
- } else {
- System.out.println("Commit failed");
- }
- }
-
- private void prepare() throws Exception {
- WSO2WSASNodeManagerStub.PrepareResponse prepareResponse = stub.prepare();
- if (prepareResponse.get_return()) {
- System.out.println("Successfully sent prepare request.");
- } else {
- System.out.println("Preparation failed");
+ private boolean commit() throws Exception {
+ if (stub.prepare().get_return()) {
+ return stub.commit().get_return();
}
+ return false;
}
/**
- * Usage: admin --epr <epr> --operation <reloadConfig | loadSG | unloadSG | applyPolicy | prepare | commit>
- *
* @param args
*/
public static void main(String[] args) {
@@ -101,21 +69,27 @@
String operation = getParam("--operation", args);
+ boolean isOperationSuccessful = false;
if (operation.equals("reloadconfig")) {
- client.reloadConfiguration();
+ isOperationSuccessful = client.reloadConfiguration();
} else if (operation.equals("loadsg")) {
- client.loadServiceGroup(getParam("--service-group", args));
+ isOperationSuccessful = client.loadServiceGroup(getParam("--service-group", args));
} else if (operation.equals("unloadsg")) {
- client.unloadServiceGroup(getParam("--service-group", args));
+ isOperationSuccessful = client.unloadServiceGroup(getParam("--service-group", args));
} else if (operation.equals("applypolicy")) {
- client.applyServicePolicy();
- } else if (operation.equals("prepare")) {
- client.prepare();
+ isOperationSuccessful = client.applyServicePolicy();
} else if (operation.equals("commit")) {
- client.commit();
+ isOperationSuccessful = client.commit();
} else {
printUsage();
}
+
+ // Set the correct exit status
+ if (isOperationSuccessful) {
+ System.exit(0);
+ } else {
+ System.exit(1);
+ }
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
@@ -123,7 +97,9 @@
}
private static void printUsage() {
- System.out.println("usage: admin --epr <epr> --operation <reloadconfig|loadsg|unloadsg|applypolicy> [options]");
+ System.out.println("usage: admin --epr <epr> " +
+ "--operation <reloadconfig|loadsg|unloadsg|applypolicy|commit> " +
+ "[options]");
System.out.println("options: --service-group <ServiceGroupName>");
}
Added: trunk/wsas/java/modules/samples/NodeManagement/unloadservicegroups
==============================================================================
--- (empty file)
+++ trunk/wsas/java/modules/samples/NodeManagement/unloadservicegroups Wed Apr 4 03:32:21 2007
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+EPR=http://10.100.1.118:9762/services/WSO2WSASNodeManager
+
+./admin.sh --epr $EPR --operation unloadsg --service-group echo
+if [ "$?" = "0" ]; then
+ ./admin.sh --epr $EPR --operation unloadsg --service-group version
+ if [ "$?" = "0" ]; then
+ ./admin.sh --epr $EPR --operation commit
+ echo Successfully committed.
+ else
+ echo Unloading service group "Version" failed
+ fi
+else
+ echo Unloading service group "Echo" failed
+fi
\ No newline at end of file
More information about the Wsas-java-dev
mailing list