/// <exception cref="System.Exception"></exception>
        public virtual bool TryLock(long time, TimeUnit?unit)
        {
            var request = LockTryLockCodec.EncodeRequest(GetName(), ThreadUtil.GetThreadId(), long.MaxValue,
                                                         GetTimeInMillis(time, unit));

            return(Invoke(request, m => LockTryLockCodec.DecodeResponse(m).response));
        }
        public void Unlock(TKey key)
        {
            var keyData = ToData(key);
            var request = MapUnlockCodec.EncodeRequest(GetName(), keyData, ThreadUtil.GetThreadId(), _lockReferenceIdGenerator.GetNextReferenceId());

            Invoke(request, keyData);
        }
        public V Get(object key)
        {
            var keyData = ToData(key);

            if (_nearCache != null)
            {
                var cached = _nearCache.Get(keyData);
                if (cached != null)
                {
                    if (cached.Equals(ClientNearCache.NullObject))
                    {
                        return(default(V));
                    }
                    return((V)cached);
                }
            }
            var request = MapGetCodec.EncodeRequest(GetName(), keyData, ThreadUtil.GetThreadId());
            var result  = Invoke(request, keyData);

            if (_nearCache != null)
            {
                _nearCache.Put(keyData, result);
            }
            return(ToObject <V>(MapGetCodec.DecodeResponse(result).response));
        }
示例#4
0
        protected virtual object GetInternal(IData keyData)
        {
            var request = MapGetCodec.EncodeRequest(GetName(), keyData, ThreadUtil.GetThreadId());
            var result  = Invoke(request, keyData);

            return(MapGetCodec.DecodeResponse(result).response);
        }
        public void Unlock(K key)
        {
            var keyData = ToData(key);
            var request = MapUnlockCodec.EncodeRequest(GetName(), keyData, ThreadUtil.GetThreadId());

            Invoke(request, keyData);
        }
        public virtual bool ContainsKey(TKey key)
        {
            var keyData = ToData(key);
            var request = MultiMapContainsKeyCodec.EncodeRequest(GetName(), keyData, ThreadUtil.GetThreadId());

            return(Invoke(request, keyData, m => MultiMapContainsKeyCodec.DecodeResponse(m).response));
        }
        public virtual void Lock(long leaseTime, TimeUnit?timeUnit)
        {
            var request = LockLockCodec.EncodeRequest(GetName(), GetTimeInMillis(leaseTime, timeUnit),
                                                      ThreadUtil.GetThreadId());

            Invoke(request);
        }
示例#8
0
        protected virtual TValue RemoveInternal(IData keyData)
        {
            var request       = MapRemoveCodec.EncodeRequest(GetName(), keyData, ThreadUtil.GetThreadId());
            var clientMessage = Invoke(request, keyData);

            return(ToObject <TValue>(MapRemoveCodec.DecodeResponse(clientMessage).response));
        }
        public virtual int ValueCount(TKey key)
        {
            var keyData = ToData(key);
            var request = MultiMapValueCountCodec.EncodeRequest(GetName(), keyData, ThreadUtil.GetThreadId());

            return(Invoke(request, keyData, m => MultiMapValueCountCodec.DecodeResponse(m).response));
        }
示例#10
0
        public virtual ICollection <TValue> Get(TKey key)
        {
            var keyData = ToData(key);
            var request = MultiMapGetCodec.EncodeRequest(GetName(), keyData, ThreadUtil.GetThreadId());
            var list    = Invoke(request, keyData, m => MultiMapGetCodec.DecodeResponse(m).response);

            return(new ReadOnlyLazyList <TValue, IData>(list, GetContext().GetSerializationService()));
        }
        /// <exception cref="System.Exception"></exception>
        public bool TryLock(K key, long time, TimeUnit timeunit, long leaseTime, TimeUnit leaseUnit)
        {
            var keyData = ToData(key);
            var request = MapTryLockCodec.EncodeRequest(GetName(), keyData, ThreadUtil.GetThreadId(),
                                                        leaseUnit.ToMillis(leaseTime), timeunit.ToMillis(time));

            return(Invoke(request, keyData, m => MapTryLockCodec.DecodeResponse(m).response));
        }
        public void Delete(object key)
        {
            var keyData = ToData(key);
            var request = MapDeleteCodec.EncodeRequest(GetName(), keyData, ThreadUtil.GetThreadId());

            InvalidateNearCacheEntry(keyData);
            Invoke(request, keyData);
        }
示例#13
0
        public void Lock(TKey key, long leaseTime, TimeUnit timeUnit)
        {
            var keyData = ToData(key);
            var request = MapLockCodec.EncodeRequest(GetName(), keyData, ThreadUtil.GetThreadId(), timeUnit.ToMillis(leaseTime),
                                                     _lockReferenceIdGenerator.GetNextReferenceId());

            Invoke(request, keyData);
        }
示例#14
0
        protected virtual void SetInternal(IData keyData, TValue value, long ttl, TimeUnit timeunit)
        {
            var valueData = ToData(value);
            var request   =
                MapSetCodec.EncodeRequest(GetName(), keyData, valueData, ThreadUtil.GetThreadId(), timeunit.ToMillis(ttl));

            Invoke(request, keyData);
        }
        public virtual bool Put(TKey key, TValue value)
        {
            var keyData   = ToData(key);
            var valueData = ToData(value);
            var request   = MultiMapPutCodec.EncodeRequest(Name, keyData, valueData, ThreadUtil.GetThreadId());

            return(Invoke(request, keyData, m => MultiMapPutCodec.DecodeResponse(m).Response));
        }
        public void Lock(K key, long leaseTime, TimeUnit timeUnit)
        {
            var keyData = ToData(key);
            var request = MapLockCodec.EncodeRequest(GetName(), keyData, ThreadUtil.GetThreadId(),
                                                     timeUnit.ToMillis(leaseTime));

            Invoke(request, keyData);
        }
        public virtual ICollection <TValue> Get(TKey key)
        {
            var keyData = ToData(key);
            var request = MultiMapGetCodec.EncodeRequest(GetName(), keyData, ThreadUtil.GetThreadId());
            var list    = Invoke(request, keyData, m => MultiMapGetCodec.DecodeResponse(m).response);

            return(ToList <TValue>(list));
        }
        public virtual void Unlock(K key)
        {
            ThrowExceptionIfNull(key);

            var keyData = ToData(key);
            var request = MultiMapUnlockCodec.EncodeRequest(GetName(), keyData, ThreadUtil.GetThreadId());

            Invoke(request, keyData);
        }
示例#19
0
        protected virtual bool TryRemoveInternal(IData keyData, long timeout, TimeUnit timeunit)
        {
            var request =
                MapTryRemoveCodec.EncodeRequest(GetName(), keyData, ThreadUtil.GetThreadId(), timeunit.ToMillis(timeout));
            var result   = Invoke(request, keyData);
            var response = MapTryRemoveCodec.DecodeResponse(result).response;

            return(response);
        }
        public virtual void Unlock(TKey key)
        {
            ThrowExceptionIfNull(key);

            var keyData = ToData(key);
            var request = MultiMapUnlockCodec.EncodeRequest(GetName(), keyData, ThreadUtil.GetThreadId(), _lockReferenceIdGenerator.GetNextReferenceId());

            Invoke(request, keyData);
        }
        public virtual ICollection <V> Remove(object key)
        {
            var keyData = ToData(key);

            var request = MultiMapRemoveCodec.EncodeRequest(GetName(), keyData, ThreadUtil.GetThreadId());
            var list    = Invoke(request, keyData, m => MultiMapRemoveCodec.DecodeResponse(m).list);

            return(ToList <V>(list));
        }
        public virtual ICollection <TValue> Remove(object key)
        {
            var keyData = ToData(key);

            var request = MultiMapRemoveCodec.EncodeRequest(Name, keyData, ThreadUtil.GetThreadId());
            var list    = Invoke(request, keyData, m => MultiMapRemoveCodec.DecodeResponse(m).Response);

            return(new ReadOnlyLazyList <TValue, IData>(list, Client.SerializationService));
        }
        public bool Evict(K key)
        {
            var keyData          = ToData(key);
            var request          = MapEvictCodec.EncodeRequest(GetName(), keyData, ThreadUtil.GetThreadId());
            var response         = Invoke(request, keyData);
            var resultParameters = MapEvictCodec.DecodeResponse(response);

            return(resultParameters.response);
        }
示例#24
0
        public virtual void Lock(TKey key, long leaseTime, TimeUnit timeUnit)
        {
            ThrowExceptionIfNull(key);

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

            Invoke(request, keyData);
        }
示例#25
0
        protected virtual Task <TValue> RemoveAsyncInternal(IData keyData)
        {
            var request = MapRemoveCodec.EncodeRequest(GetName(), keyData, ThreadUtil.GetThreadId());

            return(InvokeAsync(request, keyData, m =>
            {
                var response = MapRemoveCodec.DecodeResponse(m).response;
                return ToObject <TValue>(response);
            }));
        }
示例#26
0
        protected virtual TValue PutInternal(IData keyData, TValue value, long ttl, TimeUnit timeunit)
        {
            var valueData = ToData(value);
            var request   =
                MapPutCodec.EncodeRequest(GetName(), keyData, valueData, ThreadUtil.GetThreadId(), timeunit.ToMillis(ttl));
            var clientMessage = Invoke(request, keyData);
            var response      = MapPutCodec.DecodeResponse(clientMessage).response;

            return(ToObject <TValue>(response));
        }
        /// <exception cref="System.Exception"></exception>
        public virtual bool TryLock(K key, long timeout, TimeUnit timeunit, long leaseTime, TimeUnit leaseUnit)
        {
            ThrowExceptionIfNull(key);

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

            return(Invoke(request, keyData, m => MultiMapTryLockCodec.DecodeResponse(m).response));
        }
示例#28
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);
        }
        public V Remove(object key)
        {
            var keyData = ToData(key);
            var request = MapRemoveCodec.EncodeRequest(GetName(), keyData, ThreadUtil.GetThreadId());

            InvalidateNearCacheEntry(keyData);
            var clientMessage = Invoke(request, keyData);

            return(ToObject <V>(MapRemoveCodec.DecodeResponse(clientMessage).response));
        }
        public void Set(K key, V value, long ttl, TimeUnit timeunit)
        {
            var keyData   = ToData(key);
            var valueData = ToData(value);
            var request   = MapSetCodec.EncodeRequest(GetName(), keyData, valueData, ThreadUtil.GetThreadId(),
                                                      timeunit.ToMillis(ttl));

            InvalidateNearCacheEntry(keyData);
            Invoke(request, keyData);
        }