4.0

Table Of Contents
5 Define the event and publish it to the Orchestrator notification mechanism by calling the
IPluginPublisher.pushWatcherEvent() method.
The SolarSystemWatchersManager.starFlareEvent() method checks whether the magnitude value
exceeds a maximum magnitude value. If the maximum magnitude value is exceeded, the
starFlareEvent() method writes the flare event in the logs and publishes the event to the Orchestrator
notification mechanism.
public void starFlareEvent(String starid, double magnitude) {
synchronized (watchers) {
List<String> watchersToRemove = new Vector<String>();
for (PluginWatcher watcher : watchers.values()) {
Properties props = watcher.getTrigger().getProperties();
String wStarId = props.getProperty(SolarSystemTriggerGenerator.STAR_ID);
String wMagnitude = props.getProperty(SolarSystemTriggerGenerator.MAGNITUDE);
if (wStarId != null && wStarId.equals(starid)) {
double wMagnLimit = Double.parseDouble(wMagnitude);
if (magnitude >= wMagnLimit) {
log.info("pushWatcherEvent() for id '" + watcher.getId() + "'");
pluginPublisher.pushWatcherEvent(watcher.getId(), null);
}
}
}
}
}
6 (Optional) Remove the watchers from the notification mechanism after the events occur.
The SolarSystemWatchersManager.starFlareEvent() method adds the watcher to the list of watchers to
remove and defines a method to remove that list of watchers from the hashtable.
public void starFlareEvent(String starid, double magnitude) {
synchronized (watchers) {
List<String> watchersToRemove = new Vector<String>();
for (PluginWatcher watcher : watchers.values()) {
Properties props = watcher.getTrigger().getProperties();
String wStarId = props.getProperty(SolarSystemTriggerGenerator.STAR_ID);
String wMagnitude = props.getProperty(SolarSystemTriggerGenerator.MAGNITUDE);
if (wStarId != null && wStarId.equals(starid)) {
double wMagnLimit = Double.parseDouble(wMagnitude);
if (magnitude >= wMagnLimit) {
log.info("pushWatcherEvent() for id '" + watcher.getId() + "'");
pluginPublisher.pushWatcherEvent(watcher.getId(), null);
watchersToRemove.add(watcher.getId());
}
}
}
for (String toRemove : watchersToRemove) {
watchers.remove(toRemove);
}
}
}
You defined an event for a watcher to watch and published the event to the Orchestrator notification
mechanism. Orchestrator notifies any workflows that are waiting for that event that it has occurred.
What to do next
Define objects and methods to add to the Orchestrator JavaScript API.
vCenter Orchestrator Developer's Guide
184 VMware, Inc.