/** * @param message * @param providerUrl */ public ServerNotFoundException(final String message, final String providerUrl) { super(message); try { serverRef = new ServerRef(providerUrl); } catch (MalformedURLException e) { serverRef = null; } catch (UnknownHostException e) { serverRef = null; } }
/** * Sets the load-factor for the server with the given address. * @param serverRef a reference on a server * @param loadFactor the load-factor for the server with the given address * @throws UnsupportedOperationException if the used manager is at client-side * @throws MalformedURLException if the URL is malformed * @throws UnknownHostException if the given host cannot be resolved */ public void setLoadFactor(final String serverRef, final String loadFactor) throws UnsupportedOperationException, MalformedURLException, UnknownHostException { if(!(clusterViewManager instanceof ServerClusterViewManager)) { LOGGER.error("Clients cannot call this method"); throw new UnsupportedOperationException("Clients cannot call this method"); } ((ServerClusterViewManager) clusterViewManager).setLoadFactor(new ServerRef(serverRef), new Integer(loadFactor)); }
/** * Adds a server to the blacklist. * @param serverName a reference on a server * @throws UnsupportedOperationException if the used manager is at client-side * @throws MalformedURLException if the URL is malformed * @throws UnknownHostException if the given host cannot be resolved */ public void addServerToBlackList(final String serverName) throws UnsupportedOperationException, MalformedURLException, UnknownHostException { if(!(clusterViewManager instanceof ServerClusterViewManager)) { LOGGER.error("Clients cannot call this method"); throw new UnsupportedOperationException("Clients cannot call this method"); } ((ServerClusterViewManager) clusterViewManager).addServerToBlackList(new ServerRef(serverName)); }
/** * Removes a server from the blacklist. * @param serverName a reference on a server * @throws UnsupportedOperationException if the used manager is at client-side * @throws MalformedURLException if the URL is malformed * @throws UnknownHostException if the given host cannot be resolved */ public void removeServerFromBlackList(final String serverName) throws UnsupportedOperationException, MalformedURLException, UnknownHostException { if(!(clusterViewManager instanceof ServerClusterViewManager)) { LOGGER.error("Clients cannot call this method"); throw new UnsupportedOperationException("Clients cannot call this method"); } ((ServerClusterViewManager) clusterViewManager).removeServerFromBlackList(new ServerRef(serverName)); }
/** * Returns true the server with the given reference if blacklisted. * @param serverName a reference on a server * @return true the server with the given reference if blacklisted * @throws UnsupportedOperationException if the used manager is at client-side * @throws MalformedURLException if the URL is malformed * @throws UnknownHostException if the given host cannot be resolved */ public boolean isServerBlackListed(final String serverName) throws UnsupportedOperationException, MalformedURLException, UnknownHostException { if(!(clusterViewManager instanceof ServerClusterViewManager)) { LOGGER.error("Clients cannot call this method"); throw new UnsupportedOperationException("Clients cannot call this method"); } return ((ServerClusterViewManager) clusterViewManager).isServerBlackListed(new ServerRef(serverName)); }
/** * Returns the load-factor for the server with the given address. * @param serverRef a reference on a server * @return the load-factor for the server with the given address * @throws IllegalArgumentException if none server has the given address * @throws MalformedURLException if the URL is malformed * @throws UnknownHostException if the given host cannot be resolved */ public Integer getLoadFactor(final String serverRef) throws IllegalArgumentException, MalformedURLException, UnknownHostException { try { return clusterViewManager.getLoadFactor(new ServerRef(serverRef)); } catch(ServerNotFoundException e) { LOGGER.error("Server not found: {0}", serverRef, e); throw new IllegalArgumentException("Server not found: " + serverRef + "\n" + e.getMessage()); } }
/** * Returns the initial provider URLs by extracting it from environment. * @param protocol The protocol to extract server references from. * @param providerURLs Set of provider URLs * @return a list of references on server found in environment * @throws CMIConfigException if environment doesn't contain provider URL or if the property is malformed */ public static List<ServerRef> extractServerRefs(final String protocol, final List<String> providerURLs) throws CMIConfigException { if(protocol == null) { throw new IllegalArgumentException("Protocol missing"); } List<ServerRef> serverRefs; int size = providerURLs.size(); serverRefs = new ArrayList<ServerRef>(size); for(String providerURL : providerURLs) { try { serverRefs.add(new ServerRef(protocol, providerURL)); } catch (MalformedURLException e) { logger.error("The following provider URL is malformed {0}", providerURL, e); throw new CMIConfigException("The following provider URL is malformed " + providerURL, e); } catch (UnknownHostException e) { logger.error("The host name of the provider URL {0} cannot be resolved", providerURL, e); throw new CMIConfigException( "The host name of the provider URL " + providerURL + " cannot be resolved", e); } } return serverRefs; }