Exemplo n.º 1
0
        public void Initialize(IDictionary properties, string channelName,
            string domain, NodeIdentity identity,
            bool twoPhaseInitialization,bool isPor)
        {
            if (properties == null)
                throw new ArgumentNullException("properties");
            
            try
            {
                if (properties.Contains("op-timeout"))
                {
                    long val = Convert.ToInt64(properties["op-timeout"]);
                    if (val < 60) val = 60;
                    val = val * 1000;
                    Timeout = val;
                }
                if (properties.Contains("notification-priority"))
                {
                    string priority = Convert.ToString(properties["notification-priority"]);
                    if (priority.ToLower() == "normal")
                        _eventPriority = Priority.Normal;
                }

                IDictionary clusterProps = properties["cluster"] as IDictionary;
                string channelProps = ConfigHelper.GetClusterPropertyString(clusterProps, Timeout, isPor);

                string name = channelName != null? channelName.ToLower(): null ;
                if (clusterProps.Contains("group-id"))
                    name = Convert.ToString(clusterProps["group-id"]);
                if (clusterProps.Contains("sub-group-id"))
                {
                    _subgroupid = Convert.ToString(clusterProps["sub-group-id"]);
                    if (_subgroupid != null) _subgroupid = _subgroupid.ToLower();
                    identity.SubGroupName = _subgroupid;
                }
                // =======================================
                else
                    _subgroupid = name;
                // =======================================
                    this.PopulateClusterNodes(new Hashtable(clusterProps));

                if (name != null) name = name.ToLower();
                if (_subgroupid != null) _subgroupid = _subgroupid.ToLower();
                //A property or indexer may not be passed as an out or ref parameter.
                _channel = new GroupChannel(channelProps, _context.NCacheLog);

                Hashtable config = new Hashtable();
                config["additional_data"] = CompactBinaryFormatter.ToByteBuffer(identity, _context.SerializationContext);
                _channel.down(new Event(Event.CONFIG, config));

                _msgDisp = new MsgDispatcher(_channel, this, this, this, this, false, true);
                _channel.connect(name + domain, _subgroupid, identity.IsStartedAsMirror,twoPhaseInitialization);
                localIp = LocalAddress.IpAddress.ToString();
                _msgDisp.start();
            }
            catch (Exception e)
            {
                Dispose();
                throw new ConfigurationException("Configuration Error: " + e.ToString(), e);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Performs application-defined tasks associated with freeing, releasing, or 
 /// resetting unmanaged resources.
 /// </summary>
 public void Dispose()
 {
     if (_msgDisp != null)
     {
         _msgDisp.stop();
         _msgDisp = null;
     }
     if (_channel != null)
     {
         _channel.close();
         _channel = null;
     }
     if (_asynHandler != null)
     {
         _asynHandler.Dispose();
     }            
 }