public void checkAddressDuplicate(QuorumServer s) throws BadArgumentsException { List<InetSocketAddress> otherAddrs = new ArrayList<InetSocketAddress>(); otherAddrs.add(s.addr); otherAddrs.add(s.clientAddr); otherAddrs.add(s.electionAddr); otherAddrs = excludedSpecialAddresses(otherAddrs); for (InetSocketAddress my: this.myAddrs) { for (InetSocketAddress other: otherAddrs) { if (my.equals(other)) { String error = String.format("%s of server.%d conflicts %s of server.%d", my, this.id, other, s.id); throw new BadArgumentsException(error); } } } }
private void validateCreateRequest(String path, CreateMode createMode, Request request, long ttl) throws KeeperException { try { EphemeralType.validateTTL(createMode, ttl); } catch (IllegalArgumentException e) { throw new BadArgumentsException(path); } if (createMode.isEphemeral()) { // Exception is set when local session failed to upgrade // so we just need to report the error if (request.getException() != null) { throw request.getException(); } zks.sessionTracker.checkGlobalSession(request.sessionId, request.getOwner()); } else { zks.sessionTracker.checkSession(request.sessionId, request.getOwner()); } }
private void validatePath(String path, long sessionId) throws BadArgumentsException { try { PathUtils.validatePath(path); } catch(IllegalArgumentException ie) { LOG.info("Invalid path " + path + " with session 0x" + Long.toHexString(sessionId) + ", reason: " + ie.getMessage()); throw new BadArgumentsException(path); } }
/** * Performs basic validation of a path for a create request. * Throws if the path is not valid and returns the parent path. * @throws BadArgumentsException */ private String validatePathForCreate(String path, long sessionId) throws BadArgumentsException { int lastSlash = path.lastIndexOf('/'); if (lastSlash == -1 || path.indexOf('\0') != -1 || failCreate) { LOG.info("Invalid path %s with session 0x%s", path, Long.toHexString(sessionId)); throw new KeeperException.BadArgumentsException(path); } return path.substring(0, lastSlash); }
private void validatePath(String path, long sessionId) throws BadArgumentsException { try { PathUtils.validatePath(path); } catch(IllegalArgumentException ie) { LOG.info("Invalid path {} with session 0x{}, reason: {}", path, Long.toHexString(sessionId), ie.getMessage()); throw new BadArgumentsException(path); } }
private String getParentPathAndValidate(String path) throws BadArgumentsException { int lastSlash = path.lastIndexOf('/'); if (lastSlash == -1 || path.indexOf('\0') != -1 || zks.getZKDatabase().isSpecialPath(path)) { throw new BadArgumentsException(path); } return path.substring(0, lastSlash); }