コード例 #1
0
ファイル: HashMapBucket.cs プロジェクト: javithalion/NCache
 public HashMapBucket(Address address, int id)
 {
     _tempAddress = _permanentAddress = address;
     _bucketId = id;
     _stateTxfrLatch = new Latch(BucketStatus.Functional);
 }
コード例 #2
0
        /// <summary>
        /// Method that allows the object to initialize itself. Passes the property map down 
        /// the object hierarchy so that other objects may configure themselves as well..
        /// </summary>
        /// <param name="cacheSchemes">collection of cache schemes (config properties).</param>
        /// <param name="properties">properties collection for this cache.</param>
        public override void Initialize(IDictionary cacheClasses, IDictionary properties, bool twoPhaseInitialization)
        {
            if (properties == null)
                throw new ArgumentNullException("properties");

            try
            {
                base.Initialize(cacheClasses, properties);

                IDictionary frontCacheProps = ConfigHelper.GetCacheScheme(cacheClasses, properties, "internal-cache");
                string cacheType = Convert.ToString(frontCacheProps["type"]).ToLower();
                if (cacheType.CompareTo("local-cache") == 0)
                {
                    _internalCache =
                        CacheBase.Synchronized(new HashedLocalCache(cacheClasses, this, frontCacheProps, this, _context,
                            false));
                }
                else
                {
                    throw new ConfigurationException("invalid or non-local class specified in partitioned cache");
                }

                if (properties.Contains("data-affinity"))
                {
                    _dataAffinity = (IDictionary) properties["data-affinity"];
                }

                _distributionMgr = new DistributionManager(_autoBalancingThreshold, _internalCache.MaxSize);
                _distributionMgr.NCacheLog = Context.NCacheLog;

                InternalCache.BucketSize = _distributionMgr.BucketSize;

                _stats.Nodes = ArrayList.Synchronized(new ArrayList());

                _initialJoiningStatusLatch = new Latch();

                InitializeCluster(properties, Name, MCAST_DOMAIN,
                    new Identity(true, (_context.Render != null ? _context.Render.Port : 0),
                        (_context.Render != null ? _context.Render.IPAddress : null)), twoPhaseInitialization, false);
                _stats.GroupName = Cluster.ClusterName;
                _distributionMgr.LocalAddress = LocalAddress;

                postInstrumentatedData(_stats, Name);

                //Wait for the completion of installation of new view 
                if (!twoPhaseInitialization)
                {
                    _initialJoiningStatusLatch.WaitForAny(NodeStatus.Running);
                    DetermineClusterStatus();
                    _statusLatch.SetStatusBit(NodeStatus.Running, NodeStatus.Initializing);
                    AnnouncePresence(true);
                }

                for (int i = 0; i < confirmClusterStartUP; i++)
                {
                    ConfirmClusterStartUP(false, i + 1);
                }

                HasStarted();
            }
            catch (ConfigurationException)
            {
                Dispose();
                throw;
            }
            catch (Exception e)
            {
                Dispose();
                throw new ConfigurationException("Configuration Error: " + e.Message, e);
            }
        }
コード例 #3
0
ファイル: HashMapBucket.cs プロジェクト: javithalion/NCache
        void ICompactSerializable.Deserialize(CompactReader reader)
        {
            _bucketId = reader.ReadInt32();
            _tempAddress = (Address)reader.ReadObject();
            _permanentAddress = (Address)reader.ReadObject();
            byte status = reader.ReadByte();
            _stateTxfrLatch = new Latch(status);

        }