本文整理汇总了Java中org.apache.hadoop.ipc.Server.Connection类的典型用法代码示例。如果您正苦于以下问题:Java Connection类的具体用法?Java Connection怎么用?Java Connection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Connection类属于org.apache.hadoop.ipc.Server包,在下文中一共展示了Connection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cleanupIdleConnections
import org.apache.hadoop.ipc.Server.Connection; //导入依赖的package包/类
synchronized private void cleanupIdleConnections(String serverName) {
long currentTime = System.currentTimeMillis();
for (int i = 0; i < connectionArray.size();) {
Connection c = connectionArray.get(i);
if (c.timedOut(currentTime)) {
if (Server.LOG.isDebugEnabled()) {
Server.LOG.debug(serverName + ": disconnecting client "
+ c.getHostAddress());
}
closeConnectionWithoutException(c);
replaceConnectionWithTheLastOne(i);
} else {
i++;
}
}
}
示例2: callAndVerify
import org.apache.hadoop.ipc.Server.Connection; //导入依赖的package包/类
/**
* Make a call from a client and verify if header info is changed in server side
*/
private static void callAndVerify(Server server, InetSocketAddress addr,
int serviceClass, boolean noChanged) throws IOException{
Client client = new Client(LongWritable.class, conf);
call(client, addr, serviceClass, conf);
Connection connection = server.getConnections()[0];
int serviceClass2 = connection.getServiceClass();
assertFalse(noChanged ^ serviceClass == serviceClass2);
client.stop();
}
示例3: callAndVerify
import org.apache.hadoop.ipc.Server.Connection; //导入依赖的package包/类
/**
* Make a call from a client and verify if header info is changed in server side
*/
private void callAndVerify(Server server, InetSocketAddress addr,
int serviceClass, boolean noChanged) throws IOException{
Client client = new Client(LongWritable.class, conf);
client.call(new LongWritable(RANDOM.nextLong()),
addr, null, null, MIN_SLEEP_TIME, serviceClass, conf);
Connection connection = server.getConnections()[0];
int serviceClass2 = connection.getServiceClass();
assertFalse(noChanged ^ serviceClass == serviceClass2);
client.stop();
}
示例4: callAndVerify
import org.apache.hadoop.ipc.Server.Connection; //导入依赖的package包/类
/**
* Make a call from a client and verify if header info is changed in server side
*/
private void callAndVerify(Server server, InetSocketAddress addr,
int serviceClass, boolean noChanged) throws Exception{
Client client = new Client(LongWritable.class, conf);
client.call(new LongWritable(RANDOM.nextLong()),
addr, null, null, MIN_SLEEP_TIME, serviceClass, conf);
Connection connection = server.getConnections()[0];
int serviceClass2 = connection.getServiceClass();
assertFalse(noChanged ^ serviceClass == serviceClass2);
client.stop();
}
示例5: removeConnection
import org.apache.hadoop.ipc.Server.Connection; //导入依赖的package包/类
void removeConnection(Connection c) {
if (c == null) {
return;
}
ConnectionBucket bucket = getBucket(c);
bucket.removeConnection(c);
rpcMetrics.numOpenConnections.inc(-1);
}
示例6: getBucketIndexFromConnection
import org.apache.hadoop.ipc.Server.Connection; //导入依赖的package包/类
int getBucketIndexFromConnection(Connection c) {
String connString = null;
if (c == null || (connString = c.toString()) == null) {
return 0;
}
int hashCode = Math.abs(connString.hashCode());
return hashCode % numBuckets;
}
示例7: cleanConnections
import org.apache.hadoop.ipc.Server.Connection; //导入依赖的package包/类
synchronized private void cleanConnections() {
for (Connection c : connectionArray) {
closeConnectionWithoutException(c);
}
numConnections.addAndGet(-connectionArray.size());
connectionArray.clear();
}
示例8: isConnectionsClean
import org.apache.hadoop.ipc.Server.Connection; //导入依赖的package包/类
private synchronized boolean isConnectionsClean() {
for (Connection c : connectionArray) {
if (!c.responseQueue.isEmpty()) {
return false;
}
}
return true;
}
示例9: closeConnectionWithoutException
import org.apache.hadoop.ipc.Server.Connection; //导入依赖的package包/类
private void closeConnectionWithoutException(Connection c) {
try {
c.close();
} catch (IOException e) {
if (Server.LOG.isDebugEnabled()) {
Server.LOG.debug("IOException when closing connection", e);
}
}
}
示例10: callAndVerify
import org.apache.hadoop.ipc.Server.Connection; //导入依赖的package包/类
/**
* Make a call from a client and verify if header info is changed in server side
*/
private void callAndVerify(Server server, InetSocketAddress addr,
int serviceClass, boolean noChanged) throws IOException{
Client client = new Client(LongWritable.class, conf);
client.call(new LongWritable(RANDOM.nextLong()),
addr, null, null, MIN_SLEEP_TIME, serviceClass, conf);
Connection connection = server.getConnections().get(0);
int serviceClass2 = connection.getServiceClass();
assertFalse(noChanged ^ serviceClass == serviceClass2);
client.stop();
}
示例11: doDigestRpc
import org.apache.hadoop.ipc.Server.Connection; //导入依赖的package包/类
private void doDigestRpc(Server server, TestTokenSecretManager sm)
throws Exception {
final UserGroupInformation current = UserGroupInformation.getCurrentUser();
addr = NetUtils.getConnectAddress(server);
TestTokenIdentifier tokenId = new TestTokenIdentifier(new Text(current
.getUserName()));
Token<TestTokenIdentifier> token = new Token<TestTokenIdentifier>(tokenId, sm);
SecurityUtil.setTokenService(token, addr);
current.addToken(token);
TestRpcService proxy = null;
try {
proxy = getClient(addr, conf);
AuthMethod authMethod = convert(
proxy.getAuthMethod(null, newEmptyRequest()));
assertEquals(TOKEN, authMethod);
//QOP must be auth
assertEquals(expectedQop.saslQop,
RPC.getConnectionIdForProxy(proxy).getSaslQop());
int n = 0;
for (Connection connection : server.getConnections()) {
// only qop auth should dispose of the sasl server
boolean hasServer = (connection.saslServer != null);
assertTrue("qop:" + expectedQop + " hasServer:" + hasServer,
(expectedQop == QualityOfProtection.AUTHENTICATION) ^ hasServer);
n++;
}
assertTrue(n > 0);
proxy.ping(null, newEmptyRequest());
} finally {
stop(server, proxy);
}
}
示例12: create
import org.apache.hadoop.ipc.Server.Connection; //导入依赖的package包/类
@InterfaceAudience.Private
@InterfaceStability.Unstable
public SaslServer create(final Connection connection,
final Map<String,?> saslProperties,
SecretManager<TokenIdentifier> secretManager
) throws IOException, InterruptedException {
UserGroupInformation ugi = null;
final CallbackHandler callback;
switch (authMethod) {
case TOKEN: {
callback = new SaslDigestCallbackHandler(secretManager, connection);
break;
}
case KERBEROS: {
ugi = UserGroupInformation.getCurrentUser();
if (serverId.isEmpty()) {
throw new AccessControlException(
"Kerberos principal name does NOT have the expected "
+ "hostname part: " + ugi.getUserName());
}
callback = new SaslGssCallbackHandler();
break;
}
default:
// we should never be able to get here
throw new AccessControlException(
"Server does not support SASL " + authMethod);
}
final SaslServer saslServer;
if (ugi != null) {
saslServer = ugi.doAs(
new PrivilegedExceptionAction<SaslServer>() {
@Override
public SaslServer run() throws SaslException {
return saslFactory.createSaslServer(mechanism, protocol, serverId,
saslProperties, callback);
}
});
} else {
saslServer = saslFactory.createSaslServer(mechanism, protocol, serverId,
saslProperties, callback);
}
if (saslServer == null) {
throw new AccessControlException(
"Unable to find SASL server implementation for " + mechanism);
}
if (LOG.isDebugEnabled()) {
LOG.debug("Created SASL server with mechanism = " + mechanism);
}
return saslServer;
}
示例13: SaslDigestCallbackHandler
import org.apache.hadoop.ipc.Server.Connection; //导入依赖的package包/类
public SaslDigestCallbackHandler(
SecretManager<TokenIdentifier> secretManager,
Server.Connection connection) {
this.secretManager = secretManager;
this.connection = connection;
}
示例14: addConnection
import org.apache.hadoop.ipc.Server.Connection; //导入依赖的package包/类
void addConnection(Connection c) {
ConnectionBucket bucket = getBucket(c);
bucket.addConnection(c);
rpcMetrics.numOpenConnections.inc(1);
}
示例15: getBucket
import org.apache.hadoop.ipc.Server.Connection; //导入依赖的package包/类
ConnectionBucket getBucket(Connection c) {
return getBucket(getBucketIndexFromConnection(c));
}