]> dgit.raspbian.org Git - git-annex.git/commitdiff
cache getClusters in Annex state
authorJoey Hess <joeyh@joeyh.name>
Fri, 14 Jun 2024 15:16:01 +0000 (11:16 -0400)
committerJoey Hess <joeyh@joeyh.name>
Fri, 14 Jun 2024 15:16:01 +0000 (11:16 -0400)
Annex.hs
Logs/Cluster.hs
doc/design/passthrough_proxy.mdwn

index 28c278f0cf40b37e3589195092fe4cd1b8e5166b..1e3825ad1973618d659faf373ae6b49526f4e616 100644 (file)
--- a/Annex.hs
+++ b/Annex.hs
@@ -74,6 +74,7 @@ import Types.CatFileHandles
 import Types.RemoteConfig
 import Types.TransferrerPool
 import Types.VectorClock
+import Types.Cluster
 import Annex.VectorClock.Utility
 import Annex.Debug.Utility
 import qualified Database.Keys.Handle as Keys
@@ -194,6 +195,7 @@ data AnnexState = AnnexState
        , preferredcontentmap :: Maybe (FileMatcherMap Annex)
        , requiredcontentmap :: Maybe (FileMatcherMap Annex)
        , remoteconfigmap :: Maybe (M.Map UUID RemoteConfig)
+       , clusters :: Maybe Clusters
        , forcetrust :: TrustMap
        , trustmap :: Maybe TrustMap
        , groupmap :: Maybe GroupMap
@@ -248,6 +250,7 @@ newAnnexState c r = do
                , preferredcontentmap = Nothing
                , requiredcontentmap = Nothing
                , remoteconfigmap = Nothing
+               , clusters = Nothing
                , forcetrust = M.empty
                , trustmap = Nothing
                , groupmap = Nothing
index 0bf3d5358d17126ff64df6f333f39730f66485eb..12fe936c72098e75e5932b9f52e4942632f9d49d 100644 (file)
@@ -30,15 +30,19 @@ import qualified Data.Attoparsec.ByteString as A
 import qualified Data.Attoparsec.ByteString.Char8 as A8
 import qualified Data.ByteString.Lazy as L
 
--- TODO caching
 getClusters :: Annex Clusters
-getClusters = do
+getClusters = maybe loadClusters return =<< Annex.getState Annex.clusters
+
+loadClusters :: Annex Clusters
+loadClusters = do
        m <- convclusteruuids . M.map value . fromMapLog . parseClusterLog
                <$> Annex.Branch.get clusterLog
-       return $ Clusters
+       let clusters = Clusters
                { clusterUUIDs = m
                , clusterNodeUUIDs = M.foldlWithKey inverter mempty m
                }
+       Annex.changeState $ \s -> s { Annex.clusters = Just clusters }
+       return clusters
   where
        convclusteruuids :: M.Map UUID (S.Set ClusterNodeUUID) -> M.Map ClusterUUID (S.Set ClusterNodeUUID)
        convclusteruuids = M.fromList 
index 6f775dd0bd3ad491c664929f651ede53877cc261..581c2b8c1143048cc03e34d83b3d589996d763f1 100644 (file)
@@ -218,9 +218,10 @@ UUID, all random except the first octet set to 'a' and the second to 'c'.
 
 The proxy log contains the cluster UUID (with a remote name like
 "cluster"), as well as the UUIDs of the nodes of the cluster.
-This makes the client access the cluster using the proxy. Note that more
-than one proxy can be in front of the same cluster, and multiple clusters
-can be accessed via the same proxy.
+This lets the client access the cluster using the proxy, and it lets the
+client access individual nodes (so it can lock content on them while
+dropping). Note that more than one proxy can be in front of the same
+cluster, and multiple clusters can be accessed via the same proxy.
 
 The cluster UUID is recorded in the git-annex branch, along with a list of
 the UUIDs of nodes of the cluster (which can change at any time).