protected void doDeleteRing(HttpServletRequest req, HttpServletResponse resp) throws IOException { RingGroup ringGroup; String encodedRingGroupName = req.getParameter("g"); ringGroup = coordinator.getRingGroup(URLEnc.decode(encodedRingGroupName)); if (ringGroup == null) { throw new IOException("couldn't find any ring group called " + URLEnc.decode(encodedRingGroupName)); } ringGroup.removeRing(Integer.parseInt(req.getParameter("n"))); resp.sendRedirect("/ring_group.jsp?name=" + encodedRingGroupName); }
private void doAddHost(HttpServletRequest req, HttpServletResponse resp) throws IOException { String rgName = req.getParameter("rgName"); int ringNum = Integer.parseInt(req.getParameter("ringNum")); String hostname = req.getParameter("hostname").trim(); int portNum = Integer.parseInt(req.getParameter("port")); String flagsStr = req.getParameter("hostFlags"); coordinator.getRingGroup(rgName).getRing(ringNum).addHost( new PartitionServerAddress(hostname, portNum), Hosts.splitHostFlags(flagsStr)); resp.sendRedirect("/ring.jsp?g=" + rgName + "&n=" + ringNum); }
private void doCommandAll(HttpServletRequest req, HttpServletResponse resp) throws IOException { String rgName = req.getParameter("rgName"); int ringNum = Integer.parseInt(req.getParameter("ringNum")); HostCommand command = HostCommand.valueOf(req.getParameter("command")); Rings.commandAll(coordinator.getRingGroup(rgName).getRing(ringNum), command); resp.sendRedirect("/ring.jsp?g=" + rgName + "&n=" + ringNum); } }
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()); } }
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())); }
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); }
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); }
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 doSetRingGroupConductorMode(HttpServletRequest req, HttpServletResponse resp) throws IOException { String encodedRingGroupName = req.getParameter("g"); RingGroup ringGroup = coordinator.getRingGroup(URLEnc.decode(encodedRingGroupName)); // Only change the mode if it's not OFFLINE if (ringGroup.getRingGroupConductorMode() != null && ringGroup.getRingGroupConductorMode() != RingGroupConductorMode.OFFLINE) { ringGroup.setRingGroupConductorMode(RingGroupConductorMode.valueOf(URLEnc.decode(req.getParameter("mode")))); } resp.sendRedirect("/ring_group.jsp?name=" + encodedRingGroupName); }
public PartitionServer(PartitionServerConfigurator configurator, String hostName) throws IOException { this.configurator = configurator; this.coordinator = configurator.createCoordinator(); this.commandQueue = new LinkedBlockingQueue<HostCommand>(); hostAddress = new PartitionServerAddress(hostName, configurator.getServicePort()); ringGroup = coordinator.getRingGroup(configurator.getRingGroupName()); if (ringGroup == null) { throw new RuntimeException("Could not get ring group: " + configurator.getRingGroupName()); } this.hostName = hostName; }
private void doAddRing(HttpServletRequest req, HttpServletResponse resp) throws IOException { RingGroup ringGroup; String encodedRingGroupName = req.getParameter("g"); ringGroup = coordinator.getRingGroup(URLEnc.decode(encodedRingGroupName)); if (ringGroup == null) { throw new IOException("couldn't find any ring group called " + URLEnc.decode(encodedRingGroupName)); } // Find new ring ID (largest ID + 1) int newRingID = 0; for (Ring ring : ringGroup.getRings()) { if (ring.getRingNumber() >= newRingID) { newRingID = ring.getRingNumber() + 1; } } ringGroup.addRing(newRingID); resp.sendRedirect("/ring_group.jsp?name=" + encodedRingGroupName); }
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("Ring Group Conductor for ring group " + ringGroupName + " starting."); try { ringGroup = coordinator.getRingGroup(ringGroupName);
HankSmartClientOptions options) throws IOException { this.coordinator = coordinator; ringGroup = coordinator.getRingGroup(ringGroupName);
Ring ring = coordinator.getRingGroup(configurator.getRingGroupName()).getRingForHost(address); if (ring == null) { throw new IOException(String.format("Could not get Ring of PartitionServerAddress %s", address));