当前位置: 首页>>代码示例>>Java>>正文


Java SessionExpiredException类代码示例

本文整理汇总了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();
    }
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:22,代码来源:SessionTrackerImpl.java

示例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();
            }
        }
    }
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:18,代码来源:LearnerSessionTracker.java

示例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;
            }
        }
    }
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:18,代码来源:LearnerSessionTracker.java

示例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);
    }
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:21,代码来源:DiscoveryServiceTest.java

示例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();
    }
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:12,代码来源:SessionTrackerImpl.java

示例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;
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:8,代码来源:SessionTrackerImpl.java

示例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.
    }
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:13,代码来源:LeaderZooKeeperServer.java

示例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();
    }
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:10,代码来源:SessionTrackerImpl.java

示例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();
    }
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:10,代码来源:LeaderSessionTracker.java

示例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);
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:13,代码来源:LeaderSessionTracker.java

示例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);
    }
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:17,代码来源:HBaseReplicationEndpoint.java

示例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();
    }
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:12,代码来源:SessionTrackerImpl.java

示例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;
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:8,代码来源:SessionTrackerImpl.java


注:本文中的org.apache.zookeeper.KeeperException.SessionExpiredException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。