コード例 #1
0
        public object ExecuteOnKey(TKey key, IEntryProcessor entryProcessor)
        {
            ValidationUtil.ThrowExceptionIfNull(key);
            var keyData = ToData(key);

            return(ExecuteOnKeyInternal(keyData, entryProcessor));
        }
コード例 #2
0
        public Task <object> SubmitToKey(TKey key, IEntryProcessor entryProcessor)
        {
            ValidationUtil.ThrowExceptionIfNull(key);
            var keyData = ToData(key);

            return(SubmitToKeyInternal(keyData, entryProcessor));
        }
コード例 #3
0
        public Task <long> AddAsync(T item, OverflowPolicy overflowPolicy)
        {
            ValidationUtil.ThrowExceptionIfNull(item, "Item cannot be null");

            var request = RingbufferAddCodec.EncodeRequest(GetName(), (int)OverflowPolicy.Overwrite, ToData(item));

            return(InvokeAsync(request, GetPartitionKey(), m => RingbufferAddCodec.DecodeResponse(m).response));
        }
コード例 #4
0
        public long Add(T item)
        {
            ValidationUtil.ThrowExceptionIfNull(item, "Item cannot be null");

            var request = RingbufferAddCodec.EncodeRequest(GetName(), (int)OverflowPolicy.Overwrite, ToData(item));

            return(Invoke(request, m => RingbufferAddCodec.DecodeResponse(m).response));
        }
コード例 #5
0
        public void Add(int index, T element)
        {
            ValidationUtil.ThrowExceptionIfNull(element);
            var value   = ToData(element);
            var request = ListAddWithIndexCodec.EncodeRequest(GetName(), index, value);

            Invoke(request);
        }
コード例 #6
0
        public override bool Add(T item)
        {
            ValidationUtil.ThrowExceptionIfNull(item);
            var value   = ToData(item);
            var request = SetAddCodec.EncodeRequest(GetName(), value);

            return(Invoke(request, m => SetAddCodec.DecodeResponse(m).response));
        }
コード例 #7
0
        public int LastIndexOf(T item)
        {
            ValidationUtil.ThrowExceptionIfNull(item);
            var value    = ToData(item);
            var request  = ListLastIndexOfCodec.EncodeRequest(GetName(), value);
            var response = Invoke(request);

            return(ListLastIndexOfCodec.DecodeResponse(response).response);
        }
コード例 #8
0
        public T Set(int index, T element)
        {
            ValidationUtil.ThrowExceptionIfNull(element);
            var value    = ToData(element);
            var request  = ListSetCodec.EncodeRequest(GetName(), index, value);
            var response = Invoke(request);

            return(ToObject <T>(ListSetCodec.DecodeResponse(response).response));
        }
コード例 #9
0
        public virtual void ForceUnlock(TKey key)
        {
            ValidationUtil.ThrowExceptionIfNull(key);

            var keyData = ToData(key);
            var request = MultiMapForceUnlockCodec.EncodeRequest(GetName(), keyData, _lockReferenceIdGenerator.GetNextReferenceId());

            Invoke(request, keyData);
        }
コード例 #10
0
        public virtual bool IsLocked(TKey key)
        {
            ValidationUtil.ThrowExceptionIfNull(key);

            var keyData = ToData(key);
            var request = MultiMapIsLockedCodec.EncodeRequest(GetName(), keyData);

            return(Invoke(request, keyData, m => MultiMapIsLockedCodec.DecodeResponse(m).response));
        }
コード例 #11
0
        public virtual void Lock(TKey key, long leaseTime, TimeUnit timeUnit)
        {
            ValidationUtil.ThrowExceptionIfNull(key);

            var keyData = ToData(key);
            var request = MultiMapLockCodec.EncodeRequest(GetName(), keyData, ThreadUtil.GetThreadId(),
                                                          timeUnit.ToMillis(leaseTime), _lockReferenceIdGenerator.GetNextReferenceId());

            Invoke(request, keyData);
        }
コード例 #12
0
        /// <exception cref="System.Exception"></exception>
        public virtual bool TryLock(TKey key, long timeout, TimeUnit timeunit, long leaseTime, TimeUnit leaseUnit)
        {
            ValidationUtil.ThrowExceptionIfNull(key);

            var keyData = ToData(key);
            var request = MultiMapTryLockCodec.EncodeRequest(GetName(), keyData, ThreadUtil.GetThreadId(),
                                                             leaseUnit.ToMillis(leaseTime),
                                                             timeunit.ToMillis(timeout), _lockReferenceIdGenerator.GetNextReferenceId());

            return(Invoke(request, keyData, m => MultiMapTryLockCodec.DecodeResponse(m).response));
        }
コード例 #13
0
        protected ISet <IData> ToDataSet <T>(ICollection <T> c)
        {
            ValidationUtil.ThrowExceptionIfNull(c);
            var valueSet = new HashSet <IData>();

            foreach (var o in c)
            {
                ValidationUtil.ThrowExceptionIfNull(o);
                valueSet.Add(ToData(o));
            }

            return(valueSet);
        }
コード例 #14
0
        protected IList <IData> ToDataList <T>(ICollection <T> c)
        {
            ValidationUtil.ThrowExceptionIfNull(c, "Collection cannot be null.");
            var values = new List <IData>(c.Count);

            foreach (var o in c)
            {
                ValidationUtil.ThrowExceptionIfNull(o, "Collection cannot contain null items.");
                values.Add(ToData(o));
            }

            return(values);
        }
コード例 #15
0
        public virtual void CopyTo(T[] array, int index)
        {
            ValidationUtil.ThrowExceptionIfNull(array);
            if (index < 0)
            {
                throw new IndexOutOfRangeException("Index cannot be negative.");
            }

            var all = GetAll();

            if ((array.Length - index) < all.Count)
            {
                throw new ArgumentException("The number of source elements is greater" +
                                            " than the available space from index to the end of the destination array.");
            }

            var i = index;

            foreach (var item in all)
            {
                array[i++] = item;
            }
        }
コード例 #16
0
        public virtual void Lock(TKey key)
        {
            ValidationUtil.ThrowExceptionIfNull(key);

            Lock(key, long.MaxValue, TimeUnit.Milliseconds);
        }