public void fire(String path, Object data) { eventf.fire(path, data); } }
private void unlock() { logger.warn(String.format("management node[uuid:%s] becomes unavailable, publish unlock event[unlock key:%s, lock reason:%s] for resource it holds", lmeta.senderManagementUuid, lmeta.unlockKey, lmeta.reason)); evtf.fire(LockResourceMessage.UNLOCK_CANONICAL_EVENT_PATH, lmeta.unlockKey); dismiss(); } };
protected void fireDisconnectedCanonicalEvent(ErrorCode reason) { PrimaryStorageCanonicalEvent.DisconnectedData data = new PrimaryStorageCanonicalEvent.DisconnectedData(); data.setPrimaryStorageUuid(self.getUuid()); data.setReason(reason); evtf.fire(PrimaryStorageCanonicalEvent.PRIMARY_STORAGE_DISCONNECTED, data); }
protected void fireDisconnectedCanonicalEvent(ErrorCode reason) { BackupStorageCanonicalEvents.DisconnectedData data = new BackupStorageCanonicalEvents.DisconnectedData(); data.setBackupStorageUuid(self.getUuid()); data.setReason(reason); evtf.fire(BackupStorageCanonicalEvents.BACKUP_STORAGE_DISCONNECTED, data); }
evtf.fire(PrimaryStorageCanonicalEvent.PRIMARY_STORAGE_HOST_STATUS_CHANGED_PATH, data);
private void handleAnonymousVm(final String vmUuid, final VmInstanceState actualState, VmInstanceState expected) { final VmInstanceVO vm = dbf.findByUuid(vmUuid, VmInstanceVO.class); if (vm == null) { logger.debug(String.format("[Vm Tracer] detects stranger vm[identity:%s, state:%s]", vmUuid, actualState)); String cachedHostUuid = strangeVms.get(vmUuid); if (cachedHostUuid != null) { logger.debug(String.format("[Vm Tracer] detects stranger vm[identity:%s, state:%s] but it's already in cache, skip firing event", vmUuid, actualState)); return; } strangeVms.put(vmUuid, hostUuid); VmTracerCanonicalEvents.StrangerVmFoundData data = new VmTracerCanonicalEvents.StrangerVmFoundData(); data.setVmIdentity(vmUuid); data.setVmState(actualState); data.setHostUuid(hostUuid); evtf.fire(VmTracerCanonicalEvents.STRANGER_VM_FOUND_PATH, data); N.New(VmInstanceVO.class, vmUuid).warn_("A strange vm[%s] was found on the host[%s], May cause problems, Please manually clean this vm", vmUuid, hostUuid); return; } handleStateChangeOnHostSide(vmUuid, actualState, expected); }
@Override public void handle(Map chainData) { /** * send event, if cloudformation is creating now, it will recieve the event and record vrouter for rollback */ ApplianceVmVO avo = (ApplianceVmVO) chainData.get(ApplianceVmVO.class.getSimpleName()); L3NetworkConstant.VRouterData data = new L3NetworkConstant.VRouterData(); for (ApplianceVmNicSpec nic: spec.getAdditionalNics()) { data.l3NetworkUuid.add(nic.getL3NetworkUuid()); } if (data.l3NetworkUuid.isEmpty()) { data.l3NetworkUuid.add(spec.getManagementNic().getL3NetworkUuid()); } data.vrouterUuid = avo.getUuid(); evtf.fire(L3NetworkConstant.VROUTER_CREATE_EVENT_PATH, data); logger.debug(String.format("successfully created appliance vm[uuid:%s, name: %s, appliance vm type: %s]", avo.getUuid(), avo.getName(), avo.getApplianceVmType())); ApplianceVmVO apvo = dbf.findByUuid(avo.getUuid(), ApplianceVmVO.class); ApplianceVmInventory ainv = ApplianceVmInventory.valueOf(apvo); complete.success(ainv); } }).error(new FlowErrorHandler(complete) {
public void fireSnapShotStatusChangedEvent(VolumeSnapshotStatus oldStatus, VolumeSnapshotInventory vsi) { SnapShotCanonicalEvents.SnapShotStatusChangedData d = new SnapShotCanonicalEvents.SnapShotStatusChangedData(); d.setInventory(vsi); d.setDate(new Date()); d.setNewStatus(vsi.getStatus()); d.setOldStatus(oldStatus == null ? null : oldStatus.toString()); d.setSnapShotUuid(vsi.getUuid()); evtf.fire(SnapShotCanonicalEvents.SNAPSHOT_STATUS_CHANGED_PATH, d); } }
public void fireVolumeStatusChangedEvent(VolumeStatus oldStatus, VolumeInventory vol, String accountUuid) { VolumeCanonicalEvents.VolumeStatusChangedData d = new VolumeCanonicalEvents.VolumeStatusChangedData(); d.setInventory(vol); d.setDate(new Date()); d.setNewStatus(vol.getStatus()); d.setOldStatus(oldStatus == null ? null : oldStatus.toString()); d.setVolumeUuid(vol.getUuid()); d.setAccountUuid(accountUuid); evtf.fire(VolumeCanonicalEvents.VOLUME_STATUS_CHANGED_PATH, d); } }
protected void fireDisconnectedCanonicalEvent(ErrorCode err) { ApplianceVmCanonicalEvents.DisconnectedData data = new ApplianceVmCanonicalEvents.DisconnectedData(); data.setApplianceVmType(getSelf().getApplianceVmType()); data.setApplianceVmUuid(self.getUuid()); data.setReason(err); evtf.fire(ApplianceVmCanonicalEvents.DISCONNECTED_PATH, data); }
@Override public void run(FlowTrigger trigger, Map data) { ManagementNodeLifeCycleData d = new ManagementNodeLifeCycleData(); d.setNodeUuid(node().getUuid()); d.setInventory(ManagementNodeInventory.valueOf(node())); d.setLifeCycle(LifeCycle.NodeJoin.toString()); evtf.fire(ManagementNodeCanonicalEvent.NODE_LIFECYCLE_PATH, d); trigger.next(); } }).done(new FlowDoneHandler(null) {
@Override public void handle(Map data) { casf.asyncCascadeFull(CascadeConstant.DELETION_CLEANUP_CODE, issuer, ctx, new NopeCompletion()); bus.publish(evt); HostDeletedData d = new HostDeletedData(); d.setInventory(HostInventory.valueOf(self)); d.setHostUuid(self.getUuid()); evtf.fire(HostCanonicalEvents.HOST_DELETED_PATH, d); } }).error(new FlowErrorHandler(msg) {
@Override public void handle(Map data) { self = dbf.reload(self); evt.setInventory(VmInstanceInventory.valueOf(self)); bus.publish(evt); VmNicInventory vmNicInventory = (VmNicInventory) data.get(vmNicInvKey); VmNicCanonicalEvents.VmNicEventData vmNicEventData = new VmNicCanonicalEvents.VmNicEventData(); vmNicEventData.setCurrentStatus(self.getState().toString()); String vmNicAccountUuid = acntMgr.getOwnerAccountUuidOfResource(vmNicInventory.getUuid()); vmNicEventData.setAccountUuid(vmNicAccountUuid); vmNicEventData.setInventory(vmNicInventory); evtf.fire(VmNicCanonicalEvents.VM_NIC_CREATED_PATH, vmNicEventData); } }).error(new FlowErrorHandler(msg) {
private void handle(APIDeleteUserMsg msg) { UserVO user = dbf.findByUuid(msg.getUuid(), UserVO.class); if (user != null) { UserInventory inv = UserInventory.valueOf(user); UserDeletedData d = new UserDeletedData(); d.setInventory(inv); d.setUserUuid(inv.getUuid()); evtf.fire(IdentityCanonicalEvents.USER_DELETED_PATH, d); dbf.remove(user); } APIDeleteUserEvent evt = new APIDeleteUserEvent(msg.getId()); bus.publish(evt); }
data.setOldStatus(before.toString()); data.setInventory(HostInventory.valueOf(self)); evtf.fire(HostCanonicalEvents.HOST_STATUS_CHANGED_PATH, data);
@AsyncThread private void nodeDie(ManagementNodeVO n) { logger.debug("Node " + n.getUuid() + " has gone because its heartbeat stopped"); nodeLifeCycle.nodeLeft(ManagementNodeInventory.valueOf(n)); ManagementNodeLifeCycleData d = new ManagementNodeLifeCycleData(); d.setInventory(ManagementNodeInventory.valueOf(n)); d.setNodeUuid(n.getUuid()); d.setLifeCycle(LifeCycle.NodeLeft.toString()); evtf.fire(ManagementNodeCanonicalEvent.NODE_LIFECYCLE_PATH, d); }
protected boolean changeStatus(BackupStorageStatus status) { if (status == self.getStatus()) { return false; } BackupStorageStatus oldStatus = self.getStatus(); self.setStatus(status); dbf.update(self); BackupStorageStatusChangedData d = new BackupStorageStatusChangedData(); d.setBackupStorageUuid(self.getUuid()); d.setNewStatus(status.toString()); d.setOldStatus(oldStatus.toString()); d.setInventory(BackupStorageInventory.valueOf(self)); evtf.fire(BackupStorageCanonicalEvents.BACKUP_STORAGE_STATUS_CHANGED, d); logger.debug(String.format("change backup storage[uuid:%s] status to %s", self.getUuid(), status)); return true; } }
protected boolean changeStatus(PrimaryStorageStatus status) { if (status == self.getStatus()) { return false; } PrimaryStorageStatus oldStatus = self.getStatus(); self.setStatus(status); self = dbf.updateAndRefresh(self); PrimaryStorageStatusChangedData d = new PrimaryStorageStatusChangedData(); d.setInventory(PrimaryStorageInventory.valueOf(self)); d.setPrimaryStorageUuid(self.getUuid()); d.setOldStatus(oldStatus.toString()); d.setNewStatus(status.toString()); evtf.fire(PrimaryStorageCanonicalEvent.PRIMARY_STORAGE_STATUS_CHANGED_PATH, d); logger.debug(String.format("the primary storage[uuid:%s, name:%s] changed status from %s to %s", self.getUuid(), self.getName(), oldStatus, status)); return true; }
public void fireVolumeStatusChangedEvent(VolumeStatus oldStatus, VolumeInventory vol) { String accountUuid = null; boolean volumeAccountExists = Q.New(AccountResourceRefVO.class).eq(AccountResourceRefVO_.resourceUuid, vol.getUuid()).isExists(); if (volumeAccountExists) { accountUuid = Q.New(AccountResourceRefVO.class) .select(AccountResourceRefVO_.ownerAccountUuid) .eq(AccountResourceRefVO_.resourceUuid, vol.getUuid()).limit(1).findValue(); } VolumeCanonicalEvents.VolumeStatusChangedData d = new VolumeCanonicalEvents.VolumeStatusChangedData(); d.setInventory(vol); d.setDate(new Date()); d.setNewStatus(vol.getStatus()); d.setOldStatus(oldStatus == null ? null : oldStatus.toString()); d.setVolumeUuid(vol.getUuid()); d.setAccountUuid(accountUuid); evtf.fire(VolumeCanonicalEvents.VOLUME_STATUS_CHANGED_PATH, d); }
data.setNewState(nextState); evt.setInventory(PrimaryStorageInventory.valueOf(self)); evtf.fire(PrimaryStorageCanonicalEvent.PRIMARY_STORAGE_STATE_CHANGED_PATH, data); bus.publish(evt);