Exemple #1
0
        internal override void Visit(InitiGetVersionListRequest req)
        {
            ConcurrentDictionary <long, VersionEntry> versionList = null;

            if (!this.dict.TryGetValue(req.RecordKey, out versionList))
            {
                ConcurrentDictionary <long, VersionEntry> newVersionList = new ConcurrentDictionary <long, VersionEntry>(32);
                // Adds a special entry whose key is -1 when the list is initialized.
                // The entry uses beginTimestamp as a pointer pointing to the newest verion in the list.
                VersionEntry entry = VersionEntry.InitEmptyVersionEntry();
                ResetTailEntry(entry);
                newVersionList.TryAdd(SingletonDictionaryVersionTable.TAIL_KEY, entry);

                // if concurrentDict.TryAdd()
                this.dict.Add(req.RecordKey, newVersionList);

                // The version list is newly created by this tx.
                // No meaningful versions exist, except for the artificial entry as a tail pointer.
                req.RemoteVerList = newVersionList;
                req.Result        = true;
                req.Finished      = true;
                return;
            }
            req.RemoteVerList = null;
            req.Result        = false;
            req.Finished      = true;
        }
        internal override void Visit(InitiGetVersionListRequest req)
        {
            // The version list is empty
            if (!this.dict.ContainsKey(req.RecordKey))
            {
                Dictionary <long, VersionEntry> newVersionList =
                    new Dictionary <long, VersionEntry>(SingletonPartitionedVersionTable.VERSION_CAPACITY);

                // Adds a special entry whose key is TAIL_KEY when the list is initialized.
                // The entry uses beginTimestamp as a pointer pointing to the newest verion in the list.
                newVersionList.Add(
                    SingletonDictionaryVersionTable.TAIL_KEY, VersionEntry.InitEmptyVersionEntry());

                this.dict.Add(req.RecordKey, newVersionList);

                // The version list is newly created by this tx.
                // No meaningful versions exist, except for the artificial entry as a tail pointer.
                req.RemoteVerList = newVersionList;
                req.Result        = true;
                req.Finished      = true;
                return;
            }
            else
            {
                req.RemoteVerList = null;
                req.Result        = false;
                req.Finished      = true;
            }
        }
 internal override void Visit(InitiGetVersionListRequest req)
 {
     try
     {
         long ret = (long)req.Result;
         req.Result = ret == 1L;
     }
     catch (Exception)
     {
         req.Result = false;
     }
 }
        internal override void Visit(InitiGetVersionListRequest req)
        {
            string hashKey = GetHashKey(req);

            var redisRequest = this.NextRedisRequest();

            redisRequest.Set(
                hashKey,
                RedisVersionDb.LATEST_VERSION_PTR_FIELD,
                RedisVersionDb.EMPTY_BYTES,
                RedisRequestType.HSetNX);

            redisRequest.ParentRequest = req;
        }
Exemple #5
0
        internal override void Visit(InitiGetVersionListRequest req)
        {
            VersionEntry emptyEntry = VersionEntry.InitEmptyVersionEntry();

            this.CQLExecute(string.Format(PartitionedCassandraVersionTable.CQL_UPLOAD_VERSION_ENTRY,
                                          req.TableId,
                                          req.RecordKey.ToString(),
                                          emptyEntry.VersionKey,
                                          emptyEntry.BeginTimestamp,
                                          emptyEntry.EndTimestamp,
                                          BytesSerializer.ToHexString(BytesSerializer.Serialize(emptyEntry.Record)),
                                          emptyEntry.TxId,
                                          emptyEntry.MaxCommitTs));
            req.Result   = true;
            req.Finished = true;
        }
        internal override void Visit(InitiGetVersionListRequest req)
        {
            this.HashId = req.RecordKey as string;
            long         versionKey = VersionEntry.VERSION_KEY_START_INDEX;
            VersionEntry emptyEntry = new VersionEntry(
                versionKey,
                VersionEntry.EMPTY_RECORD,
                VersionEntry.EMPTY_TXID);

            byte[] keyBytes   = BitConverter.GetBytes(versionKey);
            byte[] valueBytes = VersionEntry.Serialize(emptyEntry);

            this.RedisReq = new RedisRequest(this.HashId, keyBytes, valueBytes, RedisRequestType.HSetNX)
            {
                ParentRequest = req
            };
        }
Exemple #7
0
        internal override void Visit(InitiGetVersionListRequest req)
        {
            if (!this.dict.TryGetValue(req.RecordKey, out VersionList versionList))
            {
                VersionList newVersionList = new VersionList();

                if (this.dict.TryAdd(req.RecordKey, newVersionList))
                {
                    // The version list is newly created by this tx.
                    // No meaningful versions exist, except for the artificial entry as a tail pointer.
                    req.RemoteVerList = newVersionList;
                    req.Result        = true;
                    req.Finished      = true;
                    return;
                }
            }
            else
            {
                req.RemoteVerList = null;
                req.Result        = false;
                req.Finished      = true;
            }
        }
Exemple #8
0
 internal virtual void Visit(InitiGetVersionListRequest req)
 {
 }