<commit_before>/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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 com.gemstone.gemfire.distributed;

import java.io.File;
import java.net.InetAddress;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.TimeUnit;

import com.gemstone.gemfire.CancelCriterion;
import com.gemstone.gemfire.LogWriter;
import com.gemstone.gemfire.StatisticsFactory;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.CacheFactory;
import com.gemstone.gemfire.cache.client.ClientCache;
import com.gemstone.gemfire.cache.client.ClientCacheFactory;
import com.gemstone.gemfire.distributed.internal.DistributionConfig;
import com.gemstone.gemfire.distributed.internal.DistributionManager;
import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
import com.gemstone.gemfire.internal.Assert;
import com.gemstone.gemfire.internal.ClassPathLoader;
import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
import com.gemstone.gemfire.internal.tcp.ConnectionTable;
import com.gemstone.gemfire.internal.util.IOUtils;
import com.gemstone.gemfire.memcached.GemFireMemcachedServer;
import com.gemstone.gemfire.redis.GemFireRedisServer;
import com.gemstone.gemfire.security.GemFireSecurityException;

/**
 * A "connection" to a GemFire distributed system.  A
 * <code>DistributedSystem</code> is created by invoking the {@link
 * #connect} method with a configuration as described <a
 * href="#configuration">below</a>.  A <code>DistributedSystem</code>
 * is used when calling {@link
 * com.gemstone.gemfire.cache.CacheFactory#create}.  This class should
 * not be confused with the {@link
 * com.gemstone.gemfire.admin.AdminDistributedSystem
 * AdminDistributedSystem} interface that is used for administering a
 * distributed system.
 *
 * <P>
 *
 * When a program connects to the distributed system, a "distribution
 * manager" is started in this VM and the other members of the
 * distributed system are located.  This discovery is performed
 * by contacting "locators"
 * running on a given host and port.  All DistributedSystems that are
 * configured to use the same same
 * locators are part of the same distributed system.
 *
 * <P>
 *
 * The current version of GemFire only supports creating one
 * <code>DistributedSystem</code> per virtual machine.  Attempts to
 * connect to multiple distributed systems (that is calling {@link
 * #connect} multiple times with different configuration
 * <code>Properties</code>) will result in an {@link
 * IllegalStateException} being thrown (if <code>connect</code> is
 * invoked multiple times with equivalent <code>Properties</code>,
 * then the same instance of <code>DistributedSystem</code> will be
 * returned).  A common practice is to connect to the distributed
 * system and store a reference to the <code>DistributedSystem</code>
 * object in a well-known location such as a <code>static</code>
 * variable.  This practice provides access to the
 * <code>DistributedSystem</code> slightly faster than invoking
 * <code>connect</code> multiple times.  Note that it is always
 * advisable to {@link #disconnect()} from the distributed system when a
 * program will no longer access it.  Disconnecting frees up certain
 * resources and allows your application to connect to a different
 * distributed system, if desirable.
 *
 * <P>
 *
 * <CENTER>
 * <B><a name="configuration">Configuration</a></B>
 * </CENTER>
 *
 * <P>
 *
 * There are a number of configuration properties that can be set when
 * a program {@linkplain #connect connects} to a distributed system.
 *
 * <P>
 *
 * <B>Distribution Configuration Properties</B>
 *
 * <dl>
 *   <a name="groups"><dt>groups</dt></a>
 *   <dd><U>Description</U>: Defines the list of groups this member belongs to.
 *   Use commas to separate group names.
 *   Note that anything defined by the roles gemfire property will also be considered a group.
 *   <dd><U>Default</U>: ""</dd>
 *   <dd><U>Since</U>: 7.0</dd>
 * </dl>
 * <dl>
 *   <a name="name"><dt>name</dt></a>
 *   <dd><U>Description</U>: Uniquely identifies a member in its distributed system.
 *   If two members with the same name try to join the same distributed system
 *   then the second join will fail.</dd>
 *   <dd><U>Default</U>: ""</dd>
 * </dl>

 * <dl>
 *   <a name="distributed-system-id"><dt>distributed-system-id</dt></a>
 *<dd> A number that uniquely identifies this distributed system, when
 * using the WAN gateway to share data between multiple distributed systems. This
 * setting is only required when using the WAN gateway in conjunction with
 * the Portable Data eXchange (PDX) serialization format.
 * 
 * If set, this setting must be the same for every member in this distributed
 * system. It must be different than the number in other distributed systems
 * that this one will connect to using the WAN.
 * 
 * -1 means no setting.</dd>
 * 
 *   <dd><U>Range</U>-1..255</dd>
 *   <dd><U>Default</U>: "-1"</dd>
 * </dl>
 *
 * <dl>
 *   <a name="mcast-port"><dt>mcast-port</dt></a>
 *   <dd><U>Description</U>: The port used for multicast networking.
 *   If zero, then multicast will be disabled and unicast messaging will
 *   be used.
 *   </dd>
 *   <dd><U>Default</U>: "0"</dd>
 * </dl>
 *
 * <dl>
 *   <a name="mcast-address"><dt>mcast-address</dt></a>
 *   <dd><U>Description</U>: The IP address used for multicast
 *   networking.  If mcast-port is zero, then mcast-address is
 *   ignored.
 *   </dd>
 *   <dd><U>Default</U>: "172.16.17.32"</dd>
 * </dl>
 * <dl>
 *   <a name="mcast-ttl"><dt>mcast-ttl</dt></a>
 *   <dd><U>Description</U>: Determines how far through your network
 *   the multicast packets used by GemFire will propagate.
 *   <dd><U>Default</U>: "32"</dd>
 *   <dd><U>Allowed values</U>: 0..255</dd>
 *   <dd><U>Since</U>: 4.1</dd>
 * </dl>
 * <dl>
 *   <a name="mcast-send-buffer-size"><dt>mcast-send-buffer-size</dt></a>
 *   <dd><U>Description</U>: Sets the size of the socket buffer used for
 *    outgoing multicast transmissions.
 *   <dd><U>Default</U>: "65535"</dd>
 *   <dd><U>Allowed values</U>: 2048..Operating System maximum</dd>
 *   <dd><U>Since</U>: 5.0</dd>
 * </dl>
 * <dl>
 *   <a name="mcast-recv-buffer-size"><dt>mcast-recv-buffer-size</dt></a>
 *   <dd><U>Description</U>: Sets the size of the socket buffer used for
 *    incoming multicast transmissions.  You should set this high if there will be
 *    high volumes of messages.
 *   <dd><U>Default</U>: "1048576"</dd>
 *   <dd><U>Allowed values</U>: 2048..Operating System maximum</dd>
 *   <dd><U>Since</U>: 5.0</dd>
 * </dl>
 * <dl>
 *   <a name="mcast-flow-control"><dt>mcast-flow-control</dt></a>
 *   <dd><U>Description</U>: Configures the flow-of-control protocol for
 *    multicast messaging.  There are three settings that are separated
 *    by commas:  byteAllowance (integer), rechargeThreshold (float) and
 *    rechargeBlockMs (integer).  The byteAllowance determines how many bytes
 *    can be sent without a recharge from other processes.  The rechargeThreshold
 *    tells receivers how low the sender's initial to remaining allowance
 *    ratio should be before sending a recharge.  The rechargeBlockMs
 *    tells the sender how long to wait for a recharge before explicitly
 *    requesting one.</dd>
 *   <dd><U>Default</U>: "1048576,0.25,5000"</dd>
 *   <dd><U>Allowed values</U>: 100000-maxInt, 0.1-0.5, 500-60000</dd>
 *   <dd><U>Since</U>: 5.0</dd>
 * </dl>
 *
 * <dl>
 *   <a name="udp-send-buffer-size"><dt>udp-send-buffer-size</dt></a>
 *   <dd><U>Description</U>: Sets the size of the socket buffer used for
 *    outgoing udp point-to-point transmissions.<commit_msg>deprecated the mcast-flow-control distributed-system property<commit_after>/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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 com.gemstone.gemfire.distributed;

import java.io.File;
import java.net.InetAddress;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.TimeUnit;

import com.gemstone.gemfire.CancelCriterion;
import com.gemstone.gemfire.LogWriter;
import com.gemstone.gemfire.StatisticsFactory;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.CacheFactory;
import com.gemstone.gemfire.cache.client.ClientCache;
import com.gemstone.gemfire.cache.client.ClientCacheFactory;
import com.gemstone.gemfire.distributed.internal.DistributionConfig;
import com.gemstone.gemfire.distributed.internal.DistributionManager;
import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
import com.gemstone.gemfire.internal.Assert;
import com.gemstone.gemfire.internal.ClassPathLoader;
import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
import com.gemstone.gemfire.internal.tcp.ConnectionTable;
import com.gemstone.gemfire.internal.util.IOUtils;
import com.gemstone.gemfire.memcached.GemFireMemcachedServer;
import com.gemstone.gemfire.redis.GemFireRedisServer;
import com.gemstone.gemfire.security.GemFireSecurityException;

/**
 * A "connection" to a GemFire distributed system.  A
 * <code>DistributedSystem</code> is created by invoking the {@link
 * #connect} method with a configuration as described <a
 * href="#configuration">below</a>.  A <code>DistributedSystem</code>
 * is used when calling {@link
 * com.gemstone.gemfire.cache.CacheFactory#create}.  This class should
 * not be confused with the {@link
 * com.gemstone.gemfire.admin.AdminDistributedSystem
 * AdminDistributedSystem} interface that is used for administering a
 * distributed system.
 *
 * <P>
 *
 * When a program connects to the distributed system, a "distribution
 * manager" is started in this VM and the other members of the
 * distributed system are located.  This discovery is performed
 * by contacting "locators"
 * running on a given host and port.  All DistributedSystems that are
 * configured to use the same same
 * locators are part of the same distributed system.
 *
 * <P>
 *
 * The current version of GemFire only supports creating one
 * <code>DistributedSystem</code> per virtual machine.  Attempts to
 * connect to multiple distributed systems (that is calling {@link
 * #connect} multiple times with different configuration
 * <code>Properties</code>) will result in an {@link
 * IllegalStateException} being thrown (if <code>connect</code> is
 * invoked multiple times with equivalent <code>Properties</code>,
 * then the same instance of <code>DistributedSystem</code> will be
 * returned).  A common practice is to connect to the distributed
 * system and store a reference to the <code>DistributedSystem</code>
 * object in a well-known location such as a <code>static</code>
 * variable.  This practice provides access to the
 * <code>DistributedSystem</code> slightly faster than invoking
 * <code>connect</code> multiple times.  Note that it is always
 * advisable to {@link #disconnect()} from the distributed system when a
 * program will no longer access it.  Disconnecting frees up certain
 * resources and allows your application to connect to a different
 * distributed system, if desirable.
 *
 * <P>
 *
 * <CENTER>
 * <B><a name="configuration">Configuration</a></B>
 * </CENTER>
 *
 * <P>
 *
 * There are a number of configuration properties that can be set when
 * a program {@linkplain #connect connects} to a distributed system.
 *
 * <P>
 *
 * <B>Distribution Configuration Properties</B>
 *
 * <dl>
 *   <a name="groups"><dt>groups</dt></a>
 *   <dd><U>Description</U>: Defines the list of groups this member belongs to.
 *   Use commas to separate group names.
 *   Note that anything defined by the roles gemfire property will also be considered a group.
 *   <dd><U>Default</U>: ""</dd>
 *   <dd><U>Since</U>: 7.0</dd>
 * </dl>
 * <dl>
 *   <a name="name"><dt>name</dt></a>
 *   <dd><U>Description</U>: Uniquely identifies a member in its distributed system.
 *   If two members with the same name try to join the same distributed system
 *   then the second join will fail.</dd>
 *   <dd><U>Default</U>: ""</dd>
 * </dl>

 * <dl>
 *   <a name="distributed-system-id"><dt>distributed-system-id</dt></a>
 *<dd> A number that uniquely identifies this distributed system, when
 * using the WAN gateway to share data between multiple distributed systems. This
 * setting is only required when using the WAN gateway in conjunction with
 * the Portable Data eXchange (PDX) serialization format.
 * 
 * If set, this setting must be the same for every member in this distributed
 * system. It must be different than the number in other distributed systems
 * that this one will connect to using the WAN.
 * 
 * -1 means no setting.</dd>
 * 
 *   <dd><U>Range</U>-1..255</dd>
 *   <dd><U>Default</U>: "-1"</dd>
 * </dl>
 *
 * <dl>
 *   <a name="mcast-port"><dt>mcast-port</dt></a>
 *   <dd><U>Description</U>: The port used for multicast networking.
 *   If zero, then multicast will be disabled and unicast messaging will
 *   be used.
 *   </dd>
 *   <dd><U>Default</U>: "0"</dd>
 * </dl>
 *
 * <dl>
 *   <a name="mcast-address"><dt>mcast-address</dt></a>
 *   <dd><U>Description</U>: The IP address used for multicast
 *   networking.  If mcast-port is zero, then mcast-address is
 *   ignored.
 *   </dd>
 *   <dd><U>Default</U>: "172.16.17.32"</dd>
 * </dl>
 * <dl>
 *   <a name="mcast-ttl"><dt>mcast-ttl</dt></a>
 *   <dd><U>Description</U>: Determines how far through your network
 *   the multicast packets used by GemFire will propagate.
 *   <dd><U>Default</U>: "32"</dd>
 *   <dd><U>Allowed values</U>: 0..255</dd>
 *   <dd><U>Since</U>: 4.1</dd>
 * </dl>
 * <dl>
 *   <a name="mcast-send-buffer-size"><dt>mcast-send-buffer-size</dt></a>
 *   <dd><U>Description</U>: Sets the size of the socket buffer used for
 *    outgoing multicast transmissions.
 *   <dd><U>Default</U>: "65535"</dd>
 *   <dd><U>Allowed values</U>: 2048..Operating System maximum</dd>
 *   <dd><U>Since</U>: 5.0</dd>
 * </dl>
 * <dl>
 *   <a name="mcast-recv-buffer-size"><dt>mcast-recv-buffer-size</dt></a>
 *   <dd><U>Description</U>: Sets the size of the socket buffer used for
 *    incoming multicast transmissions.  You should set this high if there will be
 *    high volumes of messages.
 *   <dd><U>Default</U>: "1048576"</dd>
 *   <dd><U>Allowed values</U>: 2048..Operating System maximum</dd>
 *   <dd><U>Since</U>: 5.0</dd>
 * </dl>
 * <dl>
 *   <a name="mcast-flow-control"><dt>mcast-flow-control</dt></a>
 *   <dd><U>Description</U>: Configures the flow-of-control protocol for
 *    multicast messaging.  There are three settings that are separated
 *    by commas:  byteAllowance (integer), rechargeThreshold (float) and
 *    rechargeBlockMs (integer).  The byteAllowance determines how many bytes
 *    can be sent without a recharge from other processes.  The rechargeThreshold
 *    tells receivers how low the sender's initial to remaining allowance
 *    ratio should be before sending a recharge.  The rechargeBlockMs
 *    tells the sender how long to wait for a recharge before explicitly
 *    requesting one.</dd>
 *   <dd><U>Deprecated</U>: as of 9.0 GemFire does not include a flow-of-control protocol for multicast messaging.</dd>
 *   <dd><U>Default</U>: "1048576,0.25,5000"</dd>
 *   <dd><U>Allowed values</U>: 100000-maxInt, 0.1-0.5, 500-60000</dd>
 *   <dd><U>Since</U>: 5.0</dd>
 * </dl>
 *
 * <dl>
 *   <a name="udp-send-buffer-size"><dt>udp-send-buffer-size</dt></a>
 *   <dd><U>Description</U>: Sets the size of the socket buffer used for
 *    outgoing udp point-to-point transmissions.
{'fraction_non_alphanumeric': 0.12782085406781624, 'fraction_numerical': 0.01053118851984724, 'mean_word_length': 4.086227192466157, 'pattern_counts': {'":': 0, '<': 417, '<?xml version=': 0, '>': 417, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 2, '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': '4673596', 'n_tokens_mistral': 5391, 'n_tokens_neox': 5189, 'n_words': 1735}