static List constructAndGetRemoveAllTasks(Region region, final EventID eventId, final Map<ServerLocation, HashSet> serverToFilterMap, final PoolImpl pool, Object callbackArg) { final List<SingleHopOperationCallable> tasks = new ArrayList<SingleHopOperationCallable>(); ArrayList<ServerLocation> servers = new ArrayList<ServerLocation>(serverToFilterMap.keySet()); if (logger.isDebugEnabled()) { logger.debug("Constructing tasks for the servers{}", servers); } for (ServerLocation server : servers) { AbstractOp RemoveAllOp = new RemoveAllOpImpl(region, serverToFilterMap.get(server), eventId, true, callbackArg); SingleHopOperationCallable task = new SingleHopOperationCallable(new ServerLocation(server.getHostName(), server.getPort()), pool, RemoveAllOp, UserAttributes.userAttributes.get()); tasks.add(task); } return tasks; }
@Override public boolean equals(Object obj) { if ((obj == null) || !(obj instanceof EstimateMapKey)) { return false; } EstimateMapKey that = (EstimateMapKey) obj; return this.clientId.equals(that.clientId) && this.serverId.equals(that.serverId); } }
private void authenticateIfRequired(Connection conn) { cancelCriterion.checkCancelInProgress(null); if (!pool.isUsedByGateway() && !pool.getMultiuserAuthentication()) { ServerLocation server = conn.getServer(); if (server.getRequiresCredentials()) { if (server.getUserId() == -1) { Long uniqueID = (Long) AuthenticateUserOp.executeOn(conn, pool); server.setUserId(uniqueID); if (logger.isDebugEnabled()) { logger.debug("CFI.authenticateIfRequired() Completed authentication on {}", conn); } } } } }
/** * Test hook that returns a string consisting of the host name and port of the primary server. * Null is returned if we have no primary. */ public String getPrimaryName() { String result = null; ServerLocation sl = getPrimary(); if (sl != null) { result = sl.getHostName() + sl.getPort(); } return result; }
@Override public void fromData(DataInput in) throws IOException, ClassNotFoundException { this.serverFound = DataSerializer.readPrimitiveBoolean(in); if (this.serverFound) { server = new ServerLocation(); server.fromData(in); } }
public ExplicitConnectionSourceImpl(List/* <InetSocketAddress> */ contacts) { ArrayList serverList = new ArrayList(contacts.size()); for (int i = 0; i < contacts.size(); i++) { InetSocketAddress addr = (InetSocketAddress) contacts.get(i); serverList.add(new ServerLocation(addr.getHostName(), addr.getPort())); } shuffle(serverList); this.serverList = Collections.unmodifiableList(serverList); }
public void testIntersectingGroups() { LocatorLoadSnapshot sn = new LocatorLoadSnapshot(); ServerLocation l1 = new ServerLocation("localhost", 1); ServerLocation l2 = new ServerLocation("localhost", 2); ServerLocation l3 = new ServerLocation("localhost", 3); sn.addServer(l1, new String[] {"a",}, new ServerLoad(0, 1, 0, 1)); sn.addServer(l2, new String[] {"a", "b"}, new ServerLoad(0, 1, 0, 1)); assertTrue(l1.equals(l) || l2.equals(l)); l = sn.getServerForConnection("b", Collections.EMPTY_SET); assertTrue(l2.equals(l) || l3.equals(l)); assertTrue(l1.equals(l) || l2.equals(l)); assertTrue(l2.equals(l) || l3.equals(l));
@Override public Object attempt(Connection cnx) throws Exception { if (cnx.getServer().getRequiresCredentials()) { return super.attempt(cnx); } else { return null; } }
@Override public int compareTo(Object o) { ServerLocation other = (ServerLocation) o; int difference = hostName.compareTo(other.hostName); if (difference != 0) { return difference; } return port - other.getPort(); }
if (cnx.getServer().getRequiresCredentials()) { userId = cnx.getServer().getUserId(); } else { // multi user mode Object id = UserAttributes.userAttributes.get().getServerToId().get(cnx.getServer());
.setHostnameResolver((location) -> InetAddress.getByName(location.getHostName()));
@Override public int compare(Object o1, Object o2) { LoadHolder l1 = (LoadHolder) o1; LoadHolder l2 = (LoadHolder) o2; int difference = Float.compare(l1.getLoad(), l2.getLoad()); if (difference != 0) { return difference; } ServerLocation sl1 = l1.getLocation(); ServerLocation sl2 = l2.getLocation(); return sl1.compareTo(sl2); } });
&& intermediateAcceptanceCode != REPLY_AUTH_NOT_REQUIRED && (StringUtils.isNotBlank(authInit) || multiuserSecureMode)) { location.compareAndSetRequiresCredentials(true);
public static ArrayList/* <ServerLocation> */ readServerLocationList(DataInput in) throws IOException, ClassNotFoundException { int size = in.readInt(); if (size < 0) { return null; } ArrayList serverLocations = new ArrayList(size); for (int i = 0; i < size; i++) { ServerLocation next = new ServerLocation(); InternalDataSerializer.invokeFromData(next, in); serverLocations.add(next); } return serverLocations; }
@Override public String toString() { return getName() + " (" + this.location.getHostName() + ':' + this.location.getPort() + ')'; }
/** * Process the security information in a response from the server. If the server sends a security * "part" we must process it so all subclasses should allow this method to be invoked. * * @see ServerConnection#updateAndGetSecurityPart() */ protected void processSecureBytes(Connection cnx, Message message) throws Exception { if (cnx.getServer().getRequiresCredentials()) { if (!message.isSecureMode()) { // This can be seen during shutdown if (logger.isTraceEnabled(LogMarker.BRIDGE_SERVER_VERBOSE)) { logger.trace(LogMarker.BRIDGE_SERVER_VERBOSE, "Response message from {} for {} has no secure part.", cnx, this); } return; } byte[] partBytes = message.getSecureBytes(); if (partBytes == null) { if (logger.isDebugEnabled()) { logger.debug("Response message for {} has no bytes in secure part.", this); } return; } byte[] bytes = ((ConnectionImpl) cnx).decryptBytes(partBytes); DataInputStream dis = new DataInputStream(new ByteArrayInputStream(bytes)); cnx.setConnectionID(dis.readLong()); } }
/** * Test hook that returns an int which the port of the primary server. -1 is returned if we have * no primary. */ public int getPrimaryPort() { int result = -1; ServerLocation sl = getPrimary(); if (sl != null) { result = sl.getPort(); } return result; }
static List constructGetAllTasks(String region, final Map<ServerLocation, HashSet> serverToFilterMap, final PoolImpl pool, final Object callback) { final List<SingleHopOperationCallable> tasks = new ArrayList<SingleHopOperationCallable>(); ArrayList<ServerLocation> servers = new ArrayList<ServerLocation>(serverToFilterMap.keySet()); if (logger.isDebugEnabled()) { logger.debug("Constructing tasks for the servers {}", servers); } for (ServerLocation server : servers) { Set filterSet = serverToFilterMap.get(server); AbstractOp getAllOp = new GetAllOpImpl(region, new ArrayList(filterSet), callback); SingleHopOperationCallable task = new SingleHopOperationCallable(new ServerLocation(server.getHostName(), server.getPort()), pool, getAllOp, UserAttributes.userAttributes.get()); tasks.add(task); } return tasks; }
public static HashSet/* <ServerLocation> */ readServerLocationSet(DataInput in) throws IOException, ClassNotFoundException { int size = in.readInt(); if (size < 0) { return null; } HashSet serverLocations = new HashSet(size); for (int i = 0; i < size; i++) { ServerLocation next = new ServerLocation(); InternalDataSerializer.invokeFromData(next, in); serverLocations.add(next); } return serverLocations; }
/** * Test hook that returns a list of server names (host+port); one for each server we are currently * connected to. */ public List<String> getCurrentServerNames() { List<ServerLocation> servers = getCurrentServers(); ArrayList<String> result = new ArrayList(servers.size()); Iterator it = servers.iterator(); while (it.hasNext()) { ServerLocation sl = (ServerLocation) it.next(); String name = sl.getHostName() + sl.getPort(); result.add(name); } return result; }