@Override public Ring getRingForHost(PartitionServerAddress hostAddress) { for (Ring ring : rings.values()) { if (ring.getHostByAddress(hostAddress) != null) { return ring; } } return null; }
protected void doDiscardCurrentCommand(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.nextCommand(); redirectBack(resp, rg, r, h); }
protected void doClearCommandQueue(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.clearCommandQueue(); redirectBack(resp, rg, r, h); }
protected void doEnqueueCommand(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.enqueueCommand(HostCommand.valueOf(req.getParameter("command"))); redirectBack(resp, rg, r, h); }
private void doDeleteOrUndeletePartition(HttpServletRequest req, HttpServletResponse resp, boolean deletable) 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")))); HostDomain hd = h.getHostDomain(coordinator.getDomain(req.getParameter("d"))); HostDomainPartition hdp = hd.getPartitionByNumber(Integer.parseInt(req.getParameter("p"))); hdp.setDeletable(deletable); redirectBack(resp, rg, r, h); }
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); } }
LOG.info("Found ring for host: "+ring); host = ring.getHostByAddress(hostAddress);
host = ring.getHostByAddress(address); if (host == null) { throw new IOException(String.format("Could not get Host at address %s of Ring %s", address, ring));
dataLocationChangeListener.clear(); rg.getRing(1).getHostByAddress(address).setState(HostState.SERVING); WaitUntil.orDie(() -> dataLocationChangeListener.isCalled); assertTrue(dataLocationChangeListener.isCalled());