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; }
/** * Make sure two ServerLocation objects on different hosts but with the same port * are not equal */ public void testBug42040() { ServerLocation sl1 = new ServerLocation("host1", 777); ServerLocation sl2 = new ServerLocation("host2", 777); if (sl1.equals(sl2)) { fail("ServerLocation instances on different hosts should not test equal"); } }
public void fromData(DataInput in) throws IOException, ClassNotFoundException { this.serverFound = DataSerializer.readPrimitiveBoolean(in); if (this.serverFound) { server = new ServerLocation(); server.fromData(in); } }
@Override public String toString() { return this.getName() + " (" + this.location.getHostName() + ":" + this.location.getPort() + ")"; }
public ServerLocation findServer(Set excludedServers) { return new ServerLocation("localhost", nextPort++); } public ServerLocation findReplacementServer(ServerLocation currentServer, Set/*<ServerLocation>*/ excludedServers) {
public static void acquireConnectionsAndClear(String host) { try { Region r1 = cache.getRegion(Region.SEPARATOR + REGION_NAME); assertNotNull(r1); String poolName = r1.getAttributes().getPoolName(); assertNotNull(poolName); PoolImpl pool = (PoolImpl)PoolManager.find(poolName); assertNotNull(pool); Connection conn1 = pool.acquireConnection(new ServerLocation(host, PORT2)); assertNotNull(conn1); assertEquals(PORT2, conn1.getServer().getPort()); ServerRegionProxy srp = new ServerRegionProxy(Region.SEPARATOR + REGION_NAME, pool); srp.clearOnForTestsOnly(conn1, new EventID(new byte[] {1}, 1, 1), null); } catch (Exception ex) { ex.printStackTrace(); fail("while setting acquireConnections " + ex); } }
@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); } }
public int compareTo(Object o) { ServerLocation other = (ServerLocation) o; int difference = hostName.compareTo(other.hostName); if(difference != 0) { return difference; } return port - other.getPort(); }
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); } } } } }
if (cnx.getServer().getRequiresCredentials()) { userId = cnx.getServer().getUserId(); } else { // multi user mode Object id = UserAttributes.userAttributes.get().getServerToId().get(
@Override public Object attempt(Connection cnx) throws Exception { if (cnx.getServer().getRequiresCredentials()) { return super.attempt(cnx); } else { return null; } }
@Override public void fromData(DataInput in) throws IOException, ClassNotFoundException { super.fromData(in); this.bucketId = DataSerializer.readInteger(in); this.isPrimary = DataSerializer.readBoolean(in); this.version = DataSerializer.readByte(in); }
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 && (authInit != null && authInit.length() != 0)) { location.compareAndSetRequiresCredentials(true);
@Override public String toString() { return this.getName() + " (" + this.location.getHostName() + ":" + this.location.getPort() + ")"; }
public Connection getPrimary() { getPrimary++; return new DummyConnection(new ServerLocation("localhost", currentServer++)); } public QueueConnectionImpl getConnection(Endpoint ep) {
public static void acquireConnectionsAndDestroyRegion(String host) { try { Region r1 = cache.getRegion(Region.SEPARATOR + REGION_NAME); assertNotNull(r1); String poolName = r1.getAttributes().getPoolName(); assertNotNull(poolName); PoolImpl pool = (PoolImpl)PoolManager.find(poolName); assertNotNull(pool); Connection conn1 = pool.acquireConnection(new ServerLocation(host, PORT2)); assertNotNull(conn1); assertEquals(PORT2, conn1.getServer().getPort()); ServerRegionProxy srp = new ServerRegionProxy(Region.SEPARATOR + REGION_NAME, pool); srp.destroyRegionOnForTestsOnly(conn1, new EventID(new byte[] {1}, 1, 1), null); } catch (Exception ex) { ex.printStackTrace(); fail("while setting acquireConnections " + ex); } }
@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); } }
protected static void assertPortEquals(int[] expected, List actual) { ArrayList expectedPorts = new ArrayList(); for(int i = 0; i < expected.length; i++) { expectedPorts.add(new Integer(expected[i])); } ArrayList actualPorts = new ArrayList(); for(Iterator itr = actual.iterator(); itr.hasNext();) { actualPorts.add(new Integer(((Connection) itr.next()).getServer().getPort())); } Assert.assertEquals(expectedPorts, actualPorts); }
private void authenticateIfRequired(Connection conn, Op op) { if (!conn.getServer().getRequiresCredentials()) { return; if (conn.getServer().getUserId() == -1) { Connection connImpl = this.connectionManager.getConnection(conn); conn.getServer().setUserId( (Long)AuthenticateUserOp.executeOn(connImpl, this.pool)); if (logger.isDebugEnabled()) {