Beispiel #1
0
        internal void Monitor(object partitionKey)
        {
            int pk = (int)partitionKey;

            // flush VersionTables Queue
            VersionEntryRequest veReq = null;

            while ((this.VersionDb as PartitionedCassandraVersionDb).Active)
            {
                lock (this.rawPartitionedQueues[pk])
                {
                    if (this.rawPartitionedQueues[pk].Count > 0)
                    {
                        veReq = this.rawPartitionedQueues[pk].Dequeue();
                    }
                    else
                    {
                        System.Threading.Monitor.Wait(this.rawPartitionedQueues[pk]);
                    }
                }

                if (veReq != null)
                {
                    this.tableVisitors[pk].Invoke(veReq);
                    lock (veReq)
                    {
                        System.Threading.Monitor.Pulse(veReq);
                    }
                }
            }
        }
 public virtual void Invoke(Queue <VersionEntryRequest> reqQueue)
 {
     while (reqQueue.Count > 0)
     {
         VersionEntryRequest req = reqQueue.Dequeue();
         req.Accept(this);
     }
 }
        private string GetHashKey(VersionEntryRequest request)
        {
            string hashId = request.RecordKey.ToString();

            return(redisVersionDbMode == RedisVersionDbMode.Cluster
                ? RedisVersionDb.PACK_KEY(RedisVersionDb.VER_KEY_PREFIX, hashId)
                : hashId);
        }
Beispiel #4
0
        internal void EnqueueVersionEntryRequest(VersionEntryRequest req)
        {
            this.versionEntryVisitor.Invoke(req);
            RedisRequest redisReq = this.versionEntryVisitor.RedisReq;

            redisReq.ResponseVisitor = this.redisResponseVisitor;

            this.redisRequestQueue.Enqueue(redisReq);
        }
        public override void Invoke(Queue <VersionEntryRequest> reqQueue)
        {
            int reqCount = 0;

            while (reqQueue.Count > 0)
            {
                VersionEntryRequest req = reqQueue.Dequeue();
                req.Accept(this);
                reqCount++;
            }

            if (reqCount > 0)
            {
                this.clientPool.Flush(this.redisRequests, redisClient, reqCount);
            }
            this.reqIndex = 0;
        }
Beispiel #6
0
        internal override void EnqueueVersionEntryRequest(VersionEntryRequest req, int srcPartition = 0)
        {
            if (this.redisVersionDbMode == RedisVersionDbMode.Cluster)
            {
                this.requestQueues[srcPartition].Enqueue(req);
            }
            else
            {
                int pk = this.VersionDb.PhysicalPartitionByKey(req.RecordKey);

                while (Interlocked.CompareExchange(ref queueLatches[pk], 1, 0) != 0)
                {
                    ;
                }
                Queue <VersionEntryRequest> reqQueue = Volatile.Read(ref this.requestQueues[pk]);
                reqQueue.Enqueue(req);
                Interlocked.Exchange(ref queueLatches[pk], 0);
            }
        }
Beispiel #7
0
        internal override void EnqueueVersionEntryRequest(VersionEntryRequest req, int execPartition = 0)
        {
            this.tableVisitors[execPartition].Invoke(req);
            return;

            //////////////////////////////////////////////////

            int pid = this.VersionDb.PhysicalPartitionByKey(req.RecordKey);

            //while (Interlocked.CompareExchange(ref this.latches[pid], 1, 0) != 0) ;
            //partitionedQueues[pid].Enqueue(req, execPartition);
            //Interlocked.Exchange(ref this.latches[pid], 0);

            //
            //this.ccTasksCnt.Enqueue(pid);

            lock (this.rawPartitionedQueues[pid])
            {
                this.rawPartitionedQueues[pid].Enqueue(req);
                System.Threading.Monitor.Pulse(this.rawPartitionedQueues[pid]);
            }

            //lock (partitionedQueues[pid])
            //{
            //    partitionedQueues[pid].Enqueue(req, execPartition);
            //}

            //this.ccPartitionedQueues[pid].Enqueue(req);

            while (!req.Finished)
            {
                lock (req)
                {
                    if (!req.Finished)
                    {
                        System.Threading.Monitor.Wait(req);
                    }
                }
            }
        }
Beispiel #8
0
        internal override void EnqueueVersionEntryRequest(VersionEntryRequest req, int execPartition = 0)
        {
            // Interlocked.Increment(ref VersionDb.EnqueuedRequests);
            // SingletonPartitionedVersionDb implementation 1
            //base.EnqueueVersionEntryRequest(req, execPartition);
            //while (!req.Finished) ;

            // SingletonPartitionedVersionDb implementation 2
            int pk = this.VersionDb.PhysicalPartitionByKey(req.RecordKey);

            this.tableVisitors[pk].Invoke(req);

            // SingletonPartitionedVersionDb implementation 3
            //int pk = this.VersionDb.PhysicalPartitionByKey(req.RecordKey);
            //if (pk == execPartition)
            //{
            //    this.tableVisitors[pk].Invoke(req);
            //}
            //else
            //{
            //    base.EnqueueVersionEntryRequest(req, execPartition);
            //}
        }
Beispiel #9
0
 internal virtual void Visit(VersionEntryRequest req)
 {
 }
 internal override void Visit(VersionEntryRequest req)
 {
     throw new NotImplementedException();
 }
 internal RedisRequest Invoke(VersionEntryRequest txReq)
 {
     txReq.Accept(this);
     return(RedisReq);
 }
 internal override void EnqueueVersionEntryRequest(VersionEntryRequest req, int execPartition = 0)
 {
     // Interlocked.Increment(ref VersionDb.EnqueuedRequests);
     this.tableVisitors[execPartition].Invoke(req);
 }
Beispiel #13
0
 internal virtual void EnqueueVersionEntryRequest(VersionEntryRequest req, int execPartition = 0)
 {
     // Interlocked.Increment(ref VersionDb.EnqueuedRequests);
     return;
 }
 public virtual void Invoke(VersionEntryRequest req)
 {
     req.Accept(this);
 }
 internal override void EnqueueVersionEntryRequest(VersionEntryRequest req, int execPartition = 0)
 {
     //int pk = this.VersionDb.PhysicalPartitionByKey(req.RecordKey);
     //this.tableVisitors[pk].Visit(req);
     this.tableVisitors[execPartition].Visit(req);
 }