@Override public int compareTo(RingGroup other) { return name.compareTo(other.getName()); }
public synchronized SmartClient.Iface getSmartClient(RingGroup ringGroup) throws IOException, TException { Iface client = cachedClients.get(ringGroup.getName()); if (client == null) { client = new HankSmartClient(coordinator, ringGroup.getName()); cachedClients.put(ringGroup.getName(), client); } return client; } }
@Override public List<Notifier> getRingGroupNotifiers(RingGroup ringGroup) throws InvalidConfigurationException { List<Notifier> notifiers = ringGroupToNotifiers.get(ringGroup); if (notifiers == null) { List<String> notifierConfigurationNames; notifierConfigurationNames = getRequiredStringList(MONITOR_SECTION_KEY, RING_GROUP_NOTIFIERS_CONFIGURATIONS_SECTION_KEY, ringGroup.getName()); notifiers = createNotifiers(notifierConfigurationNames, ringGroup.getName()); ringGroupToNotifiers.put(ringGroup, notifiers); } return notifiers; }
public static String formatHostListTooltip(RingGroup ringGroup, Set<Host> hosts) throws IOException { return formatHostListTooltip(ringGroup.getName(), hosts); }
private void addRingGroupDataToResponse(Map<String, Object> requestData, Map<String, Object> responseData) throws IOException { RingGroup ringGroup = coordinator.getRingGroup((String) requestData.get(Params.RING_GROUP)); if (ringGroup != null) { responseData.put(ringGroup.getName(), apiHelper.getRingGroupData(ringGroup).asMap()); } }
@Override protected String formatCore(NotificationFormatter formatter) { return "Ring Group Conductor mode for " + formatter.getWebUiLink(RingGroupController.getRingGroupUrl(ringGroup), ringGroup.getName()) + " is " + mode; }
protected void doDeleteHost(HttpServletRequest req, HttpServletResponse resp) throws IOException { RingGroup ringGroup = coordinator.getRingGroup(req.getParameter("g")); Ring ring = ringGroup.getRing(Integer.parseInt(req.getParameter("n"))); ring.removeHost(PartitionServerAddress.parse(URLEnc.decode(req.getParameter("h")))); resp.sendRedirect(String.format("/ring.jsp?g=%s&n=%d", ringGroup.getName(), ring.getRingNumber())); }
private void addAllRingGroupsDataToResponse(Map<String, Object> requestData, Map<String, Object> responseData) throws IOException { for (RingGroup ringGroup : coordinator.getRingGroups()) { responseData.put(ringGroup.getName(), apiHelper.getRingGroupData(ringGroup).asMap()); } }
@Override public String toString() { return String.format("AbstractRing [ringGroup=%s, ring=%d]", (getRingGroup() != null ? getRingGroup().getName() : "null"), this.getRingNumber()); }
protected DomainGroupDeployStatus getDomainGroupDeployStatus(DomainGroup domainGroup) throws IOException { DomainGroupDeployStatus status = new DomainGroupDeployStatus(); status.domainGroupName = domainGroup.getName(); Map<String, DomainGroupDeployStatusForRingGroup> ringGroupsMap = new HashMap<String, DomainGroupDeployStatusForRingGroup>(); Set<RingGroup> ringGroups = coordinator.getRingGroupsForDomainGroup(domainGroup); for (RingGroup ringGroup : ringGroups) { ringGroupsMap.put(ringGroup.getName(), getDomainGroupDeployStatusForRingGroup(ringGroup)); } status.ringGroupsMap = ringGroupsMap; return status; }
private void redirectBack(HttpServletResponse resp, RingGroup rgc, Ring rc, Host hc) throws IOException { resp.sendRedirect(String.format("/host.jsp?g=%s&r=%s&h=%s", rgc.getName(), rc.getRingNumber(), URLEnc.encode(hc.getAddress().toString()))); }
@Override protected String formatCore(NotificationFormatter formatter) { try { return "Domain Group for " + formatter.getWebUiLink(RingGroupController.getRingGroupUrl(ringGroup), ringGroup.getName()) + " is now:" + UiUtils.formatDomainGroupDomainVersionsTable(ringGroup.getDomainGroup(), "", false); } catch (IOException e) { throw new RuntimeException(e); } }
public static String formatHostListTooltip(Ring ring, Set<Host> hosts) throws IOException { return formatHostListTooltip(ring.getRingGroup().getName() + " ring " + ring.getRingNumber(), hosts); }
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; }
private void doUpdate(HttpServletRequest req, HttpServletResponse resp) throws IOException { RingGroup rg = coordinator.getRingGroup(req.getParameter("g")); Ring r = rg.getRing(Integer.parseInt(req.getParameter("n"))); Host h = r.getHostByAddress(PartitionServerAddress.parse(URLEnc.decode(req.getParameter("h")))); h.setFlags(Hosts.splitHostFlags(req.getParameter("hostFlags"))); PartitionServerAddress address = PartitionServerAddress.parse(req.getParameter("hostAddress")); if (!h.getAddress().equals(address)) { h.setAddress(address); // Redirect to Ring (host address has changed) resp.sendRedirect("/ring.jsp?g=" + rg.getName() + "&n=" + r.getRingNumber()); } else { redirectBack(resp, rg, r, h); } }
public static String getHostUrl(RingGroup ringGroup, Ring ring, Host host) { return "host.jsp?g=" + URLEnc.encode(ringGroup.getName()) + "&r=" + ring.getRingNumber() + "&h=" + URLEnc.encode(host.getAddress().toString()); } }
protected DomainGroupDeployStatusForRingGroup getDomainGroupDeployStatusForRingGroup(RingGroup ringGroup) throws IOException { DomainGroupDeployStatusForRingGroup status = new DomainGroupDeployStatusForRingGroup(); status.ringGroupName = ringGroup.getName(); ServingStatus servingStatus = RingGroups.computeServingStatusAggregator(ringGroup, ringGroup.getDomainGroup()).computeServingStatus(); status.numPartitions = servingStatus.getNumPartitions(); status.numPartitionsServedAndUpToDate = servingStatus.getNumPartitionsServedAndUpToDate(); return status; }
private DomainDeployStatusForRingGroup getDomainDeployStatusForRingGroup(DomainGroup domainGroup, Domain domain, RingGroup ringGroup) throws IOException { DomainDeployStatusForRingGroup status = new DomainDeployStatusForRingGroup(); status.ringGroupName = ringGroup.getName(); if (domainGroup != null) { status.targetDomainVersion = domainGroup.getDomainVersion(domain) == null ? null : domainGroup.getDomainVersion(domain).getVersionNumber(); } ServingStatus servingStatus = RingGroups.computeServingStatusAggregator(ringGroup, domainGroup).computeServingStatus(); status.numPartitions = servingStatus.getNumPartitions(); status.numPartitionsServedAndUpToDate = servingStatus.getNumPartitionsServedAndUpToDate(); return status; }
@Test public void testAddRingGroup() throws Exception { DomainGroup dg = coord.addDomainGroup("myDomainGroup2"); Map<Domain, Integer> domainIdToVersion = new HashMap<>(); dg.setDomainVersions(domainIdToVersion); RingGroup rg = coord.addRingGroup("superDuperRingGroup", "myDomainGroup2"); assertEquals("superDuperRingGroup", rg.getName()); assertEquals(0, rg.getRings().size()); }
@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()); }