@Override protected void run(Map tokens, Object data) { HostCanonicalEvents.HostStatusChangedData d = (HostCanonicalEvents.HostStatusChangedData) data; if (HostStatus.Connected.toString().equals(d.getNewStatus())) { hostDisconnectCount.remove(d.getHostUuid()); } else if (HostStatus.Disconnected.toString().equals(d.getNewStatus()) && HostStatus.Connecting.toString().equals(d.getOldStatus())) { hostDisconnectCount.computeIfAbsent(d.getHostUuid(), key -> new AtomicInteger(0)).addAndGet(1); } } });
HostStatus next = before.nextStatus(event); if (before == next) { return false; data.setNewStatus(next.toString()); data.setOldStatus(before.toString()); data.setInventory(HostInventory.valueOf(self)); evtf.fire(HostCanonicalEvents.HOST_STATUS_CHANGED_PATH, data);
@Override protected void setup() { onEvent(HostCanonicalEvents.HOST_STATUS_CHANGED_PATH, ((tokens, data) -> { HostCanonicalEvents.HostStatusChangedData d = (HostCanonicalEvents.HostStatusChangedData) data; return hostUuid.equals(d.getHostUuid()) && d.getNewStatus().equals(HostStatus.Connected.toString()); })); onEvent(HostCanonicalEvents.HOST_DELETED_PATH, ((tokens, data) -> { HostCanonicalEvents.HostDeletedData d = (HostCanonicalEvents.HostDeletedData) data; return hostUuid.equals(d.getHostUuid()); })); } }
@Override protected void setup() { onEvent(HostCanonicalEvents.HOST_DELETED_PATH, (tokens, data) -> { HostCanonicalEvents.HostDeletedData d = (HostCanonicalEvents.HostDeletedData) data; return hostUuid.equals(d.getHostUuid()); }); onEvent(HostCanonicalEvents.HOST_STATUS_CHANGED_PATH, (tokens, data) -> { HostCanonicalEvents.HostStatusChangedData d = (HostCanonicalEvents.HostStatusChangedData) data; return d.getHostUuid().equals(hostUuid) && d.getNewStatus().equals(HostStatus.Connected.toString()); }); }
@Override protected void setup() { onEvent(HostCanonicalEvents.HOST_STATUS_CHANGED_PATH, ((tokens, data) -> { HostCanonicalEvents.HostStatusChangedData d = (HostCanonicalEvents.HostStatusChangedData) data; return hostUuid.equals(d.getHostUuid()) && d.getNewStatus().equals(HostStatus.Connected.toString()); })); onEvent(HostCanonicalEvents.HOST_DELETED_PATH, ((tokens, data) -> { HostCanonicalEvents.HostDeletedData d = (HostCanonicalEvents.HostDeletedData) data; return hostUuid.equals(d.getHostUuid()); })); } }
@Override protected void setup() { onEvent(HostCanonicalEvents.HOST_STATUS_CHANGED_PATH, ((tokens, data) -> { HostCanonicalEvents.HostStatusChangedData d = (HostCanonicalEvents.HostStatusChangedData) data; return d.getHostUuid().equals(hostUuid) && d.getNewStatus().equals(HostStatus.Connected.toString()); })); onEvent(HostCanonicalEvents.HOST_DELETED_PATH, ((tokens, data) -> { HostCanonicalEvents.HostDeletedData d = (HostCanonicalEvents.HostDeletedData) data; return d.getHostUuid().equals(hostUuid); })); onEvent(PrimaryStorageCanonicalEvent.PRIMARY_STORAGE_DELETED_PATH, ((tokens, data) -> { PrimaryStorageCanonicalEvent.PrimaryStorageDeletedData d = (PrimaryStorageCanonicalEvent.PrimaryStorageDeletedData) data; return d.getPrimaryStorageUuid().equals(primaryStorageUuid); })); } }
@Override protected void setup() { onEvent(HostCanonicalEvents.HOST_STATUS_CHANGED_PATH, (tokens, data) -> { HostCanonicalEvents.HostStatusChangedData d = (HostCanonicalEvents.HostStatusChangedData) data; return d.getHostUuid().equals(hostUuid) && d.getNewStatus().equals(HostStatus.Connected.toString()); }); onEvent(HostCanonicalEvents.HOST_DELETED_PATH, ((tokens, data) -> { HostCanonicalEvents.HostDeletedData d = (HostCanonicalEvents.HostDeletedData) data; return hostUuid.equals(d.getHostUuid()); })); onEvent(VmCanonicalEvents.VM_FULL_STATE_CHANGED_PATH, ((tokens, data) -> { VmCanonicalEvents.VmStateChangedData d = (VmCanonicalEvents.VmStateChangedData) data; return d.getVmUuid().equals(inventory.getUuid()) && d.getNewState().equals(VmInstanceState.Destroyed.toString()); })); } }
if (r.getCurrentHostStatus().equals(HostStatus.Disconnected.toString())) { if (autoReconnect) { return ReconnectDecision.ReconnectNow;
@Override protected boolean run(Map tokens, Object data) { HostCanonicalEvents.HostStatusChangedData d = (HostCanonicalEvents.HostStatusChangedData) data; if (!HostStatus.Connected.toString().equals(d.getNewStatus())) { return false;
@Override public void afterHostConnected(HostInventory inv) { if (inv.getStatus().equals(HostStatus.Connected.toString())){ List<String> vmUuids = Q.New(VmInstanceVO.class).select(VmInstanceVO_.uuid) .eq(VmInstanceVO_.hostUuid, inv.getUuid()) .listValues(); if(vmUuids.isEmpty()){ return; } new While<>(vmUuids).step((vmUuid, completion) -> { VmCheckOwnStateMsg msg = new VmCheckOwnStateMsg(); msg.setVmInstanceUuid(vmUuid); bus.makeTargetServiceIdByResourceUuid(msg, VmInstanceConstant.SERVICE_ID, vmUuid); bus.send(msg, new CloudBusCallBack(completion) { @Override public void run(MessageReply reply) { if(!reply.isSuccess()){ logger.warn(String.format("the host[uuid:%s] connected, but the vm[uuid:%s] fails to " + "update it's state , %s", inv.getUuid(), vmUuid, reply.getError())); } completion.done(); } }); }, 200).run(new NopeNoErrorCompletion()); } } }
@Override protected boolean run(Map tokens, Object data) { HostStatusChangedData d = (HostStatusChangedData) data; if (!HostStatus.Connected.toString().equals(d.getNewStatus())) { return false;
public static APIGetVmMigrationCandidateHostsReply __example__() { APIGetVmMigrationCandidateHostsReply reply = new APIGetVmMigrationCandidateHostsReply(); HostInventory hi = new HostInventory (); hi.setAvailableCpuCapacity(2L); hi.setAvailableMemoryCapacity(4L); hi.setClusterUuid(uuid()); hi.setManagementIp("192.168.0.1"); hi.setName("example"); hi.setState(HostState.Enabled.toString()); hi.setStatus(HostStatus.Connected.toString()); hi.setClusterUuid(uuid()); hi.setZoneUuid(uuid()); hi.setUuid(uuid()); hi.setTotalCpuCapacity(4L); hi.setTotalMemoryCapacity(4L); hi.setHypervisorType("KVM"); hi.setDescription("example"); hi.setCreateDate(new Timestamp(org.zstack.header.message.DocUtils.date)); hi.setLastOpDate(new Timestamp(org.zstack.header.message.DocUtils.date)); reply.setInventories(asList(hi)); return reply; }
hi.setName("example"); hi.setState(HostState.Enabled.toString()); hi.setStatus(HostStatus.Connected.toString()); hi.setClusterUuid(uuid()); hi.setZoneUuid(uuid());
public static APIQueryHostReply __example__() { APIQueryHostReply reply = new APIQueryHostReply(); HostInventory hi = new HostInventory (); hi.setAvailableCpuCapacity(2L); hi.setAvailableMemoryCapacity(4L); hi.setClusterUuid(uuid()); hi.setManagementIp("192.168.0.1"); hi.setName("example"); hi.setState(HostState.Enabled.toString()); hi.setStatus(HostStatus.Connected.toString()); hi.setClusterUuid(uuid()); hi.setZoneUuid(uuid()); hi.setUuid(uuid()); hi.setTotalCpuCapacity(4L); hi.setTotalMemoryCapacity(4L); hi.setHypervisorType("KVM"); hi.setDescription("example"); reply.setInventories(Arrays.asList(hi)); return reply; }
hi.setName("example"); hi.setState(HostState.Enabled.toString()); hi.setStatus(HostStatus.Connected.toString()); hi.setClusterUuid(uuid()); hi.setZoneUuid(zoneUuid);
public static APIUpdateHostEvent __example__() { APIUpdateHostEvent event = new APIUpdateHostEvent(); HostInventory hi = new HostInventory (); hi.setAvailableCpuCapacity(2L); hi.setAvailableMemoryCapacity(4L); hi.setClusterUuid(uuid()); hi.setManagementIp("192.168.0.1"); hi.setName("example"); hi.setState(HostState.Enabled.toString()); hi.setStatus(HostStatus.Connected.toString()); hi.setClusterUuid(uuid()); hi.setZoneUuid(uuid()); hi.setUuid(uuid()); hi.setTotalCpuCapacity(4L); hi.setTotalMemoryCapacity(4L); hi.setHypervisorType("KVM"); hi.setDescription("example"); event.setInventory(hi); return event; }
public static APIChangeHostStateEvent __example__() { APIChangeHostStateEvent event = new APIChangeHostStateEvent(); HostInventory hi = new HostInventory (); hi.setAvailableCpuCapacity(2L); hi.setAvailableMemoryCapacity(4L); hi.setClusterUuid(uuid()); hi.setManagementIp("192.168.0.1"); hi.setName("example"); hi.setState(HostState.Enabled.toString()); hi.setStatus(HostStatus.Connected.toString()); hi.setClusterUuid(uuid()); hi.setZoneUuid(uuid()); hi.setUuid(uuid()); hi.setTotalCpuCapacity(4L); hi.setTotalMemoryCapacity(4L); hi.setHypervisorType("KVM"); hi.setDescription("example"); event.setInventory(hi); return event; }
public static APIAddHostEvent __example__() { APIAddHostEvent event = new APIAddHostEvent(); HostInventory hi = new HostInventory (); hi.setAvailableCpuCapacity(2L); hi.setAvailableMemoryCapacity(4L); hi.setClusterUuid(uuid()); hi.setManagementIp("192.168.0.1"); hi.setName("example"); hi.setState(HostState.Enabled.toString()); hi.setStatus(HostStatus.Connected.toString()); hi.setClusterUuid(uuid()); hi.setZoneUuid(uuid()); hi.setUuid(uuid()); hi.setTotalCpuCapacity(4L); hi.setTotalMemoryCapacity(4L); hi.setHypervisorType("KVM"); hi.setDescription("example"); event.setInventory(hi); return event; }
protected HostInventory(HostVO vo) { this.setStatus(vo.getStatus().toString()); this.setCreateDate(vo.getCreateDate()); this.setDescription(vo.getDescription()); this.setHypervisorType(vo.getHypervisorType()); this.setLastOpDate(vo.getLastOpDate()); this.setManagementIp(vo.getManagementIp()); this.setName(vo.getName()); this.setState(vo.getState().toString()); this.setUuid(vo.getUuid()); this.setZoneUuid(vo.getZoneUuid()); this.setClusterUuid(vo.getClusterUuid()); if (vo.getCapacity() != null) { this.setTotalCpuCapacity(vo.getCapacity().getTotalCpu()); this.setAvailableCpuCapacity(vo.getCapacity().getAvailableCpu()); this.setTotalMemoryCapacity(vo.getCapacity().getTotalMemory()); this.setAvailableMemoryCapacity(vo.getCapacity().getAvailableMemory()); this.setCpuSockets(vo.getCapacity().getCpuSockets()); this.setCpuNum(vo.getCapacity().getCpuNum()); } }