Пример #1
0
        protected override bool CreateCollectionInternal(CollectionConfiguration configuration, NodeContext nodeContext, bool isNew)
        {
            if (_collections.ContainsKey(configuration.CollectionName))
            {
                return(false);
            }
            lock (Collections)
            {
                ICollectionStore collection;

                collection           = new BaseCollection(_dbContext, nodeContext);
                collection.ShardName = _nodeContext.LocalShardName;
                bool success = collection.Initialize(configuration, _queryResultManager, this, null);
                if (success)
                {
                    //    // set status running incase of internal collections
                    //   collection.Status.SetStatusBit(CollectionStatus.RUNNING, CollectionStatus.INITIALIZING);
                    _collections[collection.Name] = collection;
                    //    if (configuration.CollectionType.Equals(CollectionType.CappedCollection.ToString()))
                    //        ((CappedCollection) collection).PopulateData();
                }
                return(success);
            }

            /*if (_collections.ContainsKey(configuration.CollectionName))
             *  return false;
             * if (_dbContext.StorageManager.CreateCollection(configuration.CollectionName))
             * {
             *  ICollectionStore collection = new BaseCollection(_dbContext, nodeContext);
             *  bool success = collection.Initialize(configuration, _queryResultManager, this);
             *  if (success)
             *      _collections[collection.Name] = collection;
             *  return success;
             * }
             * return false;*/
        }