protected DomainVersion findVersion(Collection<DomainVersion> versions, int versionNumber) throws IOException { for (DomainVersion v : versions) { if (v != null && v.getVersionNumber() == versionNumber) { return v; } } return null; }
public Delta(DomainVersion parentVersion, String source) { super(parentVersion == null ? null : parentVersion.getVersionNumber(), source); } }
@Override public DomainVersion getParentDomainVersion(DomainVersion domainVersion) throws IOException { if (domainVersion.getVersionNumber() == 0) { return null; } else { return domain.getVersion(domainVersion.getVersionNumber() - 1); } }
private int getNextVersionNumber() { if(this.versions.isEmpty()){ return 0; } return this.versions.iterator().next().getVersionNumber() + 1; }
private int getNextVersionNumber() { if(this.versions.isEmpty()){ return 0; } return this.versions.iterator().next().getVersionNumber() + 1; }
public static void fastForwardDomains(DomainGroup domainGroup, Collection<Domain> domains) throws IOException { Map<Domain, Integer> domainVersions = new HashMap<Domain, Integer>(); for (Domain domain : domains) { domainVersions.put(domain, Domains.getLatestVersionNotOpenNotDefunct(domain).getVersionNumber()); } domainGroup.mergeDomainVersions(domainVersions); }
@Override public void run(Coordinator coordinator) throws IOException { Domain domain = getDomain(coordinator, domainName); DomainVersion domainVersion = domain.openNewVersion(domainVersionProperties); if (domainVersion == null) { throw new IOException("Could not open a new version of domain " + domainName); } else { LOG.info("Opened new version #" + domainVersion.getVersionNumber() + " of domain: " + domainName); result = new DomainVersionNumberAndNumPartitions(domainVersion.getVersionNumber(), domain.getNumParts()); } } }
@Override public void run(Coordinator coordinator) throws IOException { DomainVersion domainVersion = getDomainVersion(coordinator, domainName, domainVersionNumber); LOG.info("Closing new version #" + domainVersion.getVersionNumber() + " of domain: " + domainName); domainVersion.close(); } }
@Override public void run(Coordinator coordinator) throws IOException { DomainVersion domainVersion = getDomainVersion(coordinator, domainName, domainVersionNumber); LOG.info("Cancelling new version #" + domainVersion.getVersionNumber() + " of domain: " + domainName); domainVersion.cancel(); } }
public CurlyFilePath getCurlyFilePathForVersion(DomainVersion version, DomainVersion currentVersion, boolean isBase) { if (currentVersion != null && currentVersion.equals(version)) { // If version is current version, data is in root return new CurlyFilePath(localPartitionRoot + "/" + Curly.getName(version.getVersionNumber(), isBase)); } else { // Otherwise, version must be in cache return new CurlyFilePath(localPartitionRootCache + "/" + Curly.getName(version.getVersionNumber(), isBase)); } } }
private void addDomainVersionDataToResponse(Map<String, Object> requestData, Map<String, Object> responseData) throws IOException { Domain domain = coordinator.getDomain((String) requestData.get(Params.DOMAIN)); try { DomainVersion version = domain.getVersion(Integer.valueOf((String) requestData.get(Params.DOMAIN_VERSION))); responseData.put(String.valueOf(version.getVersionNumber()), apiHelper.getDomainVersionData(version).asMap()); } catch (Exception ignored) { } // No data added, but no harm done }
public static boolean isEmptyVersion(PartitionRemoteFileOps partitionRemoteFileOps, DomainVersion domainVersion) throws IOException { return !partitionRemoteFileOps.exists(Cueball.getName(domainVersion.getVersionNumber(), true)) && !partitionRemoteFileOps.exists(Cueball.getName(domainVersion.getVersionNumber(), false)); }
@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); } });
public static boolean isCurrentlyServed(Domain domain, DomainVersion domainVersion, Coordinator coord) throws IOException { for (DomainGroup domainGroup : coord.getDomainGroups()) { DomainAndVersion version = domainGroup.getDomainVersion(domain); if (version != null) { if (version.getVersionNumber() == domainVersion.getVersionNumber()) { return true; } } } return false; }
private Writer getWriter(DomainVersion domainVersion, PartitionRemoteFileOps partitionRemoteFileOps, int partitionNumber, Writer keyFileWriter) throws IOException { IncrementalDomainVersionProperties domainVersionProperties = getDomainVersionProperties(domainVersion); OutputStream outputStream = partitionRemoteFileOps.getOutputStream(getName(domainVersion.getVersionNumber(), domainVersionProperties.isBase())); return new CurlyWriter(outputStream, keyFileWriter, offsetNumBytes, valueFoldingCacheCapacity, blockCompressionCodec, compressedBlockSizeThreshold, offsetInBlockNumBytes); }
@Override public Writer getWriter(DomainVersion domainVersion, PartitionRemoteFileOps partitionRemoteFileOps, int partitionNumber) throws IOException { IncrementalDomainVersionProperties domainVersionProperties = getDomainVersionProperties(domainVersion); return new CueballWriter(partitionRemoteFileOps.getOutputStream(getName(domainVersion.getVersionNumber(), domainVersionProperties.isBase())), keyHashSize, hasher, valueSize, getCompressionCodec(), hashIndexBits ); }
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; }
@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()); }
@Test public void testCancelVersion() throws Exception { DomainVersion dv = ZkDomainVersion.create(getZk(), getRoot(), 1, null, null); assertEquals(1, dv.getVersionNumber()); assertNull(dv.getClosedAt()); assertFalse(DomainVersions.isClosed(dv)); dv.cancel(); assertNull(getZk().exists(ZkPath.append(getRoot(), "v/1"), false)); }