本文整理汇总了Java中org.jivesoftware.openfire.cluster.ClusterEventListener类的典型用法代码示例。如果您正苦于以下问题:Java ClusterEventListener类的具体用法?Java ClusterEventListener怎么用?Java ClusterEventListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClusterEventListener类属于org.jivesoftware.openfire.cluster包,在下文中一共展示了ClusterEventListener类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: startClustering
import org.jivesoftware.openfire.cluster.ClusterEventListener; //导入依赖的package包/类
public static void startClustering() {
if (isClusteringAvailable()) {
clusteringStarting = clusteredCacheFactoryStrategy.startCluster();
}
if (clusteringStarting) {
if (statsThread == null) {
// Start a timing thread with 1 second of accuracy.
statsThread = new Thread("Cache Stats") {
private volatile boolean destroyed = false;
@Override
public void run() {
XMPPServer.getInstance().addServerListener(new XMPPServerListener() {
@Override
public void serverStarted() {}
@Override
public void serverStopping() {
destroyed = true;
}
});
ClusterManager.addListener(new ClusterEventListener() {
@Override
public void joinedCluster() {}
@Override
public void joinedCluster(byte[] nodeID) {}
@Override
public void leftCluster() {
destroyed = true;
ClusterManager.removeListener(this);
}
@Override
public void leftCluster(byte[] nodeID) {}
@Override
public void markedAsSeniorClusterMember() {}
});
// Run the timer indefinitely.
while (!destroyed && ClusterManager.isClusteringEnabled()) {
// Publish cache stats for this cluster node (assuming clustering is
// enabled and there are stats to publish).
try {
cacheFactoryStrategy.updateCacheStats(caches);
}
catch (Exception e) {
log.error(e.getMessage(), e);
}
try {
// Sleep 10 seconds.
sleep(10000);
}
catch (InterruptedException ie) {
// Ignore.
}
}
statsThread = null;
log.debug("Cache stats thread terminated.");
}
};
statsThread.setDaemon(true);
statsThread.start();
}
}
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:69,代码来源:CacheFactory.java
示例2: startClustering
import org.jivesoftware.openfire.cluster.ClusterEventListener; //导入依赖的package包/类
public static void startClustering() {
if (isClusteringAvailable()) {
clusteringStarting = clusteredCacheFactoryStrategy.startCluster();
}
if (clusteringStarting) {
if (statsThread == null) {
// Start a timing thread with 1 second of accuracy.
statsThread = new Thread("Cache Stats") {
private volatile boolean destroyed = false;
@Override
public void run() {
XMPPServer.getInstance().addServerListener(new XMPPServerListener() {
public void serverStarted() {}
public void serverStopping() {
destroyed = true;
}
});
ClusterManager.addListener(new ClusterEventListener() {
public void joinedCluster() {}
public void joinedCluster(byte[] nodeID) {}
public void leftCluster() {
destroyed = true;
ClusterManager.removeListener(this);
}
public void leftCluster(byte[] nodeID) {}
public void markedAsSeniorClusterMember() {}
});
// Run the timer indefinitely.
while (!destroyed && ClusterManager.isClusteringEnabled()) {
// Publish cache stats for this cluster node (assuming clustering is
// enabled and there are stats to publish).
try {
cacheFactoryStrategy.updateCacheStats(caches);
}
catch (Exception e) {
log.error(e.getMessage(), e);
}
try {
// Sleep 10 seconds.
sleep(10000);
}
catch (InterruptedException ie) {
// Ignore.
}
}
statsThread = null;
log.debug("Cache stats thread terminated.");
}
};
statsThread.setDaemon(true);
statsThread.start();
}
}
}
开发者ID:idwanglu2010,项目名称:openfire,代码行数:62,代码来源:CacheFactory.java
注:本文中的org.jivesoftware.openfire.cluster.ClusterEventListener类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论