public virtual void Invoke(Queue <TxEntryRequest> reqQueue) { while (reqQueue.Count > 0) { TxEntryRequest req = reqQueue.Dequeue(); req.Accept(this); } }
internal void EnqueueTxEntryRequest(TxEntryRequest req) { this.txEntryVisitor.Invoke(req); RedisRequest redisReq = this.txEntryVisitor.RedisReq; redisReq.ResponseVisitor = this.redisResponseVisitor; this.redisRequestQueue.Enqueue(redisReq); }
internal override void EnqueueTxEntryRequest(long txId, TxEntryRequest txEntryRequest, int executorPK = 0) { this.dbVisitors[executorPK].Invoke(txEntryRequest); return; //////////////////////////////////////////////// int pk = this.PhysicalTxPartitionByKey(txId); //while (Interlocked.CompareExchange(ref this.latches[pk], 1, 0) != 0) ; //partitionedQueues[pk].Enqueue(txEntryRequest, executorPK); //Interlocked.Exchange(ref this.latches[pk], 0); // count tasks per partition //this.ccTasksCnt.Enqueue(pk); lock (this.rawPartitionedQueues[pk]) { this.rawPartitionedQueues[pk].Enqueue(txEntryRequest); System.Threading.Monitor.Pulse(this.rawPartitionedQueues[pk]); } //lock (partitionedQueues[pk]) //{ // partitionedQueues[pk].Enqueue(txEntryRequest, executorPK); //} //this.ccPartitionedQueues[pk].Enqueue(txEntryRequest); while (!txEntryRequest.Finished) { lock (txEntryRequest) { if (!txEntryRequest.Finished) { System.Threading.Monitor.Wait(txEntryRequest); } } } }
public override void Invoke(Queue <TxEntryRequest> reqQueue) { //foreach (TxEntryRequest req in reqs) //{ // clientPool.EnqueueTxEntryRequest(req); //} //clientPool.Visit(); int reqCount = 0; while (reqQueue.Count > 0) { TxEntryRequest req = reqQueue.Dequeue(); req.Accept(this); reqCount++; } if (reqCount > 0) { this.clientPool.Flush(this.redisRequests, redisClient, reqCount); } this.reqIndex = 0; }
internal override void EnqueueTxEntryRequest(long txId, TxEntryRequest txEntryRequest, int execPartition = 0) { // Interlocked.Increment(ref VersionDb.EnqueuedRequests); // SingletonPartitionVersionDb implementation 1 //base.EnqueueTxEntryRequest(txId, txEntryRequest, execPartition); //while (!txEntryRequest.Finished) ; // SingletonPartitionedVersionDb implementation 2 int pk = this.PhysicalTxPartitionByKey(txId); this.dbVisitors[pk].Invoke(txEntryRequest); // SingletonPartitionedVersionDb implementation 3 //int pk = this.PhysicalTxPartitionByKey(txId); //if (pk == execPartition) //{ // this.dbVisitors[pk].Invoke(txEntryRequest); //} //else //{ // base.EnqueueTxEntryRequest(txId, txEntryRequest, execPartition); //} }
private void Monitor(object partitionKey) { //long totalTicks = 0; //long idleTicks = 0; //long round = 0; //long idleRound = 0; int pk = (int)partitionKey; while (this.Active) { //long start = DateTime.Now.Ticks; //round++; //bool idle = true; // flush version db queue TxEntryRequest txReq = null; lock (this.rawPartitionedQueues[pk]) { if (this.rawPartitionedQueues[pk].Count > 0) { txReq = this.rawPartitionedQueues[pk].Dequeue(); } else { System.Threading.Monitor.Wait(this.rawPartitionedQueues[pk]); } } if (txReq != null) { this.dbVisitors[pk].Invoke(txReq); lock (txReq) { System.Threading.Monitor.Pulse(txReq); } } //if (this.partitionedQueues[pk].TryDequeue(out txReq)) //if (this.ccPartitionedQueues[pk].TryDequeue(out txReq)) //{ // //this.ccPartitionedQueues[pk].IsEmpty; // //idle = false; // this.dbVisitors[pk].Invoke(txReq); // lock (txReq) // { // System.Threading.Monitor.Pulse(txReq); // } //} // flush VersionTables Queue //VersionEntryRequest veReq = null; //if (this.versionTables.Count > 0) // avoid lock mostly, just for test, not safe theoretically //{ // foreach (var item in this.versionTables) // { // //if ((item.Value as PartitionedCassandraVersionTable).partitionedQueues[pk].TryDequeue(out veReq)) // if ((item.Value as PartitionedCassandraVersionTable).ccPartitionedQueues[pk].TryDequeue(out veReq)) // { // //idle = false; // (item.Value as PartitionedCassandraVersionTable).tableVisitors[pk].Invoke(veReq); // lock (veReq) // { // System.Threading.Monitor.Pulse(veReq); // } // } // } //} //long end = DateTime.Now.Ticks; //long delta = end - start; //totalTicks += delta; //if (idle) //{ // idleRound++; // idleTicks += delta; //} } //Console.WriteLine("Monitor: {0}, total round {1}, idle round {2}, idle rate {3} \n" + // " total ticks {4}, idle ticks {5}, idle rate {6}", // partitionKey, round, idleRound, idleRound * 1.0 / round, // totalTicks, idleTicks, idleTicks * 1.0 / totalTicks); }
/// <summary> /// Enqueue Transcation Entry Requests /// </summary> /// <param name="txId">The specify txId to partition</param> /// <param name="txEntryRequest">The given request</param> internal abstract void EnqueueTxEntryRequest( long txId, TxEntryRequest txEntryRequest, int execWorkerId = 0);
internal virtual void Visit(TxEntryRequest req) { }
internal override void EnqueueTxEntryRequest(long txId, TxEntryRequest txEntryRequest, int execPartition = 0) { //int pk = this.PhysicalPartitionByKey(txId); //this.dbVisitors[pk].Invoke(txEntryRequest); this.dbVisitors[execPartition].Invoke(txEntryRequest); }
public virtual void Invoke(TxEntryRequest req) { req.Accept(this); }
internal RedisRequest Invoke(TxEntryRequest txReq) { txReq.Accept(this); return(RedisReq); }
internal override void Visit(TxEntryRequest req) { throw new NotImplementedException(); }