@Transactional public void cleanTaskProgress(String apiId) { if (apiId == null) { return; } Query query = dbf.getEntityManager().createNativeQuery("select unix_timestamp()"); Long current = ((BigInteger) query.getSingleResult()).longValue() * 1000; SQL.New(TaskProgressVO.class).eq(TaskProgressVO_.apiId, apiId).set(TaskProgressVO_.timeToDelete, current + TimeUnit.SECONDS.toMillis(DELETE_DELAY)).update(); }
@Override public void cleanupVip(String uuid) { SQL.New(VirtualRouterVipVO.class).eq(VirtualRouterVipVO_.uuid, uuid).delete(); } }
@Override public List<String> getBackupStorageSupportedPS(String psUuid) { return SQL.New("select b.uuid from CephPrimaryStorageVO c, PrimaryStorageVO p, CephBackupStorageVO b, BackupStorageZoneRefVO ref where " + "p.uuid = :puuid and c.uuid = p.uuid and b.fsid = c.fsid and b.uuid = ref.backupStorageUuid and ref.zoneUuid = p.zoneUuid"). param("puuid", psUuid).list(); }
@Transactional(readOnly = true) private long getUsedVxlan(String accountUuid) { long cnt = SQL.New("select count(vxlan) from L2NetworkVO vxlan, AccountResourceRefVO ref where vxlan.uuid = ref.resourceUuid and " + "ref.accountUuid = :auuid and vxlan.type = :rtype", Long.class).param("auuid", accountUuid).param("rtype", VxlanNetworkConstant.VXLAN_NETWORK_TYPE).find(); return cnt; }
@Transactional(readOnly = true) private PrimaryStorageInventory findSMPByHostUuid(String clusterUuid) { List<PrimaryStorageVO> ret = SQL.New("select pri from PrimaryStorageVO pri, PrimaryStorageClusterRefVO ref" + " where pri.uuid = ref.primaryStorageUuid" + " and ref.clusterUuid = :cuuid" + " and pri.type = :ptype", PrimaryStorageVO.class) .param("cuuid", clusterUuid) .param("ptype", SMPConstants.SMP_TYPE) .limit(1) .list(); return ret.isEmpty() ? null : PrimaryStorageInventory.valueOf(ret.get(0)); }
protected void cancel() { assert uuid != null; assert canceller != null; logger.debug(String.format("[GC] a job[name:%s, id:%s] is cancelled by itself", NAME, uuid)); canceller.run(); SQL.New(GarbageCollectorVO.class) .eq(GarbageCollectorVO_.uuid, uuid) .set(GarbageCollectorVO_.status, GCStatus.Done).update(); gcMgr.deregisterGC(this); }
@Override public void afterRemoveDhcpServerIP(String L3NetworkUuid, String dhcpSererIp) { SQL.New(L3NetworkHostRouteVO.class).eq(L3NetworkHostRouteVO_.l3NetworkUuid, L3NetworkUuid) .eq(L3NetworkHostRouteVO_.prefix, NetworkServiceConstants.METADATA_HOST_PREFIX).delete(); }
private List<String> getLocalStorageInCluster(String clusterUuid) { return SQL.New("select pri.uuid" + " from PrimaryStorageVO pri, PrimaryStorageClusterRefVO ref" + " where pri.uuid = ref.primaryStorageUuid" + " and ref.clusterUuid = :cuuid" + " and pri.type = :ptype", String.class) .param("cuuid", clusterUuid) .param("ptype", LocalStorageConstants.LOCAL_STORAGE_TYPE) .list(); }
@Override @RetryCondition(times = 6) protected Void call() { SQL.New(UsedIpVO.class).eq(UsedIpVO_.uuid, msg.getUsedIpUuid()).hardDelete(); return null; } }.run();
@Override protected void success() { assert uuid != null; unlock(); logger.debug(String.format("[GC] a job[name:%s, id:%s] completes successfully", NAME, uuid)); SQL.New(GarbageCollectorVO.class) .eq(GarbageCollectorVO_.uuid, uuid) .set(GarbageCollectorVO_.status, GCStatus.Idle).update(); super.setupTimer(); } }
private void cleanUpImageCache(String psUuid) { PrimaryStorageVO ps = dbf.findByUuid(psUuid, PrimaryStorageVO.class); logger.info(String.format("cleanup image cache on PrimaryStorage [%s]", ps.getUuid())); List<String> hostUuids = SQL.New("select h.uuid from LocalStorageHostRefVO ref, HostVO h " + "where ref.hostUuid = h.uuid and ref.primaryStorageUuid = :ps and h.status = :status"). param("ps", psUuid).param("status", HostStatus.Connected).list(); List<BackupStoragePrimaryStorageExtensionPoint> extenstions = pluginRgty.getExtensionList(BackupStoragePrimaryStorageExtensionPoint.class); extenstions.forEach(ext -> { hostUuids.forEach(hostUuid -> ext.cleanupPrimaryCacheForBS(PrimaryStorageInventory.valueOf(ps), hostUuid, new NopeCompletion())); }); }
@Override protected void scripts() { if(Q.New(CephPrimaryStorageVO.class).eq(CephPrimaryStorageVO_.fsid, fsid).find() == null){ SQL.New(CephCapacityVO.class).eq(CephCapacityVO_.fsid, fsid).delete(); } } }.execute();
@VmAttachVolumeValidatorMethod static void vmAttachVolumeValidator(String vmUuid, String volumeUuid) { PrimaryStorageState state = SQL.New("select pri.state from PrimaryStorageVO pri " + "where pri.uuid = (select vol.primaryStorageUuid from VolumeVO vol where vol.uuid = :volUuid)", PrimaryStorageState.class) .param("volUuid", volumeUuid) .find(); if(state == PrimaryStorageState.Maintenance){ throw new OperationFailureException( operr("cannot attach volume[uuid:%s] whose primary storage is Maintenance", volumeUuid)); } } }
@Override public void handle(Map data) { casf.asyncCascadeFull(CascadeConstant.DELETION_CLEANUP_CODE, issuer, ctx, new NopeCompletion()); SQL.New(SharedResourceVO.class).eq(SharedResourceVO_.resourceUuid, msg.getL2NetworkUuid()).delete(); bus.publish(evt); } }).error(new FlowErrorHandler(msg) {
private void handle(APIDeleteRoleMsg msg) { SQL.New(RoleVO.class).eq(RoleVO_.uuid, msg.getUuid()).hardDelete(); bus.publish(new APIDeleteRoleEvent(msg.getId())); } }
@Override public void before() { Tuple tuple = SQL.New("select nic.ip, nic.vmInstanceUuid, nic.uuid, eip.vipIp from VmNicVO nic, EipVO eip" + " where eip.vmNicUuid = nic.uuid and eip.uuid = :uuid", Tuple.class) .param("uuid", getEipUuid()).find(); ip = tuple.get(0, String.class); vmUuid = tuple.get(1, String.class); vmNicUuid = tuple.get(2, String.class); eip = tuple.get(3, String.class); }
private void handle(APIDetachRoleFromAccountMsg msg) { SQL.New(RoleAccountRefVO.class).eq(RoleAccountRefVO_.accountUuid, msg.getAccountUuid()) .eq(RoleAccountRefVO_.roleUuid, msg.getRoleUuid()).hardDelete(); APIDetachRoleFromAccountEvent evt = new APIDetachRoleFromAccountEvent(msg.getId()); bus.publish(evt); }
@Override protected void scripts() { List<String> huuids = Q.New(HostVO.class).select(HostVO_.uuid) .eq(HostVO_.clusterUuid, clusterUuid) .listValues(); SQL.New(PrimaryStorageHostRefVO.class) .eq(PrimaryStorageHostRefVO_.primaryStorageUuid, inventory.getUuid()) .in(PrimaryStorageHostRefVO_.hostUuid, huuids) .hardDelete(); } }.execute();
private void handle(APIDetachPolicyFromRoleMsg msg) { SQL.New(RolePolicyRefVO.class).eq(RolePolicyRefVO_.policyUuid, msg.getPolicyUuid()) .eq(RolePolicyRefVO_.roleUuid, msg.getRoleUuid()).hardDelete(); bus.publish(new APIDetachPolicyFromRoleEvent(msg.getId())); }
private void handle(APIUpdateNotificationsStatusMsg msg) { APIUpdateNotificationsStatusEvent evt = new APIUpdateNotificationsStatusEvent(msg.getId()); SQL.New(NotificationVO.class).set(NotificationVO_.status, NotificationStatus.valueOf(msg.getStatus())) .in(NotificationVO_.uuid, msg.getUuids()).update(); bus.publish(evt); }