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); } } }
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); } }