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 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); }
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 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); } }
@Override public Host addHost(PartitionServerAddress address, List<String> flags) throws IOException { try { // throws an exception if we can't parse the address PartitionServerAddress.parse(address.toString()); Host host = getHostByAddress(address); if(host != null){ throw new IllegalArgumentException("Host "+address+" already exists in ring "+getRingNumber()+"!"); } return ZkHost.create(zk, coordinator, ZkPath.append(ringPath, HOSTS_PATH_SEGMENT), address, dataLocationChangeListener, flags); } catch (Exception e) { throw new IOException(e); } }