<commit_before>/*
 * Tigase Jabber/XMPP Server
 * Copyright (C) 2004-2008 "<NAME>" <<EMAIL>>
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, version 3 of the License.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program. Look for COPYING file in the top folder.
 * If not, see http://www.gnu.org/licenses/.
 * 
 * $Rev$
 * Last modified by $Author$
 * $Date$
 */

package tigase.cluster.strategy;

import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.Logger;
import tigase.cluster.ClusteringStrategyIfc;
import tigase.server.Packet;
import tigase.stats.StatisticsList;
import tigase.xmpp.JID;

/**
 * Created: May 13, 2009 9:53:44 AM
 *
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 * @version $Rev$
 */
public class SMNonCachingAllNodes implements ClusteringStrategyIfc {

  /**
   * Variable <code>log</code> is a class logger.
   */
  private static final Logger log =
    Logger.getLogger(SMNonCachingAllNodes.class.getName());

	//private Set<String> cluster_nodes = new ConcurrentSkipListSet<String>();
	private List<JID> cl_nodes_list = new CopyOnWriteArrayList<JID>();
	//private String smName = null;

	@Override
	public Map<String, Object> getDefaults(Map<String, Object> params) {
		return null;
	}

	@Override
	public void setProperties(Map<String, Object> props) {
	}

	@Override
	public List<JID> getNodesForJid(JID jid) {
		Collections.rotate(cl_nodes_list, 1);
		return cl_nodes_list;
	}

	@Override
	public void nodeConnected(JID jid) {
		cl_nodes_list.add(jid);
		log.fine("Cluster nodes: " + cl_nodes_list.toString());
	}

	@Override
	public void nodeDisconnected(JID jid) {
		cl_nodes_list.remove(jid);
		log.fine("Cluster nodes: " + cl_nodes_list.toString());
	}

	@Override
	public void usersConnected(JID sm, Queue<Packet> results, JID ... jid) {
	}

	@Override
	public void userDisconnected(JID sm, Queue<Packet> results, JID jid) {
	}

	@Override
	public List<JID> getAllNodes() {
		return cl_nodes_list;
	}

	@Override
	public boolean needsSync() {
		return false;
	}

	@Override
	public void getStatistics(StatisticsList list) {	}

	@Override
	public boolean hasCompleteJidsInfo() {
		return false;
	}

	@Override
	public boolean containsJid(JID jid) {
		return false;
	}

	@Override
	public JID[] getConnectionIdsForJid(JID jid) {
		return null;
	}

//	@Override
//	public void init(String smName) {
//		this.smName = smName;
//	}

}<commit_msg>Code formatting changes only.<commit_after>/*
 * Tigase Jabber/XMPP Server
 * Copyright (C) 2004-2008 "<NAME>" <<EMAIL>>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, version 3 of the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. Look for COPYING file in the top folder.
 * If not, see http://www.gnu.org/licenses/.
 *
 * $Rev$
 * Last modified by $Author$
 * $Date$
 */

package tigase.cluster.strategy;

//~--- non-JDK imports --------------------------------------------------------

import tigase.cluster.ClusteringStrategyIfc;

import tigase.server.Packet;

import tigase.stats.StatisticsList;

import tigase.xmpp.JID;

//~--- JDK imports ------------------------------------------------------------

import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

//~--- classes ----------------------------------------------------------------

/**
 * Created: May 13, 2009 9:53:44 AM
 *
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 * @version $Rev$
 */
public class SMNonCachingAllNodes implements ClusteringStrategyIfc {

	/**
	 * Variable <code>log</code> is a class logger.
	 */
	private static final Logger log = Logger.getLogger(SMNonCachingAllNodes.class.getName());

	//~--- fields ---------------------------------------------------------------

	// private Set<String> cluster_nodes = new ConcurrentSkipListSet<String>();
	private List<JID> cl_nodes_list = new CopyOnWriteArrayList<JID>();

	// private String smName = null;

	//~--- methods --------------------------------------------------------------

	/**
	 * Method description
	 *
	 *
	 * @param jid
	 *
	 * @return
	 */
	@Override
	public boolean containsJid(JID jid) {
		return false;
	}

	//~--- get methods ----------------------------------------------------------

	/**
	 * Method description
	 *
	 *
	 * @return
	 */
	@Override
	public List<JID> getAllNodes() {
		return cl_nodes_list;
	}

	/**
	 * Method description
	 *
	 *
	 * @param jid
	 *
	 * @return
	 */
	@Override
	public JID[] getConnectionIdsForJid(JID jid) {
		return null;
	}

	/**
	 * Method description
	 *
	 *
	 * @param params
	 *
	 * @return
	 */
	@Override
	public Map<String, Object> getDefaults(Map<String, Object> params) {
		return null;
	}

	/**
	 * Method description
	 *
	 *
	 * @param jid
	 *
	 * @return
	 */
	@Override
	public List<JID> getNodesForJid(JID jid) {
		Collections.rotate(cl_nodes_list, 1);

		return cl_nodes_list;
	}

	/**
	 * Method description
	 *
	 *
	 * @param list
	 */
	@Override
	public void getStatistics(StatisticsList list) {}

	/**
	 * Method description
	 *
	 *
	 * @return
	 */
	@Override
	public boolean hasCompleteJidsInfo() {
		return false;
	}

	//~--- methods --------------------------------------------------------------

	/**
	 * Method description
	 *
	 *
	 * @return
	 */
	@Override
	public boolean needsSync() {
		return false;
	}

	/**
	 * Method description
	 *
	 *
	 * @param jid
	 */
	@Override
	public void nodeConnected(JID jid) {
		cl_nodes_list.add(jid);
		log.log(Level.FINE, "Cluster nodes: {0}", cl_nodes_list.toString());
	}

	/**
	 * Method description
	 *
	 *
	 * @param jid
	 */
	@Override
	public void nodeDisconnected(JID jid) {
		cl_nodes_list.remove(jid);
		log.log(Level.FINE, "Cluster nodes: {0}", cl_nodes_list.toString());
	}

	//~--- set methods ----------------------------------------------------------

	/**
	 * Method description
	 *
	 *
	 * @param props
	 */
	@Override
	public void setProperties(Map<String, Object> props) {}

	//~--- methods --------------------------------------------------------------

	/**
	 * Method description
	 *
	 *
	 * @param sm
	 * @param results
	 * @param jid
	 */
	@Override
	public void userDisconnected(JID sm, Queue<Packet> results, JID jid) {}

	/**
	 * Method description
	 *
	 *
	 * @param sm
	 * @param results
	 * @param jid
	 */
	@Override
	public void usersConnected(JID sm, Queue<Packet> results, JID... jid) {}

//@Override
//public void init(String smName) {
//  this.smName = smName;
//}
}


//~ Formatted in Sun Code Convention


//~ Formatted by Jindent --- http://www.jindent.com
{'fraction_non_alphanumeric': 0.18744228993536471, 'fraction_numerical': 0.005803983643318823, 'mean_word_length': 2.5764150943396227, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 3, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3955498', 'n_tokens_mistral': 2489, 'n_tokens_neox': 2291, 'n_words': 656}