示例#1
0
            public DataAddress[] GetPathRootsSince(DataAddress root)
            {
                // The returned list,
                List<DataAddress> rootList = new List<DataAddress>(6);

                // Synchronize over the object
                lock (accessLock) {

                    // Only allow if complete and synchronized
                    CheckIsSynchronized();

                    bool found = false;

                    // Start position at the end of the file,
                    long pos = internalFile.Length;

                    while (found == false && pos > 0) {
                        // Iterate backwards,
                        pos = pos - RootItemSize;
                        // Read the root node for this record,
                        long rootNodeRefH = pagedFile.ReadInt64(pos + 8);
                        long rootNodeRefL = pagedFile.ReadInt64(pos + 16);
                        NodeId rootNodeId = new NodeId(rootNodeRefH, rootNodeRefL);
                        // Crudely clear the cache if it's reached a certain threshold,
                        pagedFile.ClearCache(4);
                        // Did we find the root node?
                        DataAddress rootNodeDa = new DataAddress(rootNodeId);
                        if (rootNodeDa.Equals(root)) {
                            found = true;
                        } else {
                            rootList.Add(rootNodeDa);
                        }
                    }

                    // If not found, report error
                    if (!found) {
                        // Bit of an obscure error message. This basically means we didn't
                        // find the root node requested in the path file.
                        throw new ApplicationException("Root not found in version list");
                    }

                    // Return the array as a list,
                    return rootList.ToArray();
                }
            }
示例#2
0
            private void PostProposalIfNotPresent(long uid, DataAddress rootNode)
            {
                lock (accessLock) {

                    long setSize = internalFile.Length/RootItemSize;

                    // The position of the uid,
                    long pos = BinarySearch(pagedFile, 0, setSize - 1, uid);
                    if (pos < 0) {
                        pos = -(pos + 1);
                    }
                    // Crudely clear the cache if it has reached a certain threshold,
                    pagedFile.ClearCache(4);

                    // Go back some entries
                    pos = Math.Max(0, pos - 256);

                    // Search,
                    while (true) {
                        if (pos >= setSize)
                            // End if pos is greater or equal to the size,
                            break;

                        long readUid = pagedFile.ReadInt64((pos*RootItemSize) + 0);
                        long nodeH = pagedFile.ReadInt64((pos*RootItemSize) + 8);
                        long nodeL = pagedFile.ReadInt64((pos*RootItemSize) + 16);
                        NodeId node = new NodeId(nodeH, nodeL);
                        DataAddress dataAddress = new DataAddress(node);

                        // Crudely clear the cache if it's reached a certain threshold,
                        pagedFile.ClearCache(4);

                        // Found, so return
                        if (uid == readUid &&
                            rootNode.Equals(dataAddress)) {
                            return;
                        }

                        ++pos;
                    }

                    // Not found, so post
                    PostProposalToPath(uid, rootNode);
                }
            }
示例#3
0
        private DataAddress[] GetSnapshots(string pathName, DataAddress rootNode)
        {
            // Check the name given is valid,
            CheckPathNameValid(pathName);

            // Fetch the path access object for the given name. This will generate an
            // exception if the path doesn't exist or there is an error input the
            // configuration of the path.
            PathAccess pathAccess = GetPathAccess(pathName);

            List<DataAddress> rootList = new List<DataAddress>(6);
            lock (pathAccess) {
                bool found = false;

                // Start position at the end of the file,
                long pos = pathAccess.AccessStream.Length;

                while (!found && pos > 0) {
                    // Iterate backwards,
                    pos = pos - 16;
                    // Read the root node for this record,
                    long rootNodeId = pathAccess.PagedAccess.ReadInt64(pos + 8);
                    // Crudely clear the cache if it's reached a certain threshold,
                    pathAccess.PagedAccess.ClearCache(4);
                    // Did we find the root node?
                    DataAddress rootNodeAddress = new DataAddress(rootNodeId);
                    if (rootNodeAddress.Equals(rootNode)) {
                        found = true;
                    } else {
                        rootList.Add(rootNodeAddress);
                    }
                }

                // If not found, report error
                if (!found) {
                    // Bit of an obscure error message. This basically means we didn't
                    // find the root node requested input the path file.
                    throw new ApplicationException("Root not found input version list");
                }

                // Return the array as a list,
                return rootList.ToArray();

            }
        }