Example #1
0
 /// <summary>
 /// For write committed version to log.
 /// </summary>
 public LogRequest(string tableId, long txId, LogVersionEntry logEntry, LogRequestType type)
 {
     this.TableId  = tableId;
     this.TxId     = txId;
     this.LogEntry = logEntry;
     this.Type     = type;
 }
Example #2
0
        internal void Flush()
        {
            // Send queued requests to Cassandra, collect results and store each of them in the corresonding request
            for (int reqId = 0; reqId <= this.currReqId; reqId++)
            {
                LogRequest req = this.requestQueue[reqId];
                if (req.Type == LogRequestType.WriteTxLog)
                {
                    req.IsSuccess = CassandraLogStore.Instance.InsertCommittedTx(req.TxId);
                    req.Finished  = true;
                }
                else
                {
                    LogVersionEntry entry = req.LogEntry;
                    req.IsSuccess = CassandraLogStore.Instance.InsertCommittedVersion(req.TableId, entry.RecordKey, entry.Payload, req.TxId, entry.CommitTs);
                    req.Finished  = true;
                }
            }

            // Release the request lock to make sure processRequest can keep going
            for (int reqId = 0; reqId <= this.currReqId; reqId++)
            {
                // Monitor.Wait must be called in sync block, here we should lock the
                // request and release the it on time
                lock (this.requestQueue[reqId])
                {
                    System.Threading.Monitor.PulseAll(this.requestQueue[reqId]);
                }
            }

            this.currReqId = -1;
        }
Example #3
0
 public bool WriteCommittedVersion(string tableId, object recordKey, object payload, long txId, long commitTs)
 {
     if (this.PipelineMode)
     {
         LogVersionEntry logEntry = new LogVersionEntry(recordKey, payload, txId);
         LogRequest      request  = new LogRequest(tableId, txId, logEntry, LogRequestType.WriteVersionLog);
         return(this.connectionPool[txId % CassandraLogStore.DEFAULT_CONNECTION_POOL_COUNT].ProcessBoolRequest(request));
     }
     else
     {
         return(this.InsertCommittedVersion(tableId, recordKey, payload, txId, commitTs));
     }
 }