I can confirm that I was able to implement a Plugin,
whose purpose was to list running Remote Strategies
in the onStart of the Plugin implementation.
This allows my Linux strategy runner to determine
whether certain critical strategies are indeed running
on the Remote Server.
It works very well !! Thanks ! You guys/gals are the Best.
HyperScalper
final public class MyPlugin extends Plugin {
IPluginContext pluginContext;
IRemoteStrategyManager remoteStrategyManager = null;
final public IPluginContext getPluginContext() {
return pluginContext;
}
@Override
final public void onStart(final IPluginContext pluginContextArg) throws JFException {
super.onStart(pluginContext);
pluginContext = pluginContextArg; // allows access to all system functionality
remoteStrategyManager = pluginContext.getRemoteStrategyManager();
log("************** MyPlugin onStart..."); // print to console
try {
log("Trying to list all REMOTE Strategies...");
//Future<IStrategyResponse<Set<DESCRIPTOR>>> startedStrategies =
Future<IStrategyResponse<Set<IRemoteStrategyDescriptor>>> future =
remoteStrategyManager.getStartedStrategies(); // asynchronous ??
IStrategyResponse<Set<IRemoteStrategyDescriptor>> strategyResponse = null;
try {
strategyResponse = future.get(60, TimeUnit.SECONDS); // wait for response
}
catch(Exception ee) {
ee.printStackTrace();
}
Set<IRemoteStrategyDescriptor> strategyDescriptorSet = strategyResponse.getResult();
if (strategyDescriptorSet!=null) {
int count = 0;
for (IRemoteStrategyDescriptor descriptor : strategyDescriptorSet) {
++count;
log("RemoteStrategyDescriptor #"+count+" name: "+descriptor.getName());
}
}
else {
log("strategyDescriptorSet is null.");
}
log("After list all REMOTE Strategies.");
}
catch(Exception e) {
e.printStackTrace();
}
}
@Override
final public void onStop() throws JFException {
super.onStop();
log("************** MyPlugin onStop...");
}
}
// run the plugin, which will list remote strategies
myPlugin = new MyPlugin();
new Thread(new PluginRunner()).start(); // asynchronous
//
//
//
final public class PluginRunner implements Runnable {
public void run() {
try {
log("PluginRunner start...");
getIClient().runPlugin(myPlugin, myStrategyExceptionHandler);
log("PluginRunner after runPlugin...");
}
catch(Exception e) {
e.printStackTrace();
}
}
}
Output of the listing is:
2014-Feb-14 05:22:16 ************** MyPlugin onStart...
2014-Feb-14 05:22:16 Trying to list all REMOTE Strategies...
2014-Feb-14 05:22:16 RemoteStrategyDescriptor #1 name: HyperScanner
2014-Feb-14 05:22:16 RemoteStrategyDescriptor #2 name: HyperBotWatchdog
2014-Feb-14 05:22:16 After list all REMOTE Strategies.
2014-Feb-14 05:22:16 PluginRunner after runPlugin...