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


Java ClusterManager.isClusteringEnabled方法代码示例

本文整理汇总了Java中org.jivesoftware.openfire.cluster.ClusterManager.isClusteringEnabled方法的典型用法代码示例。如果您正苦于以下问题:Java ClusterManager.isClusteringEnabled方法的具体用法?Java ClusterManager.isClusteringEnabled怎么用?Java ClusterManager.isClusteringEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jivesoftware.openfire.cluster.ClusterManager的用法示例。


在下文中一共展示了ClusterManager.isClusteringEnabled方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: canExecute

import org.jivesoftware.openfire.cluster.ClusterManager; //导入方法依赖的package包/类
protected boolean canExecute() {
  if(ClusterManager.isClusteringEnabled()) {
    LOGGER.debug("canExecute : clustering is enabled");
    try {
      if(lock != null) {
        boolean result = lock.tryLock();
        LOGGER.trace("canExecute : tryLockResult={}", result);
        return result;
      } else {
        LOGGER.debug("canExecute : lock has not been set, cannot execute task");
        return false;
      }
    } catch (Exception e) {
      LOGGER.error("canExecute : error trying to acquire distributed lock", e);
      return false;
    }
  } else {
    LOGGER.debug("canExecute : clustering is disabled return true");
    return true;
  }
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:22,代码来源:MMXClusterableTask.java

示例2: shutdown

import org.jivesoftware.openfire.cluster.ClusterManager; //导入方法依赖的package包/类
public static void shutdown()
{
    log.info("Flushing write cache to database");
    flushPendingItems(false); // local member only
    
    // node cleanup (skip when running as a cluster)
    if (!ClusterManager.isClusteringEnabled()) {
        purgeItems();
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:11,代码来源:PubSubPersistenceManager.java

示例3: updateCluster

import org.jivesoftware.openfire.cluster.ClusterManager; //导入方法依赖的package包/类
private void updateCluster() {
    boolean isClustered = ClusterManager.isClusteringEnabled();
    if (isClustered) {
        RulesUpdatedEvent request = new RulesUpdatedEvent();
        CacheFactory.doClusterTask(request);
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:8,代码来源:DbRuleManager.java

示例4: shutdown

import org.jivesoftware.openfire.cluster.ClusterManager; //导入方法依赖的package包/类
public static void shutdown()
  {
  	log.info("Flushing write cache to database");
flushPendingItems(false); // local member only

// node cleanup (skip when running as a cluster)
if (!ClusterManager.isClusteringEnabled()) {
	purgeItems();
}
  }
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:11,代码来源:PubSubPersistenceManager.java

示例5: startClustering

import org.jivesoftware.openfire.cluster.ClusterManager; //导入方法依赖的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

示例6: initializePlugin

import org.jivesoftware.openfire.cluster.ClusterManager; //导入方法依赖的package包/类
public void initializePlugin(PluginManager manager, File pluginDirectory) {
        System.out.println("Starting Clustering Plugin");

        // Check if we Enterprise is installed and stop loading this plugin if found
        File pluginDir = new File(JiveGlobals.getHomeDirectory(), "plugins");
        File[] jars = pluginDir.listFiles(new FileFilter() {
            public boolean accept(File pathname) {
                String fileName = pathname.getName().toLowerCase();
                return (fileName.equalsIgnoreCase("enterprise.jar"));
            }
        });
        if (jars.length > 0) {
            // Do not load this plugin since Enterprise is still installed
            System.out.println("Enterprise plugin found. Stopping Clustering Plugin");
            throw new IllegalStateException("This plugin cannot run next to the Enterprise plugin");
        }

        // Make sure that the enteprise folder exists under the home directory
        File enterpriseDir = new File(JiveGlobals.getHomeDirectory() +
            File.separator + "enterprise");
        if (!enterpriseDir.exists()) {
            enterpriseDir.mkdirs();
        }

        // Check if Coherence libs are installed and stop loading this plugin if NOT found
//        File libDir = new File(JiveGlobals.getHomeDirectory(), "lib");
//        jars = libDir.listFiles(new FileFilter() {
//            public boolean accept(File pathname) {
//                String fileName = pathname.getName().toLowerCase();
//                return (fileName.equalsIgnoreCase("coherence.jar"));
//            }
//        });
//        if (jars.length == 0) {
//            // Do not load this plugin since Coherence libs are not installed
//            System.out.println("Coherence libs not found. Stopping Clustering Plugin. Copy tangosol.jar, " +
//                    "coherence.jar and coherence-work.jar files to [OPENFIRE_HOME]/lib and restart the server.");
//            throw new IllegalStateException("Coherence libs not found. Stopping Clustering Plugin. Copy " +
//                    "tangosol.jar, coherence.jar and coherence-work.jar files to [OPENFIRE_HOME]/lib and restart the server.");
//        }

        // List for clustering setting events (e.g. enabled/disabled)
        PropertyEventDispatcher.addListener(this);

        // Delete no longer used COHERENCE_CONFIG file. Java system properties should be used
        // to customize coherence
        File configFile = new File(enterpriseDir, COHERENCE_CONFIG + ".xml");
        if (configFile.exists()) {
            configFile.delete();
        }
        // Delete no longer used COHERENCE_CACHE_CONFIG file. Admins should use system properties
        // to override default values. Same system properties will be used when not using enterprise or not
        // using clustering
        configFile = new File(enterpriseDir, COHERENCE_CACHE_CONFIG + ".xml");
        if (configFile.exists()) {
            configFile.delete();
        }

        try {
            // Add openfireHome/enterprise dir to pluginclassloader
            // Add enterprise plugin dir to pluginclassloader
            URL url = new File(pluginDirectory + File.separator).toURL();
            manager.getPluginClassloader(manager.getPlugin(pluginDirectory.getName())).addURLFile(url);
        }
        catch (MalformedURLException e) {
            Log.error("Error adding openfireHome/enterprise to the classpath of the enterprise plugin", e);
        }

        if (ClusterManager.isClusteringEnabled()) {
            initForClustering();

            // Start up or join the cluster and initialize caches
            ClusterManager.startup();
        }

    }
 
开发者ID:coodeer,项目名称:g3server,代码行数:76,代码来源:ClusteringPlugin.java

示例7: startClustering

import org.jivesoftware.openfire.cluster.ClusterManager; //导入方法依赖的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.ClusterManager.isClusteringEnabled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。