Exemplo n.º 1
0
        private long[] GetLatestUid()
        {
            // Perform this under a lock. This lock is also active for block queries
            // and administration updates.
            lock (blockDbWriteLock) {
                // Create a transaction
                ITransaction transaction = blockDatabase.CreateTransaction();

                try {
                    // Create the UIDList object,
                    IDataFile uidListDf = transaction.GetFile(UidListKey, FileAccess.ReadWrite);
                    UidList uidList = new UidList(uidListDf);

                    return uidList.GetLastUid();

                } finally {
                    blockDatabase.Dispose(transaction);
                }
            }
        }
Exemplo n.º 2
0
        private void InternalFetchLogBundle(MessageStream replyMessage, long[] uid, bool initial)
        {
            // Perform this under a lock. This lock is also active for block queries
            // and administration updates.
            lock (blockDbWriteLock) {
                // Create a transaction
                ITransaction transaction = blockDatabase.CreateTransaction();

                try {
                    // Create the UIDList object,
                    IDataFile uidListDf = transaction.GetFile(UidListKey, FileAccess.ReadWrite);
                    UidList uidList = new UidList(uidListDf);

                    // Go to the position of the uid,
                    long pos = 0;
                    if (uid != null) {
                        pos = uidList.PositionOfUid(uid);
                    }
                    long end = Math.Min(pos + 32, uidList.Count);
                    if (pos < 0) {
                        pos = -(pos + 1);
                    }

                    // If initial is true, we go back a bit
                    if (initial) {
                        // Go back 16 entries in the log (but don't go back before the first)
                        pos = Math.Max(0, (pos - 16));
                    } else {
                        // Go to the next entry,
                        pos = pos + 1;
                    }

                    // Send the bundle out to the stream,
                    for (long i = pos; i < end; ++i) {
                        long[] inUid = uidList.GetUid(i);
                        byte[] buf = GetValueFromUid(transaction, inUid);

                        replyMessage.AddMessage(new Message(inUid, buf));
                    }

                } finally {
                    blockDatabase.Dispose(transaction);
                }
            }
        }
Exemplo n.º 3
0
        private static void InsertToUidList(ITransaction t, long[] uid)
        {
            // Create the UIDList object,
            IDataFile uidListDf = t.GetFile(UidListKey, FileAccess.ReadWrite);
            UidList uidList = new UidList(uidListDf);

            // Inserts the uid in the list
            uidList.AddUid(uid);
        }