Ejemplo n.º 1
0
        private static ArrayList createServers(string l)
        {
            Global.Tokenizer tok = new Global.Tokenizer(l, ",");
            string           t;
            int        port;
            ArrayList  retval = new ArrayList();
            Hashtable  hosts  = new Hashtable();
            ServerNode node;
            int        j = 0;

            while (tok.HasMoreTokens())
            {
                try
                {
                    t = tok.NextToken();
                    string host = t.Substring(0, (t.IndexOf((char)'[')) - (0));
                    host = host.Trim();
                    port = Convert.ToInt32(t.Substring(t.IndexOf((char)'[') + 1, (t.IndexOf((char)']')) - (t.IndexOf((char)'[') + 1)));
                    node = new ServerNode(host);
                    retval.Add(node);
                    j++;
                }
                catch (FormatException ex)
                {
                    throw ex;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }

            return(retval);
        }
Ejemplo n.º 2
0
        /* -------------------------- Private methods ---------------------------- */



        /// <summary> Input is "daddy[8880],sindhu[8880],camille[5555]. Return List of IpAddresses</summary>
        private System.Collections.ArrayList createInitialHosts(System.String l)
        {
            Global.Tokenizer tok = new Global.Tokenizer(l, ",");
            System.String    t;
            Address          addr;
            int port;

            System.Collections.ArrayList retval = new System.Collections.ArrayList();
            System.Collections.Hashtable hosts  = new System.Collections.Hashtable();

            //to be removed later on
            while (tok.HasMoreTokens())
            {
                try
                {
                    t = tok.NextToken();

                    System.String host = t.Substring(0, (t.IndexOf((System.Char) '[')) - (0));
                    host = host.Trim();
                    port = System.Int32.Parse(t.Substring(t.IndexOf((System.Char) '[') + 1, (t.IndexOf((System.Char) ']')) - (t.IndexOf((System.Char) '[') + 1)));
                    hosts.Add(host, port);
                }
                catch (System.FormatException e)
                {
                    Stack.NCacheLog.Error("exeption is " + e);
                }
                catch (Exception e)
                {
                    Stack.NCacheLog.Error("TcpPing.createInitialHosts", "Error: " + e.ToString());

                    throw new Exception("Invalid initial members list");
                }
            }
            try
            {
                System.Collections.IDictionaryEnumerator ide;
                for (int i = 0; i < port_range; i++)
                {
                    ide = hosts.GetEnumerator();
                    while (ide.MoveNext())
                    {
                        port = Convert.ToInt32(ide.Value);
                        addr = new Address((String)ide.Key, port + i);
                        retval.Add(addr);
                    }
                }
            }
            catch (Exception ex)
            {
                Stack.NCacheLog.Error("TcpPing.CreateInitialHosts()", "Error :" + ex);
                throw new Exception("Invalid initial memebers list");
            }
            return(retval);
        }
Ejemplo n.º 3
0
        /// <summary> Get a string of the form "P1(config_str1):P2:P3(config_str3)" and return
        /// ProtocolConfigurations for it. That means, parse "P1(config_str1)", "P2" and
        /// "P3(config_str3)"
        /// </summary>
        /// <param name="config_str">Configuration string
        /// </param>
        /// <returns> Vector of ProtocolConfigurations
        /// </returns>
        public virtual System.Collections.ArrayList parseComponentStrings(string config_str, string delimiter)
        {
            System.Collections.ArrayList retval = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
            Global.Tokenizer             tok;
            string token;

            tok = new Global.Tokenizer(config_str, delimiter);
            while (tok.HasMoreTokens())
            {
                token = tok.NextToken();
                retval.Add(token);
            }

            return(retval);
        }
Ejemplo n.º 4
0
		/* -------------------------- Private methods ---------------------------- */
		


		/// <summary> Input is "daddy[8880],sindhu[8880],camille[5555]. Return List of IpAddresses</summary>
		private System.Collections.ArrayList createInitialHosts(System.String l)
		{
			Global.Tokenizer tok = new Global.Tokenizer(l, ",");
			System.String t;
			Address addr;
			int port;
			System.Collections.ArrayList retval = new System.Collections.ArrayList();
			System.Collections.Hashtable hosts = new System.Collections.Hashtable();

			//to be removed later on
			while (tok.HasMoreTokens())
			{
                try
                {
                    t = tok.NextToken();

                    System.String host = t.Substring(0, (t.IndexOf((System.Char)'[')) - (0));
                    host = host.Trim();
                    port = System.Int32.Parse(t.Substring(t.IndexOf((System.Char)'[') + 1, (t.IndexOf((System.Char)']')) - (t.IndexOf((System.Char)'[') + 1)));
                    hosts.Add(host, port);


                }
                catch (System.FormatException e)
                {
                    Stack.NCacheLog.Error("exeption is " + e);
                }
                catch (Exception e)
                {
                    Stack.NCacheLog.Error("TcpPing.createInitialHosts",   "Error: " + e.ToString());

                    throw new Exception("Invalid initial members list");
                }
			}
			try
			{
				System.Collections.IDictionaryEnumerator ide;
				for(int i = 0; i< port_range; i++)
				{
					ide = hosts.GetEnumerator();
					while(ide.MoveNext())
					{
						port = Convert.ToInt32(ide.Value);		
						addr = new Address((String)ide.Key, port + i);
						retval.Add(addr);
					}
				
				}
			}
			catch(Exception ex)
			{
                Stack.NCacheLog.Error("TcpPing.CreateInitialHosts()",   "Error :" + ex);
                throw new Exception("Invalid initial memebers list");
			}
			return retval;
		}
Ejemplo n.º 5
0
		/// <summary> Get a string of the form "P1(config_str1):P2:P3(config_str3)" and return
		/// ProtocolConfigurations for it. That means, parse "P1(config_str1)", "P2" and
		/// "P3(config_str3)"
		/// </summary>
		/// <param name="config_str">Configuration string
		/// </param>
		/// <returns> Vector of ProtocolConfigurations
		/// </returns>
		public virtual System.Collections.ArrayList parseComponentStrings(string config_str, string delimiter)
		{
			System.Collections.ArrayList retval = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
			Global.Tokenizer tok;
			string token;
			
			tok = new Global.Tokenizer(config_str, delimiter);
			while (tok.HasMoreTokens())
			{
				token = tok.NextToken();
				retval.Add(token);
			}
			
			return retval;
		}
Ejemplo n.º 6
0
		 private static ArrayList createServers(string l)
		 {
			Global.Tokenizer tok = new Global.Tokenizer(l, ",");
			string t;
			Address addr;
			int port;
			ArrayList retval = new ArrayList();
			Hashtable hosts = new Hashtable();
			ServerNode node;
	//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
			int j = 0;
			while (tok.HasMoreTokens())
			{
				try
				{
					t = tok.NextToken();
	//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
					string host = t.Substring(0, (t.IndexOf((char) '[')) - (0));
					host = host.Trim();
					port = Convert.ToInt32(t.Substring(t.IndexOf((char) '[') + 1, (t.IndexOf((char) ']')) - (t.IndexOf((char) '[') + 1)));
					node = new ServerNode(host);
					

					retval.Add(node);
	//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
					j++;

				}
                catch (FormatException ex)
				{
                    throw ex;
				}
				catch (Exception ex)
				{
                    throw ex;
				}
			}

			return retval;

		 }