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
, 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
, preferredcontentmap = Nothing
, requiredcontentmap = Nothing
, remoteconfigmap = Nothing
+ , clusters = Nothing
, forcetrust = M.empty
, trustmap = Nothing
, groupmap = Nothing
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
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).