public SqlServerWithExternalBlobDataProvider(string connectionString) : base(connectionString)
        {
            _blobSetLocks = new LockSet();

            var externalBlobStorageProviderType = Configuration.Settings.Media.ExternalBlobStorageProviderType;

            if (string.IsNullOrWhiteSpace(externalBlobStorageProviderType))
            {
                Log.Info("ExternalBlobStorageProviderType isn't configured. So, using the Sitecore default provider.", this);
                _externalBlobStorageProviderConfigured = false;
                return;
            }

            try
            {
                Log.Info($"Initializing ExternalBlobStorageProviderType using {externalBlobStorageProviderType}", this);

                _blobStorageProvider = ReflectionUtil.CreateObject(externalBlobStorageProviderType) as IBlobStorageProvider;
                if (_blobStorageProvider == null)
                {
                    Log.Error($"Unable to create IBlobStorageProvider of type {externalBlobStorageProviderType}. So, using the Sitecore default provider.", this);
                    _externalBlobStorageProviderConfigured = false;
                    return;
                }

                _externalBlobStorageProviderConfigured = true;
            }
            catch (Exception ex)
            {
                Log.Error($"Unable to initialize ExternalBlobStorageProviderType {externalBlobStorageProviderType}. So, using the Sitecore default provider.", ex, this);
                _externalBlobStorageProviderConfigured = false;
            }
        }
Ejemplo n.º 2
0
        public SqlServerWithExternalBlobDataProvider(string connectionString) : base(connectionString)
        {
            _blobLockSet = new LockSet();

            if (string.IsNullOrWhiteSpace(BlobManagerHelper.BlobManagerType))
            {
                Log.Error("ExternalBlobDataProvider not configured. Using Sitecore default.", this);
                _configured = false;
                return;
            }
            try
            {
                Log.Info($"Initializing ExternalBlobDataProvider using {BlobManagerHelper.BlobManagerType}", this);
                _blobManager = ReflectionUtil.CreateObject(BlobManagerHelper.BlobManagerType) as IBlobManager;
                if (_blobManager == null)
                {
                    Log.Error($"Unable to create IBlobManager of type {BlobManagerHelper.BlobManagerType}. Using Sitecore default.", this);
                    _configured = false;
                    return;
                }
                _blobManager.Initialize();
                _configured = true;
            }
            catch (Exception ex)
            {
                Log.Error($"Unable to initialize ExternalBlobDataProvider {BlobManagerHelper.BlobManagerType}. Using Sitecore default", ex, this);
                _configured = false;
            }
        }
Ejemplo n.º 3
0
        public void AcquireImmediately()
        {
            var lockSet = new LockSet <string>();

            using (var handle = lockSet.TryAcquire("key1"))
            {
                handle.Should().NotBeNull();
            }
        }
Ejemplo n.º 4
0
        public async Task AcquireImmediatelyNotBlockedAndReturnsNullWhenKeyHeld()
        {
            var lockSet = new LockSet <string>();

            using (await lockSet.AcquireAsync("key1"))
            {
                using (var handle = lockSet.TryAcquire("key1"))
                {
                    handle.Should().BeNull();
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="store"></param>
        /// <param name="context"></param>
        /// <param name="maxNodesBound"></param>
        /// <param name="positionCache"></param>
        public MCTSTree(MCTSNodeStore store, MCTSIterator context,
                        int maxNodesBound, int estimatedNumNodes,
                        PositionEvalCache positionCache)
        {
            if (context.ParamsSearch.DrawByRepetitionLookbackPlies > MAX_LENGTH_POS_HISTORY)
            {
                throw new Exception($"DrawByRepetitionLookbackPlies exceeds maximum length of {MAX_LENGTH_POS_HISTORY}");
            }

            Store         = store;
            Context       = context;
            PositionCache = positionCache;

            ChildCreateLocks = new LockSet(128);

            const int ANNOTATION_MIN_CACHE_SIZE = 50_000;
            int       annotationCacheSize       = Math.Min(maxNodesBound, context.ParamsSearch.Execution.NodeAnnotationCacheSize);

            if (annotationCacheSize < ANNOTATION_MIN_CACHE_SIZE &&
                annotationCacheSize < maxNodesBound)
            {
                throw new Exception($"NODE_ANNOTATION_CACHE_SIZE is below minimum size of {ANNOTATION_MIN_CACHE_SIZE}");
            }

            if (maxNodesBound <= annotationCacheSize && !context.ParamsSearch.TreeReuseEnabled)
            {
                // We know with certainty the maximum size, and it will fit inside the cache
                // without purging needed - so just use a simple fixed size cache
                cache = new MCTSNodeCacheArrayFixed(this, maxNodesBound);
            }
            else
            {
                cache = new MCTSNodeCacheArrayPurgeableSet(this, annotationCacheSize, estimatedNumNodes);
            }

            // Populate EncodedPriorPositions with encoded boards
            // corresponding to possible prior moves (before the root of this search)
            EncodedPriorPositions = new List <EncodedPositionBoard>();
            Position[] priorPositions = new Position[9];

            // Get prior positions (last position has highest index)
            priorPositions = PositionHistoryGatherer.DoGetHistoryPositions(PriorMoves, priorPositions, 0, 8, false).ToArray();


            for (int i = priorPositions.Length - 1; i >= 0; i--)
            {
                EncodedPositionBoard thisBoard = EncodedPositionBoard.GetBoard(in priorPositions[i], priorPositions[i].MiscInfo.SideToMove, false);
                EncodedPriorPositions.Add(thisBoard);
            }
        }
 public BlobTransferer(string connectionString, IBlobManager blobManager)
 {
     _connectionString = connectionString;
     _blobManager      = blobManager;
     _blobLockSet      = new LockSet();
 }
Ejemplo n.º 7
0
 public ValueTask <IDisposable> Lock(CancellationToken cancellationToken = default)
 => LockSet.Lock(Key, cancellationToken);
 public SqlServerDataProviderWithAzureStorage(string connectionString) : base(connectionString)
 {
     _blobSetLocks   = new LockSet();
     StorageProvider = new AzureBlobStorageProvider(Settings.Media.AzureBlobStorage.StorageConnectionString, Settings.Media.AzureBlobStorage.StorageContainerName);
 }