public void cleanFailedSnapshot(String snapshotId) { EntityWrapper<SnapshotInfo> db = StorageProperties.getEntityWrapper(); SnapshotInfo snapshotInfo = new SnapshotInfo(snapshotId); List<SnapshotInfo> snapshotInfos = db.query(snapshotInfo); if (snapshotInfos.size() > 0) { SnapshotInfo snapInfo = snapshotInfos.get(0); cleanSnapshot(snapInfo); db.delete(snapInfo); } db.commit(); }
public void cleanFailedSnapshots() { EntityWrapper<SnapshotInfo> db = StorageProperties.getEntityWrapper(); SnapshotInfo snapshotInfo = new SnapshotInfo(); snapshotInfo.setStatus(StorageProperties.Status.failed.toString()); List<SnapshotInfo> snapshotInfos = db.query(snapshotInfo); for (SnapshotInfo snapInfo : snapshotInfos) { cleanSnapshot(snapInfo); db.delete(snapInfo); } db.commit(); }
public void cleanStuckSnapshots() { EntityWrapper<SnapshotInfo> db = StorageProperties.getEntityWrapper(); SnapshotInfo snapshotInfo = new SnapshotInfo(); snapshotInfo.setStatus(StorageProperties.Status.creating.toString()); List<SnapshotInfo> snapshotInfos = db.query(snapshotInfo); for (SnapshotInfo snapInfo : snapshotInfos) { // Mark them as failed so that it gets reflected in the CLC and the clean up routine picks // them up later snapInfo.setStatus(StorageProperties.Status.failed.toString()); } db.commit(); }
public void cleanFailedVolumes() { EntityWrapper<VolumeInfo> db = StorageProperties.getEntityWrapper(); VolumeInfo volumeInfo = new VolumeInfo(); volumeInfo.setStatus(StorageProperties.Status.failed.toString()); List<VolumeInfo> volumeInfos = db.query(volumeInfo); for (VolumeInfo volInfo : volumeInfos) { String volumeId = volInfo.getVolumeId(); LOG.info("Cleaning failed volume " + volumeId); blockManager.cleanVolume(volumeId); } db.commit(); }
public void cleanFailedVolume(String volumeId) { EntityWrapper<VolumeInfo> db = StorageProperties.getEntityWrapper(); VolumeInfo volumeInfo = new VolumeInfo(volumeId); List<VolumeInfo> volumeInfos = db.query(volumeInfo); if (volumeInfos.size() > 0) { VolumeInfo volInfo = volumeInfos.get(0); LOG.info("Cleaning failed volume " + volumeId); blockManager.cleanVolume(volumeId); // We don't remove deleted volumes, but failed are okay to delete. db.delete(volInfo); } db.commit(); }
private static void addAddress(final Address address) { Address addr = address; EntityWrapper<Address> db = EntityWrapper.get(Address.class); try { addr = db.getUnique( new Address() { { this.setDisplayName(address.getName()); } }); addr.setOwner(address.getOwner()); db.commit(); } catch (RuntimeException e) { db.rollback(); LOG.error(e, e); } catch (EucalyptusCloudException e) { try { db.add(address); db.commit(); } catch (Exception e1) { db.rollback(); } } }
private static void removeAddress(final String ipAddress) { try { Addresses.getInstance().disable(ipAddress); } catch (NoSuchElementException e1) { LOG.debug(e1); } EntityWrapper<Address> db = EntityWrapper.get(Address.class); try { Address searchAddr = new Address(ipAddress); searchAddr.setOwner(null); Address dbAddr = db.getUnique(searchAddr); db.delete(dbAddr); db.commit(); } catch (Exception e) { Logs.extreme().error(e, e); db.rollback(); } }
public static <T> EntityWrapper<T> getEntityWrapper() { return (EntityWrapper<T>) EntityWrapper.get(VolumeInfo.class); }