예제 #1
0
        private void RemovePathRootMapping(string pathName)
        {
            // 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 {
                    PathRootTable path_root_map = new PathRootTable(transaction.GetFile(PathRootKey, FileAccess.Write));
                    path_root_map.Set(pathName, null);

                    // Commit and check point the update,
                    blockDatabase.Publish(transaction);
                    blockDatabase.CheckPoint();
                } finally {
                    blockDatabase.Dispose(transaction);
                }
            }
        }
예제 #2
0
        private IServiceAddress GetRootForPath(string pathName)
        {
            // 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 {
                    // Get the map,
                    PathRootTable path_root_map = new PathRootTable(transaction.GetFile(PathRootKey, FileAccess.Read));

                    // Get the service address for the path name
                    return path_root_map.Get(pathName);
                } finally {
                    blockDatabase.Dispose(transaction);
                }
            }
        }
예제 #3
0
        private void RegisterRootServer(IServiceAddress serviceAddress)
        {
            // Open a connection with the root service,
            IMessageProcessor processor = connector.Connect(serviceAddress, ServiceType.Root);

            // Lock the root service with this manager
            RequestMessage request = new RequestMessage("bindWithManager");
            request.Arguments.Add(address);
            Message response = processor.Process(request);
            if (response.HasError)
                throw new ApplicationException(response.ErrorMessage);

            // Get the database path report from the service,
            request = new RequestMessage("pathReport");
            response = processor.Process(request);
            if (response.HasError)
                throw new ApplicationException(response.ErrorMessage);

            string[] pathsNames = (string[])response.Arguments[0].Value;

            // Create a transaction
            lock (blockDbWriteLock) {
                ITransaction transaction = blockDatabase.CreateTransaction();
                try {
                    // Get the map,
                    PathRootTable pathRootTable = new PathRootTable(transaction.GetFile(PathRootKey, FileAccess.ReadWrite));

                    // Read until the end
                    int sz = pathsNames.Length;
                    // Put each block item into the database,
                    for (int i = 0; i < sz; ++i) {
                        // Put the mapping of path_root to the root service that manages it.
                        pathRootTable.Set(pathsNames[i], serviceAddress);
                    }

                    // Commit and check point the update,
                    blockDatabase.Publish(transaction);
                    blockDatabase.CheckPoint();

                } finally {
                    blockDatabase.Dispose(transaction);
                }
            }

            // Add it to the map
            lock (rootServers) {
                rootServers.Add(new RootServerInfo(serviceAddress, ServiceStatus.Up));
                PersistRootServers(rootServers);
            }
        }
예제 #4
0
 private string[] GetPaths()
 {
     // Perform this under a lock. This lock is also active for block queries
     // and administration updates.
     List<String> paths = new List<string>(32);
     lock (blockDbWriteLock) {
         // Create a transaction
         ITransaction transaction = blockDatabase.CreateTransaction();
         try {
             // Get the map,
             PathRootTable pathRootTable = new PathRootTable(transaction.GetFile(PathRootKey, FileAccess.Read));
             foreach(string path in pathRootTable.Keys) {
                 paths.Add(path);
             }
         } finally {
             blockDatabase.Dispose(transaction);
         }
     }
     // Return the list,
     return paths.ToArray();
 }