本文整理汇总了Java中org.apache.commons.pool2.PooledObject.getObject方法的典型用法代码示例。如果您正苦于以下问题:Java PooledObject.getObject方法的具体用法?Java PooledObject.getObject怎么用?Java PooledObject.getObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.pool2.PooledObject
的用法示例。
在下文中一共展示了PooledObject.getObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateObject
import org.apache.commons.pool2.PooledObject; //导入方法依赖的package包/类
@Override
public boolean validateObject(PooledObject<Jedis> pooledJedis) {
final BinaryJedis jedis = pooledJedis.getObject();
try {
HostAndPort hostAndPort = this.hostAndPort.get();
String connectionHost = jedis.getClient().getHost();
int connectionPort = jedis.getClient().getPort();
return hostAndPort.getHost().equals(connectionHost)
&& hostAndPort.getPort() == connectionPort && jedis.isConnected()
&& jedis.ping().equals("PONG");
} catch (final Exception e) {
return false;
}
}
示例2: passivateObject
import org.apache.commons.pool2.PooledObject; //导入方法依赖的package包/类
@Override
public void passivateObject(Event.Type key, PooledObject<Event> pooledObject) throws Exception {
final Event event = pooledObject.getObject();
switch (event.type) {
case BEFORE:
unsafe.putObject(event, targetFieldInBeforeEventOffset, null);
unsafe.putObject(event, argumentArrayFieldInBeforeEventOffset, null);
break;
case IMMEDIATELY_THROWS:
case THROWS:
unsafe.putObject(event, throwableFieldInThrowsEventOffset, null);
break;
case IMMEDIATELY_RETURN:
case RETURN:
unsafe.putObject(event, objectFieldInReturnEventOffset, null);
}
}
示例3: validateObject
import org.apache.commons.pool2.PooledObject; //导入方法依赖的package包/类
@Override
public boolean validateObject(PooledObject<Jedis> pooledJedis) {
final BinaryJedis jedis = pooledJedis.getObject();
try {
HostAndPort hostAndPort = this.hostAndPort.get();
String connectionHost = jedis.getClient().getHost();
int connectionPort = jedis.getClient().getPort();
return hostAndPort.getHost().equals(connectionHost)
&& hostAndPort.getPort() == connectionPort && jedis.isConnected()
&& jedis.ping().equals("PONG");
} catch (final Exception e) {
return false;
}
}
示例4: activateObject
import org.apache.commons.pool2.PooledObject; //导入方法依赖的package包/类
@Override
public void activateObject(PooledObject<Jedis> pooledJedis) throws Exception {
final BinaryJedis jedis = pooledJedis.getObject();
if (jedis.getDB() != database) {
jedis.select(database);
}
}
示例5: activateObject
import org.apache.commons.pool2.PooledObject; //导入方法依赖的package包/类
@Override
public void activateObject(PooledObject<Jedis> pooledJedis) throws Exception {
final BinaryJedis jedis = pooledJedis.getObject();
if (jedis.getDB() != database) {
jedis.select(database);
}
}
示例6: validateObject
import org.apache.commons.pool2.PooledObject; //导入方法依赖的package包/类
@Override
public boolean validateObject(PooledObject<Jedis> pooledJedis) {
final BinaryJedis jedis = pooledJedis.getObject();
try {
HostAndPort hostAndPort = this.hostAndPort.get();
String connectionHost = jedis.getClient().getHost();
int connectionPort = jedis.getClient().getPort();
return hostAndPort.getHost().equals(connectionHost) && hostAndPort.getPort() == connectionPort
&& jedis.isConnected() && jedis.ping().equals("PONG");
} catch (final Exception e) {
return false;
}
}
示例7: validateObject
import org.apache.commons.pool2.PooledObject; //导入方法依赖的package包/类
@Override
public boolean validateObject(PooledObject<ShardedJedis> pooledShardedJedis) {
try {
ShardedJedis jedis = pooledShardedJedis.getObject();
for (Jedis shard : jedis.getAllShards()) {
if (!shard.ping().equals("PONG")) {
return false;
}
}
return true;
} catch (Exception ex) {
return false;
}
}
示例8: destroyObject
import org.apache.commons.pool2.PooledObject; //导入方法依赖的package包/类
@Override
public void destroyObject(ConnectionDetails connectionDetails, PooledObject<Session> sessionObject) {
log.debug("Destroying session for "+connectionDetails);
if (sessionObject != null) {
Session session = sessionObject.getObject();
if (session != null) {
session.disconnect();
}
}
}
示例9: activateObject
import org.apache.commons.pool2.PooledObject; //导入方法依赖的package包/类
@Override
public void activateObject(final PooledObject<Session> p) throws BackgroundException {
final Session session = p.getObject();
if(log.isDebugEnabled()) {
log.debug(String.format("Activate session %s", session));
}
// Load vault to increment open count for pooled vault
connect.check(session, cache, new DisabledCancelCallback());
}
示例10: passivateObject
import org.apache.commons.pool2.PooledObject; //导入方法依赖的package包/类
@Override
public void passivateObject(final PooledObject<Session> p) throws Exception {
final Session session = p.getObject();
if(log.isDebugEnabled()) {
log.debug(String.format("Pause session %s", session));
}
}
示例11: destroyObject
import org.apache.commons.pool2.PooledObject; //导入方法依赖的package包/类
@Override
public void destroyObject(final PooledObject<Session> p) throws BackgroundException {
final Session session = p.getObject();
if(log.isDebugEnabled()) {
log.debug(String.format("Destroy session %s", session));
}
session.close();
}
示例12: passivateObject
import org.apache.commons.pool2.PooledObject; //导入方法依赖的package包/类
@Override
public void passivateObject(PooledObject<PooledFastResource> p) throws Exception {
PooledFastResource resource = p.getObject();
synchronized (resource) {
resource.getStorageServer().close();
resource.getTrackerServer().close();
}
}
示例13: activateObject
import org.apache.commons.pool2.PooledObject; //导入方法依赖的package包/类
@Override
public void activateObject(PooledObject<Jedis> pooledJedis) throws Exception {
final BinaryJedis jedis = pooledJedis.getObject();
if (jedis.getDB() != database) {
jedis.select(database);
}
}
示例14: validateObject
import org.apache.commons.pool2.PooledObject; //导入方法依赖的package包/类
@Override
public boolean validateObject(PooledObject<ShardedJedis> pooledShardedJedis) {
try {
ShardedJedis jedis = pooledShardedJedis.getObject();
for (Jedis shard : jedis.getAllShards()) {
if (!shard.ping().equals("PONG")) {
return false;
}
}
return true;
} catch (Exception ex) {
return false;
}
}
示例15: destroyObject
import org.apache.commons.pool2.PooledObject; //导入方法依赖的package包/类
@Override
public void destroyObject(PooledObject<KuduClient> pooledKuduClient)
throws Exception
{
final KuduClient kuduClient = pooledKuduClient.getObject();
kuduClient.close();
}