Example #1
0
        public async Task <IReadOnlyCollection <bool> > ExistsAsync(IEnumerable <string> fullPaths, CancellationToken cancellationToken)
        {
            GenericValidation.CheckBlobFullPaths(fullPaths);

            var result = new List <bool>();

            using (ServiceFabricTransaction tx = GetTransaction())
            {
                IReliableDictionary <string, byte[]> coll = await OpenCollectionAsync().ConfigureAwait(false);

                foreach (string fullPath in fullPaths)
                {
                    bool exists = await coll.ContainsKeyAsync(tx.Tx, ToFullPath(fullPath)).ConfigureAwait(false);

                    result.Add(exists);
                }
            }
            return(result);
        }
Example #2
0
        public async Task <Stream> OpenReadAsync(string id, CancellationToken cancellationToken)
        {
            GenericValidation.CheckBlobFullPath(id);
            id = ToFullPath(id);

            using (ServiceFabricTransaction tx = GetTransaction())
            {
                IReliableDictionary <string, byte[]> coll = await OpenCollectionAsync().ConfigureAwait(false);

                ConditionalValue <byte[]> value = await coll.TryGetValueAsync(tx.Tx, id).ConfigureAwait(false);

                if (!value.HasValue)
                {
                    throw new StorageException(ErrorCode.NotFound, null);
                }

                return(new MemoryStream(value.Value));
            }
        }
Example #3
0
        public async Task <IEnumerable <bool> > ExistsAsync(IEnumerable <string> ids, CancellationToken cancellationToken)
        {
            GenericValidation.CheckBlobId(ids);

            var result = new List <bool>();

            using (ServiceFabricTransaction tx = GetTransaction())
            {
                IReliableDictionary <string, byte[]> coll = await OpenCollectionAsync();

                foreach (string id in ids)
                {
                    bool exists = await coll.ContainsKeyAsync(tx.Tx, ToId(id));

                    result.Add(exists);
                }
            }
            return(result);
        }
        protected override async Task <int> GetMessageCountAsync(IReliableState reliableState, ServiceFabricTransaction transaction)
        {
            IReliableQueue <byte[]> collection = (IReliableQueue <byte[]>)reliableState;

            long count = await collection.GetCountAsync(transaction.Tx).ConfigureAwait(false);

            return((int)count);
        }
 protected abstract Task <ConditionalValue <byte[]> > TryDequeueAsync(ServiceFabricTransaction tx, IReliableState collectionBase, CancellationToken cancellationToken);
 protected abstract Task <int> GetMessageCountAsync(IReliableState reliableState, ServiceFabricTransaction transaction);
 private void CloseTransaction(bool b)
 {
     //dispose on transaction is already called!
     _currentTransaction = null;
 }
Example #8
0
        protected override Task <int> GetMessageCountAsync(IReliableState reliableState, ServiceFabricTransaction transaction)
        {
            IReliableConcurrentQueue <byte[]> collection = (IReliableConcurrentQueue <byte[]>)reliableState;

            return(Task.FromResult((int)collection.Count));
        }