本文整理汇总了Java中org.apache.zookeeper.KeeperException.SessionExpiredException类的典型用法代码示例。如果您正苦于以下问题:Java SessionExpiredException类的具体用法?Java SessionExpiredException怎么用?Java SessionExpiredException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SessionExpiredException类属于org.apache.zookeeper.KeeperException包,在下文中一共展示了SessionExpiredException类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkSession
import org.apache.zookeeper.KeeperException.SessionExpiredException; //导入依赖的package包/类
public synchronized void checkSession(long sessionId, Object owner)
throws KeeperException.SessionExpiredException,
KeeperException.SessionMovedException,
KeeperException.UnknownSessionException {
LOG.debug("Checking session 0x" + Long.toHexString(sessionId));
SessionImpl session = sessionsById.get(sessionId);
if (session == null) {
throw new KeeperException.UnknownSessionException();
}
if (session.isClosing()) {
throw new KeeperException.SessionExpiredException();
}
if (session.owner == null) {
session.owner = owner;
} else if (session.owner != owner) {
throw new KeeperException.SessionMovedException();
}
}
示例2: checkSession
import org.apache.zookeeper.KeeperException.SessionExpiredException; //导入依赖的package包/类
public void checkSession(long sessionId, Object owner)
throws SessionExpiredException, SessionMovedException {
if (localSessionTracker != null) {
try {
localSessionTracker.checkSession(sessionId, owner);
return;
} catch (UnknownSessionException e) {
// Check whether it's a global session. We can ignore those
// because they are handled at the leader, but if not, rethrow.
// We check local session status first to avoid race condition
// with session upgrading.
if (!isGlobalSession(sessionId)) {
throw new SessionExpiredException();
}
}
}
}
示例3: setOwner
import org.apache.zookeeper.KeeperException.SessionExpiredException; //导入依赖的package包/类
public void setOwner(long sessionId, Object owner)
throws SessionExpiredException {
if (localSessionTracker != null) {
try {
localSessionTracker.setOwner(sessionId, owner);
return;
} catch (SessionExpiredException e) {
// Check whether it's a global session. We can ignore those
// because they are handled at the leader, but if not, rethrow.
// We check local session status first to avoid race condition
// with session upgrading.
if (!isGlobalSession(sessionId)) {
throw e;
}
}
}
}
示例4: testGetPartitionsMetadata
import org.apache.zookeeper.KeeperException.SessionExpiredException; //导入依赖的package包/类
@Test
public void testGetPartitionsMetadata() throws Exception {
DestinationName topic1 = DestinationName.get("persistent://test/local/ns/my-topic-1");
PartitionedTopicMetadata m = service.getDiscoveryProvider().getPartitionedTopicMetadata(service, topic1, "role")
.get();
assertEquals(m.partitions, 0);
// Simulate ZK error
mockZookKeeper.failNow(Code.SESSIONEXPIRED);
DestinationName topic2 = DestinationName.get("persistent://test/local/ns/my-topic-2");
CompletableFuture<PartitionedTopicMetadata> future = service.getDiscoveryProvider()
.getPartitionedTopicMetadata(service, topic2, "role");
try {
future.get();
fail("Partition metadata lookup should have failed");
} catch (ExecutionException e) {
assertEquals(e.getCause().getClass(), SessionExpiredException.class);
}
}
示例5: checkSession
import org.apache.zookeeper.KeeperException.SessionExpiredException; //导入依赖的package包/类
synchronized public void checkSession(long sessionId, Object owner) throws KeeperException.SessionExpiredException, KeeperException.SessionMovedException {
SessionImpl session = sessionsById.get(sessionId);
if (session == null || session.isClosing()) {
throw new KeeperException.SessionExpiredException();
}
if (session.owner == null) {
session.owner = owner;
} else if (session.owner != owner) {
throw new KeeperException.SessionMovedException();
}
}
示例6: setOwner
import org.apache.zookeeper.KeeperException.SessionExpiredException; //导入依赖的package包/类
synchronized public void setOwner(long id, Object owner) throws SessionExpiredException {
SessionImpl session = sessionsById.get(id);
if (session == null || session.isClosing()) {
throw new KeeperException.SessionExpiredException();
}
session.owner = owner;
}
示例7: revalidateSession
import org.apache.zookeeper.KeeperException.SessionExpiredException; //导入依赖的package包/类
@Override
protected void revalidateSession(ServerCnxn cnxn, long sessionId,
int sessionTimeout) throws IOException {
super.revalidateSession(cnxn, sessionId, sessionTimeout);
try {
// setowner as the leader itself, unless updated
// via the follower handlers
setOwner(sessionId, ServerCnxn.me);
} catch (SessionExpiredException e) {
// this is ok, it just means that the session revalidation failed.
}
}
示例8: checkGlobalSession
import org.apache.zookeeper.KeeperException.SessionExpiredException; //导入依赖的package包/类
public void checkGlobalSession(long sessionId, Object owner)
throws KeeperException.SessionExpiredException,
KeeperException.SessionMovedException {
try {
checkSession(sessionId, owner);
} catch (KeeperException.UnknownSessionException e) {
throw new KeeperException.SessionExpiredException();
}
}
示例9: checkGlobalSession
import org.apache.zookeeper.KeeperException.SessionExpiredException; //导入依赖的package包/类
public void checkGlobalSession(long sessionId, Object owner)
throws SessionExpiredException, SessionMovedException {
try {
globalSessionTracker.checkSession(sessionId, owner);
} catch (UnknownSessionException e) {
// For global session, if we don't know it, it is already expired
throw new SessionExpiredException();
}
}
示例10: setOwner
import org.apache.zookeeper.KeeperException.SessionExpiredException; //导入依赖的package包/类
public void setOwner(long sessionId, Object owner)
throws SessionExpiredException {
if (localSessionTracker != null) {
try {
localSessionTracker.setOwner(sessionId, owner);
return;
} catch(SessionExpiredException e) {
// Ignore. We'll check instead whether it's a global session
}
}
globalSessionTracker.setOwner(sessionId, owner);
}
示例11: reconnect
import org.apache.zookeeper.KeeperException.SessionExpiredException; //导入依赖的package包/类
/**
* A private method used to re-establish a zookeeper session with a peer cluster.
* @param ke
*/
protected void reconnect(KeeperException ke) {
if (ke instanceof ConnectionLossException || ke instanceof SessionExpiredException
|| ke instanceof AuthFailedException) {
String clusterKey = ctx.getPeerConfig().getClusterKey();
LOG.warn("Lost the ZooKeeper connection for peer " + clusterKey, ke);
try {
reloadZkWatcher();
} catch (IOException io) {
LOG.warn("Creation of ZookeeperWatcher failed for peer " + clusterKey, io);
}
}
}
示例12: checkSession
import org.apache.zookeeper.KeeperException.SessionExpiredException; //导入依赖的package包/类
synchronized public void checkSession(long sessionId, Object owner) throws KeeperException.SessionExpiredException, KeeperException.SessionMovedException {
SessionImpl session = sessionsById.get(sessionId);
if (session == null) {
throw new KeeperException.SessionExpiredException();
}
if (session.owner == null) {
session.owner = owner;
} else if (session.owner != owner) {
throw new KeeperException.SessionMovedException();
}
}
示例13: setOwner
import org.apache.zookeeper.KeeperException.SessionExpiredException; //导入依赖的package包/类
synchronized public void setOwner(long id, Object owner) throws SessionExpiredException {
SessionImpl session = sessionsById.get(id);
if (session == null) {
throw new KeeperException.SessionExpiredException();
}
session.owner = owner;
}