@Override protected void action(HttpServletRequest req, HttpServletResponse resp) throws IOException { Domain domain = DomainController.this.coordinator.getDomain(req.getParameter("n")); final DomainVersion domainVersion = domain.getVersion(Integer.parseInt(req.getParameter("ver"))); domainVersion.setDefunct(false); redirect("/domain.jsp?n=" + req.getParameter("n"), resp); } });
@Override protected void action(HttpServletRequest req, HttpServletResponse resp) throws IOException { Domain domain = DomainController.this.coordinator.getDomain(req.getParameter("n")); final DomainVersion domainVersion = domain.getVersion(Integer.parseInt(req.getParameter("ver"))); domainVersion.setDefunct(true); redirect("/domain.jsp?n=" + req.getParameter("n"), resp); } });
public static void main(String[] args) throws IOException, InvalidConfigurationException { CommandLineChecker.check(args, new String[]{"configuration", "domain name", "domain version number"}, RemoteDomainVersionDeletionHelper.class ); String configurationPath = args[0]; String domainName = args[1]; Integer versionNumber = Integer.parseInt(args[2]); Coordinator coordinator = new YamlCoordinatorConfigurator(configurationPath).createCoordinator(); Domain domain = coordinator.getDomain(domainName); if (domain == null) { throw new RuntimeException("Given domain was not found: " + domainName); } DomainVersion domainVersion = domain.getVersion(versionNumber); if (domainVersion == null) { throw new RuntimeException("Given version was not found: " + domainName + " version " + versionNumber); } LOG.info("Deleting remote data for domain " + domainName + " version " + versionNumber); domainVersion.setDefunct(true); domain.getStorageEngine().getRemoteDomainVersionDeleter(StorageEngine.RemoteLocation.DOMAIN_BUILDER).deleteVersion(versionNumber); } }
version.setDefunct(true);
@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()); }