
|
Force-saving router/swiftlet configuration from inside a Swiftlet
I am trying to make some changes to a proprietary extension swiftlet to allow some dynamic configuration changes on startup based on environmental conditions that the swiftlet is coded to check. Once I have made these changes to the Entity and EntityLists within my swiftlet's Configuration object, I want to save those changes to the RouterConfiguration file in the same way that can be done from the Explorer or the CLI.
Within the confines of the public SwiftMQ API, does anyone know the easiest way to do this from within an Extension Swiftlet? I can see writeContent methods within the Entity and Configuration objects, but no obvious way to construct the appropriate DataOutput relating to the running Router's configuration file; so I am assuming there is a better way, but haven't been able to find that better way.
Appreciate any help/ideas/sample or pseudo code.
|

|
Re: Force-saving router/swiftlet configuration from inside a Swiftlet
Yes, you execute any CLI command on the local router from a custom Swiftlet as well:
MgmtSwiftlet mgmtSwiftlet = (MgmtSwiftlet) SwiftletManager.getInstance().getSwiftlet("sys$mgmt");
CLIExecutor cliexec = mgmtSwiftlet.createCLIExecutor();
cliexec.execute("save");
|

|
Re: Force-saving router/swiftlet configuration from inside a Swiftlet
Ahh, many thanks - I wondered if that was the way to go about it.
I'm having issues using that approach however - whichever command I execute (save, help, sr routername etc), execute(..) throws a NullPointerException inside java.lang.StringTokenizer (line 146, JDK 1.4.2_19 with SwiftMQ 7.5.1). A debug inspection shows that CliExecutorImpl and SwiftUtilities.tokenize(..) is passing a null string to the StringTokenizer with a delimiter of "/".
Any idea why would this be? I'm guessing this is supposed to be a context path in which to execute the command, so if doing this during a swiftlet's startup, is the context in which to execute not set correctly at that time?
|

|
Re: Force-saving router/swiftlet configuration from inside a Swiftlet
Oops, sorry. We use the CLIExceutor internally and only in the Deploy Swiftlet to execute before/after deployment CLI commands which do not include "save".
So just forget the CLIExecutor and use:
SwiftletManager.getInstance().saveConfiguration();
(This would be called by the "save" command out of a proper context as well).
|

|
Re: Force-saving router/swiftlet configuration from inside a Swiftlet
Ahh, great - this works perfectly! I hadn't seen it earlier as I was still looking at the 5.2.5 API jar where this function was not public/available. Thankfully we're planning on doing the upgrade to 7.5.1 so this shouldn't be an issue.
Thanks a lot for your assistance.
|