protected static final String ResourcePoolEvent = null;
public VcEventRouter() {
/* High level handler for external vm events. */
VcEventListener.installExtEventHandler(vmEvents, new IVcEventHandler() {
@Override
public boolean eventHandler(VcEventType type, Event e)
throws Exception {
// Event can be either VmEvent or EventEx (TODO: Explicitly check for
// VM specific EventEx class usage? e.g. VcEventType.VmAppHealthChanged?)
AuAssert.check(e instanceof VmEvent || e instanceof EventEx);
ManagedObjectReference moRef = e.getVm().getVm();
switch (type) {
case VmRemoved: {
VcCache.purge(moRef);
ManagedObjectReference rpMoRef = VcCache.removeVmRpPair(moRef);
if (rpMoRef != null) {
VcCache.refresh(rpMoRef);
}
return false;
}
case VmDisconnected:
case VmConnected: {
VcVirtualMachine vm = VcCache.getIgnoreMissing(moRef);
if (vm == null) {
return false;
}
vm.update();
break;
}
case VmResourcePoolMoved: {
VmResourcePoolMovedEvent event = (VmResourcePoolMovedEvent) e;
VcCache.refresh(event.getOldParent().getResourcePool());
VcCache.refresh(event.getNewParent().getResourcePool());
break;
}
case VmCreated: {
VmCreatedEvent event = (VmCreatedEvent) e;
VcVirtualMachine vm = VcCache.get(event.getVm().getVm());
vm.refreshRP();
break;
}
case HostRemoved: {
logger.info("Host removed event received" + e);
}
}
VcCache.refreshAll(moRef);
return false;
}
});
/* High level handler for external rp events. */
VcEventListener.installExtEventHandler(rpEvents, new IVcEventHandler() {
@Override
public boolean eventHandler(VcEventType type, Event e)
throws Exception {
ManagedObjectReference moRef =
((ResourcePoolEvent) e).getResourcePool().getResourcePool();