Esempio n. 1
0
 public EnvironmentsStorage(IZooKeeperClient zooKeeperClient, ServiceDiscoveryPathHelper pathHelper, ActionsQueue eventsHandler, ILog log)
 {
     this.zooKeeperClient = zooKeeperClient;
     this.pathHelper      = pathHelper;
     this.eventsHandler   = eventsHandler;
     this.log             = log;
     nodeWatcher          = new AdHocNodeWatcher(OnNodeEvent);
 }
        internal ServiceBeacon(
            [NotNull] IZooKeeperClient zooKeeperClient,
            [NotNull] ReplicaInfo replicaInfo,
            [CanBeNull] ServiceBeaconSettings settings,
            [CanBeNull] ILog log)
        {
            this.zooKeeperClient = zooKeeperClient ?? throw new ArgumentNullException(nameof(settings));
            this.replicaInfo     = replicaInfo = replicaInfo ?? throw new ArgumentNullException(nameof(settings));
            this.settings        = settings ?? new ServiceBeaconSettings();
            this.log             = (log ?? LogProvider.Get()).ForContext <ServiceBeacon>();

            var pathHelper = new ServiceDiscoveryPathHelper(this.settings.ZooKeeperNodesPrefix, this.settings.ZooKeeperNodesPathEscaper);

            environmentNodePath = pathHelper.BuildEnvironmentPath(replicaInfo.Environment);
            applicationNodePath = pathHelper.BuildApplicationPath(replicaInfo.Environment, replicaInfo.Application);
            replicaNodePath     = pathHelper.BuildReplicaPath(replicaInfo.Environment, replicaInfo.Application, replicaInfo.Replica);
            replicaNodeData     = ReplicaNodeDataSerializer.Serialize(replicaInfo);

            nodeWatcher = new AdHocNodeWatcher(OnNodeEvent);
        }
        public ApplicationWithReplicas(
            string environmentName,
            string applicationName,
            string applicationNodePath,
            IZooKeeperClient zooKeeperClient,
            ServiceDiscoveryPathHelper pathHelper,
            ActionsQueue eventsQueue,
            ILog log)
        {
            this.environmentName     = environmentName;
            this.applicationName     = applicationName;
            this.applicationNodePath = applicationNodePath;
            this.zooKeeperClient     = zooKeeperClient;
            this.pathHelper          = pathHelper;
            this.eventsQueue         = eventsQueue;
            this.log = log;

            nodeWatcher          = new AdHocNodeWatcher(OnNodeEvent);
            applicationContainer = new VersionedContainer <ApplicationInfo>();
            replicasContainer    = new VersionedContainer <Uri[]>();
        }