Exemplo n.º 1
0
        public Transaction(
            ILogStore logStore,
            VersionDb versionDb,
            long txId = -1,
            Queue <long> garbageQueueTxId       = null,
            Queue <long> garbageQueueFinishTime = null)
        {
            this.logStore             = logStore;
            this.versionDb            = versionDb;
            this.readSet              = new Dictionary <string, Dictionary <object, ReadSetEntry> >();
            this.writeSet             = new Dictionary <string, Dictionary <object, object> >();
            this.abortSet             = new Dictionary <string, Dictionary <object, List <PostProcessingEntry> > >();
            this.commitSet            = new Dictionary <string, Dictionary <object, List <PostProcessingEntry> > >();
            this.largestVersionKeyMap = new Dictionary <string, Dictionary <object, long> >();
            this.validationVersions   = new List <Tuple <string, object, VersionEntry> >();

            this.txId     = txId < 0 ? this.versionDb.InsertNewTx() : txId;
            this.txStatus = TxStatus.Ongoing;

            this.commitTs            = TxTableEntry.DEFAULT_COMMIT_TIME;
            this.maxCommitTsOfWrites = -1L;
            this.beginTimestamp      = Transaction.DEFAULT_TX_BEGIN_TIMESTAMP;

            this.garbageQueueTxId       = garbageQueueTxId;
            this.garbageQueueFinishTime = garbageQueueFinishTime;
        }
Exemplo n.º 2
0
        public VersionTable(VersionDb versionDb, string tableId, int partitionCount = 4)
        {
            // private properties
            this.VersionDb      = versionDb;
            this.tableId        = tableId;
            this.PartitionCount = partitionCount;

            // the table visitors
            this.tableVisitors = new VersionTableVisitor[partitionCount];
        }
Exemplo n.º 3
0
        public CassandraVersionTable(VersionDb versionDb, string tableId, int partitionCount = 4)
            : base(versionDb, tableId)
        {
            this.PartitionCount = partitionCount;

            for (int pid = 0; pid < this.PartitionCount; pid++)
            {
                this.tableVisitors[pid] = new CassandraVersionTableVisitor();
            }
        }
Exemplo n.º 4
0
        public SingletonPartitionedVersionTable(VersionDb versionDb, string tableId, int partitionCount)
            : base(versionDb, tableId, partitionCount)
        {
            this.PartitionCount = partitionCount;
            this.dicts          = new Dictionary <object, Dictionary <long, VersionEntry> > [partitionCount];

            for (int pid = 0; pid < partitionCount; pid++)
            {
                this.dicts[pid]         = new Dictionary <object, Dictionary <long, VersionEntry> >(SingletonPartitionedVersionTable.RECORD_CAPACITY);
                this.tableVisitors[pid] = new SingletonPartitionedVersionTableVisitor(this.dicts[pid]);
            }
        }
        public SingletonDictionaryVersionTable(VersionDb versionDb, string tableId,
                                               int partitionCount, List <TxResourceManager> txResourceManagers)
            : base(versionDb, tableId, partitionCount)
        {
            int maxConcurrency = Math.Max(1, this.VersionDb.PartitionCount / 2);

            // this.dict = new ConcurrentDictionary<object, ConcurrentDictionary<long, VersionEntry>>(
            //     maxConcurrency, 1200500/*VersionDb.RECORD_CAPACITY*/);
            this.dict = new Dictionary <object, ConcurrentDictionary <long, VersionEntry> >(1200000);

            for (int i = 0; i < partitionCount; i++)
            {
                this.tableVisitors[i] = new SingletonVersionTableVisitor(this.dict);
            }
        }
Exemplo n.º 6
0
        public PartitionedCassandraVersionTable(VersionDb versionDb, string tableId, int partitionCount = 4)
            : base(versionDb, tableId, 1)   // fake partitionCount to avoid memory overflow
        {
            this.PartitionCount = partitionCount;
            //this.partitionedQueues = new RequestQueue<VersionEntryRequest>[partitionCount];
            this.rawPartitionedQueues = new Queue <VersionEntryRequest> [partitionCount];
            //this.ccPartitionedQueues = new ConcurrentQueue<VersionEntryRequest>[partitionCount];
            //this.latches = new int[partitionCount];
            this.ccTasksCnt = new ConcurrentQueue <int>();

            this.tableVisitors = new VersionTableVisitor[partitionCount];

            for (int pid = 0; pid < this.PartitionCount; pid++)
            {
                //this.partitionedQueues[pid] = new RequestQueue<VersionEntryRequest>(partitionCount);
                this.rawPartitionedQueues[pid] = new Queue <VersionEntryRequest>(partitionCount);
                //this.rawPartitionedQueues[pid] = new Queue<VersionEntryRequest>();
                //this.ccPartitionedQueues[pid] = new ConcurrentQueue<VersionEntryRequest>();
                //this.latches[pid] = 0;

                this.tableVisitors[pid] = new PartitionedCassandraVersionTableVisitor(pid);
            }
        }
Exemplo n.º 7
0
        public RedisVersionTable(VersionDb versionDb, string tableId, long redisDbIndex)
            : base(versionDb, tableId, versionDb.PartitionCount)
        {
            this.redisDbIndex       = redisDbIndex;
            this.responseVisitor    = new RedisResponseVisitor();
            this.redisVersionDb     = ((RedisVersionDb)this.VersionDb);
            this.RedisManager       = redisVersionDb.RedisManager;
            this.LuaManager         = redisVersionDb.RedisLuaManager;
            this.singletonConnPool  = redisVersionDb.SingletonConnPool;
            this.redisVersionDbMode = redisVersionDb.Mode;

            this.requestQueues = new Queue <VersionEntryRequest> [this.PartitionCount];
            this.flushQueues   = new Queue <VersionEntryRequest> [this.PartitionCount];
            this.queueLatches  = new int[this.PartitionCount];

            RedisConnectionPool clientPool = null;

            for (int pid = 0; pid < this.PartitionCount; pid++)
            {
                if (this.redisVersionDbMode == RedisVersionDbMode.Cluster)
                {
                    clientPool = this.singletonConnPool;
                }
                else
                {
                    clientPool = this.RedisManager.GetClientPool(
                        this.redisDbIndex, RedisVersionDb.GetRedisInstanceIndex(pid));
                }
                this.tableVisitors[pid] = new RedisVersionTableVisitor(
                    clientPool, this.LuaManager, this.responseVisitor, this.redisVersionDbMode);

                this.requestQueues[pid] = new Queue <VersionEntryRequest>(VersionDb.REQUEST_QUEUE_CAPACITY);
                this.flushQueues[pid]   = new Queue <VersionEntryRequest>(VersionDb.REQUEST_QUEUE_CAPACITY);
                this.queueLatches[pid]  = 0;
            }
        }
 public SingletonTreeMapVersionTable(VersionDb versionDb, string tableId)
     : base(versionDb, tableId)
 {
 }