Search code examples
javawebspherejava-ee-6jmxwebsphere-8

Set Config Param for Command AdminTask.createCluster


my problem is to define the config properties:

I got this SourceCode:

            Session session = new Session();
    ConfigService cService = new ConfigServiceProxy(aClient);

    CommandMgr cmdMgr = CommandMgr.getCommandMgr(aClient);
    AdminCommand cmd = cmdMgr.createCommand("createCluster");

    Hashtable<String,Object> myParam = new Hashtable<String, Object>();
    myParam.put("clusterName", ClusterName);
    myParam.put("preferLocal", true);

    cmd.setParameter("clusterConfig", myParam); 

    cmd.setConfigSession(session);
    cmd.execute();

    CommandResult result = cmd.getCommandResult();

    cService.save(session, false);

The WsAdmin command is :

AdminTask.createCluster('[-clusterConfig [-clusterName test_rpc -preferLocal true]]') 

Now how can i set clusterConfig? I try to define Hashtable with the values of clustername and preferLocal. So i can set clusterConfig with this hashtable.

As response i get : Excep.: unknown paramname clusterConfig....

Does anybody know how to set something if the setParameter looks like [-x [-y "value" -z "value2"]].

i try this to get all Parameter for this Task :

List temp = cmd.listAllParameterName();

And the Result = List still empty. misterious

Thanks


Solution

  • After long Research i found the solution.

    There are some steps to predefine.

    AdminTask.createCluster('[-clusterConfig [-clusterName test_rpc -preferLocal true]]')
    

    clusterConfig is one step.

    To define the ClusterConfig the SourceCode looks like:

                AdminCommand cmd = cmdMgr.createCommand("createCluster");
    
                //gotoStep
        CommandStep step = ((TaskCommand) cmd).gotoStep("clusterConfig");
    
        step.setParameter("clusterName", ClusterName);
        step.setParameter("preferLocal", true);
    
        cmd.setConfigSession(session);
        cmd.execute();
    

    And now it works perfect!