cache getClusters in Annex state
This commit is contained in:
parent
da3c0115cb
commit
de1d795dfe
3 changed files with 14 additions and 6 deletions
3
Annex.hs
3
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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).
|
||||
|
|
Loading…
Reference in a new issue