private String getTargetDirectory(DiskPartitionAssignment assignment, int partitionNumber) { return assignment.getDisk(partitionNumber) + "/" + domain.getName() + "/" + partitionNumber; }
@Override public int compareTo(Domain other) { return getName().compareTo(other.getName()); }
public String getName() { return hostDomain.getDomain().getName(); }
private String getTargetDirectory(DiskPartitionAssignment assignment, int partitionNumber) { return assignment.getDisk(partitionNumber) + "/" + domain.getName() + "/" + partitionNumber; }
public static void cleanDomains(Collection <Domain> domains, boolean deleteMetadata, StorageEngine.RemoteLocation dataLocation) throws IOException { for (Domain domain : domains) { StorageEngine storageEngine = domain.getStorageEngine(); RemoteDomainCleaner cleaner = storageEngine.getRemoteDomainCleaner(); if (cleaner == null) { LOG.info("Failed to clean Domain " + domain.getName() + ". No Remote Domain Cleaner is configured."); continue; } RemoteDomainVersionDeleter deleter = storageEngine.getRemoteDomainVersionDeleter(dataLocation); if (deleter == null) { LOG.info("Failed to clean Domain " + domain.getName() + ". No Remote Domain Version Deleter is configured."); continue; } LOG.info("Cleaning Domain " + domain.getName()); cleaner.deleteOldVersions(deleter, deleteMetadata); } }
@Override public String toString() { return String.format("AbstractHostDomain [domainName=%s]", getDomain() != null ? getDomain().getName() : "?"); } }
private void doDeleteDomain(HttpServletRequest req, HttpServletResponse resp) throws IOException { String domainName = req.getParameter("name"); final Domain domain = coordinator.getDomain(domainName); if (!isInUse(domain)) { coordinator.deleteDomain(domain.getName()); } resp.sendRedirect("/domains.jsp"); }
DomainAccessor(HostDomain hostDomain, PartitionAccessor[] partitionAccessors, Partitioner partitioner, int getTimerAggregatorWindow) throws IOException { this.hostDomain = hostDomain; this.partitionAccessors = partitionAccessors; this.partitioner = partitioner; this.getRequestsTimerAggregator = new HankTimerEventAggregator("GET " + hostDomain.getDomain().getName(), getTimerAggregatorWindow); }
private void addDomainDeployStatusToResponse(Map<String, Object> requestData, Map<String, Object> responseData) throws IOException { Domain domain = coordinator.getDomain((String) requestData.get(Params.DEPLOY_STATUS_FOR_DOMAIN)); if (domain != null) { responseData.put(domain.getName(), apiHelper.getDomainDeployStatus(domain).asMap()); } }
@Override public String toString() { return getDomain().getName() + "@v" + getVersionNumber(); }
protected void doUpdateDomainVersions(HttpServletRequest req, HttpServletResponse resp) throws IOException { String dgName = URLEnc.decode(req.getParameter("name")); DomainGroup dg = coordinator.getDomainGroup(dgName); Map<Domain, Integer> domainVersions = new HashMap<Domain, Integer>(); for (Domain domain : coordinator.getDomains()) { String version = req.getParameter(domain.getName() + "_version"); if (version == null) { continue; } domainVersions.put(domain, Integer.parseInt(version)); } dg.setDomainVersions(domainVersions); resp.sendRedirect("/domain_group.jsp?n=" + dgName); } }
protected DomainGroupData getDomainGroupData(DomainGroup domainGroup) throws IOException { DomainGroupData data = new DomainGroupData(); data.name = domainGroup.getName(); Map<String, Integer> versionsMap = new HashMap<String, Integer>(); for (DomainAndVersion v : domainGroup.getDomainVersions()) { versionsMap.put(v.getDomain().getName(), v.getVersionNumber()); } data.domainVersions = versionsMap; return data; }
protected DomainDeployStatus getDomainDeployStatus(Domain domain) throws IOException { DomainDeployStatus status = new DomainDeployStatus(); status.domainName = domain.getName(); Map<String, DomainDeployStatusForRingGroup> ringGroupsMap = new HashMap<String, DomainDeployStatusForRingGroup>(); for (RingGroup ringGroup : coordinator.getRingGroups()) { DomainGroup domainGroup = ringGroup.getDomainGroup(); if (domainGroup != null && domainGroup.getDomainVersion(domain) != null) { ringGroupsMap.put(ringGroup.getName(), getDomainDeployStatusForRingGroup(domainGroup, domain, ringGroup)); } } status.ringGroupsMap = ringGroupsMap; return status; }
protected DomainData getDomainData(Domain domain) throws IOException { DomainData data = new DomainData(); data.name = domain.getName(); data.numPartitions = domain.getNumParts(); data.storageEngine = domain.getStorageEngineFactoryClassName(); data.storageEngineOptions = domain.getStorageEngineOptions(); Map<Integer, DomainVersionData> versionsMap = new HashMap<Integer, DomainVersionData>(); for (DomainVersion v : domain.getVersions()) { versionsMap.put(v.getVersionNumber(), getDomainVersionData(v)); } data.versionsMap = versionsMap; return data; }
public HankResponse get(ByteBuffer key, ReaderResult result) throws IOException { HankTimer timer = getRequestsTimerAggregator.getTimer(); try { int partition = partitioner.partition(key, partitionAccessors.length); PartitionAccessor partitionAccessor = partitionAccessors[partition]; if (partitionAccessor == null) { LOG.error("Failed to perform get because of an Exception: wrong host for domain: " + hostDomain.getDomain().getName() + ", partition: " + partition + ", key: " + BytesUtils.bytesToHexString(key) + ", response: " + WRONG_HOST); return WRONG_HOST; } return partitionAccessor.get(key, result); } finally { getRequestsTimerAggregator.add(timer); } }
@Override public DomainAndVersion getDomainVersion(Domain domain) throws IOException { if (domain == null || domain.getName() == null) { return null; } for (DomainAndVersion domainVersion : getDomainVersions()) { if (domainVersion.getDomain() != null && domain.getId() == domainVersion.getDomain().getId()) { return domainVersion; } } return null; }
private void deletePartition(HostDomain hostDomain, HostDomainPartition partition) throws IOException { LOG.info("Deleting Domain " + hostDomain.getDomain().getName() + " partition " + partition.getPartitionNumber()); Deleter deleter = hostDomain.getDomain().getStorageEngine().getDeleter(assignment, partition.getPartitionNumber()); deleter.delete(); hostDomain.removePartition(partition.getPartitionNumber()); }
protected void addDomainsToRingGroup(Coordinator coordinator, RingGroup ringGroup) throws IOException { // for each configured domain for (RingGroupConfiguredDomain configuredDomain : configuredDomains) { Domain domain = coordinator.getDomain(configuredDomain.getName()); DomainAndVersion version = ringGroup.getDomainGroup().getDomainVersion(domain); if (version == null) { // either there are no versions, which is fine DomainVersion latestClosedVersion = Domains.getLatestVersionNotOpenNotDefunct(domain); if (latestClosedVersion != null) { int versionToAdd = latestClosedVersion.getVersionNumber(); LOG.info("Adding domain " + domain.getName() + " version " + versionToAdd + " to domain group: " + ringGroup.getName()); ringGroup.getDomainGroup().setDomainVersion(domain, versionToAdd); } } } }
@Test public void testLoad() throws Exception { // check standard loading stuff assertEquals("number of loaded domain configs", 1, coord.getDomains().size()); assertEquals("get domain by name", "domain0", coord.getDomain("domain0").getName()); assertEquals("number of loaded domain group configs", 1, coord.getDomainGroups().size()); assertEquals("get domain group by name", "myDomainGroup", coord.getDomainGroup("myDomainGroup").getName()); assertEquals("number of loaded ring groups", 1, coord.getRingGroups().size()); assertEquals("get ring group by name", "myRingGroup", coord.getRingGroup("myRingGroup").getName()); }