public static long getTotalNumBytes(Domain domain) throws IOException { long total = 0; for (DomainVersion version : domain.getVersions()) { if (version.isDefunct()) { continue; } total += DomainVersions.getTotalNumBytes(version); } return total; }
@Override protected void action(HttpServletRequest req, HttpServletResponse resp) throws IOException { Domain domain = DomainController.this.coordinator.getDomain(req.getParameter("n")); for (DomainVersion domainVersion : domain.getVersions()) { if (domainVersion.isDefunct()) { domain.deleteVersion(domainVersion.getVersionNumber()); } } redirect("/domain.jsp?n=" + req.getParameter("n"), resp); } });
while (parentVersion != null) { if (!parentVersion.isDefunct()) {
if (!version.isDefunct()) { LOG.info("Deleting Version " + version.getVersionNumber() + " of Domain " + domain.getName());
@Test public void testDefunct() throws Exception { final DomainVersion dv = ZkDomainVersion.create(getZk(), getRoot(), 1, null, null); final DomainVersion otherDv = new ZkDomainVersion(getZk(), ZkPath.append(getRoot(), "v/1"), null); assertFalse(dv.isDefunct()); assertFalse(otherDv.isDefunct()); dv.setDefunct(true); WaitUntil.orDie(() -> { try { return dv.isDefunct() && otherDv.isDefunct(); } catch (IOException e) { throw new RuntimeException(e); } }); assertTrue(dv.isDefunct()); assertTrue(otherDv.isDefunct()); dv.setDefunct(false); WaitUntil.orDie(() -> { try { return !dv.isDefunct() && !otherDv.isDefunct(); } catch (IOException e) { throw new RuntimeException(e); } }); assertFalse(dv.isDefunct()); assertFalse(otherDv.isDefunct()); }
protected DomainVersionData getDomainVersionData(DomainVersion version) throws IOException { DomainVersionData data = new DomainVersionData(); data.versionNumber = version.getVersionNumber(); data.totalNumBytes = DomainVersions.getTotalNumBytes(version); data.totalNumRecords = DomainVersions.getTotalNumRecords(version); data.isClosed = DomainVersions.isClosed(version); data.closedAt = version.getClosedAt(); data.properties = version.getProperties(); data.isDefunct = version.isDefunct(); return data; }
private static boolean isCompleteToBase(DomainVersion version, Domain domain) throws IOException { if(version == null){ return true; } if (!DomainVersions.isClosed(version)) { return false; } if (isBase(version)) { return !version.isDefunct(); } // TODO is there ever going to be a different impl of props? IncrementalDomainVersionProperties properties = (IncrementalDomainVersionProperties)version.getProperties(); return isCompleteToBase( domain.getVersion(properties.getParentVersionNumber()), domain ); }
@Test public void testCreate() throws Exception { DomainVersion dv = ZkDomainVersion.create(getZk(), getRoot(), 1, null, null); assertEquals(1, dv.getVersionNumber()); assertNull(dv.getClosedAt()); assertFalse(DomainVersions.isClosed(dv)); assertFalse(dv.isDefunct()); }
@Test public void testLoad() throws Exception { ZkDomainVersion.create(getZk(), getRoot(), 1, null, null); DomainVersion dv = new ZkDomainVersion(getZk(), ZkPath.append(getRoot(), "v/" + 1), null); assertEquals(1, dv.getVersionNumber()); assertNull(dv.getClosedAt()); assertFalse(DomainVersions.isClosed(dv)); assertFalse(dv.isDefunct()); }