<commit_before>/*
 * Jicofo, the Jitsi Conference Focus.
 *
 * Copyright @ 2015 Atlassian Pty Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.jitsi.jicofo;

import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.event.*;
import net.java.sip.communicator.util.Logger;

import org.jitsi.assertions.*;
import org.jitsi.eventadmin.*;
import org.jitsi.jicofo.discovery.*;
import org.jitsi.jicofo.discovery.Version;
import org.jitsi.jicofo.event.*;
import org.jitsi.protocol.xmpp.*;
import org.jitsi.protocol.xmpp.SubscriptionListener;
import org.jitsi.util.*;

import org.jivesoftware.smack.packet.*;
import org.jivesoftware.smackx.pubsub.*;

import org.osgi.framework.*;

import java.util.*;
import java.util.concurrent.*;

/**
 * Class observes components available on XMPP domain, classifies them as JVB,
 * SIP gateway or Jirecon and notifies {@link JitsiMeetServices} whenever new
 * instance becomes available or goes offline.
 *
 * @author <NAME>
 */
public class ComponentsDiscovery
    implements RegistrationStateChangeListener
{
    /**
     * The logger
     */
    private final static Logger logger
        = Logger.getLogger(ComponentsDiscovery.class);

    /**
     * Re-discovers every 30 seconds.
     */
    private static final long DEFAULT_REDISCOVERY_INT = 30L * 1000L;

    /**
     * The name of configuration property which specifies how often XMPP
     * components re-discovery will be performed. Time interval in millis.
     */
    private final static String REDISCOVERY_INTERVAL_PNAME
        = "org.jitsi.jicofo.SERVICE_REDISCOVERY_INTERVAL";

    /**
     * {@link JitsiMeetServices} which is notified about new components
     * discovered or when one of currently running goes offline.
     */
    private final JitsiMeetServices meetServices;

    /**
     * Map of component features.
     */
    private Map<String, List<String>> itemMap = new HashMap<>();

    /**
     * Timer which runs re-discovery task.
     */
    private Timer rediscoveryTimer;

    /**
     * XMPP xmppDomain for which we're discovering service info.
     */
    private String xmppDomain;

    /**
     * The protocol service handler that provides XMPP service.
     */
    private ProtocolProviderHandler protocolProviderHandler;

    /**
     * Capabilities operation set used to discover services info.
     */
    private OperationSetSimpleCaps capsOpSet;

    /**
     * Detects video bridges based on stats published to PubSub node.
     */
    private ThroughPubSubDiscovery pubSubBridgeDiscovery;

    /**
     * The name of PubSub node where videobridges are publishing their stats.
     */
    private String statsPubSubNode;<commit_msg>fix: Uses a ConcurrentHashMap instead of HashMap.<commit_after>/*
 * Jicofo, the Jitsi Conference Focus.
 *
 * Copyright @ 2015 Atlassian Pty Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.jitsi.jicofo;

import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.event.*;
import net.java.sip.communicator.util.Logger;

import org.jitsi.assertions.*;
import org.jitsi.eventadmin.*;
import org.jitsi.jicofo.discovery.*;
import org.jitsi.jicofo.discovery.Version;
import org.jitsi.jicofo.event.*;
import org.jitsi.protocol.xmpp.*;
import org.jitsi.protocol.xmpp.SubscriptionListener;
import org.jitsi.util.*;

import org.jivesoftware.smack.packet.*;
import org.jivesoftware.smackx.pubsub.*;

import org.osgi.framework.*;

import java.util.*;
import java.util.concurrent.*;

/**
 * Class observes components available on XMPP domain, classifies them as JVB,
 * SIP gateway or Jirecon and notifies {@link JitsiMeetServices} whenever new
 * instance becomes available or goes offline.
 *
 * @author <NAME>
 */
public class ComponentsDiscovery
    implements RegistrationStateChangeListener
{
    /**
     * The logger
     */
    private final static Logger logger
        = Logger.getLogger(ComponentsDiscovery.class);

    /**
     * Re-discovers every 30 seconds.
     */
    private static final long DEFAULT_REDISCOVERY_INT = 30L * 1000L;

    /**
     * The name of configuration property which specifies how often XMPP
     * components re-discovery will be performed. Time interval in millis.
     */
    private final static String REDISCOVERY_INTERVAL_PNAME
        = "org.jitsi.jicofo.SERVICE_REDISCOVERY_INTERVAL";

    /**
     * {@link JitsiMeetServices} which is notified about new components
     * discovered or when one of currently running goes offline.
     */
    private final JitsiMeetServices meetServices;

    /**
     * Map of component features.
     */
    private Map<String, List<String>> itemMap = new ConcurrentHashMap<>();

    /**
     * Timer which runs re-discovery task.
     */
    private Timer rediscoveryTimer;

    /**
     * XMPP xmppDomain for which we're discovering service info.
     */
    private String xmppDomain;

    /**
     * The protocol service handler that provides XMPP service.
     */
    private ProtocolProviderHandler protocolProviderHandler;

    /**
     * Capabilities operation set used to discover services info.
     */
    private OperationSetSimpleCaps capsOpSet;

    /**
     * Detects video bridges based on stats published to PubSub node.
     */
    private ThroughPubSubDiscovery pubSubBridgeDiscovery;

    /**
     * The name of PubSub node where videobridges are publishing their stats.
     */
    private String statsPubSubNode;
{'fraction_non_alphanumeric': 0.08747697974217311, 'fraction_numerical': 0.004910988336402701, 'mean_word_length': 3.276246719160105, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '823918', 'n_tokens_mistral': 1893, 'n_tokens_neox': 1815, 'n_words': 605}