Beispiel #1
0
        public HerculesCluster Deploy()
        {
            Directory.CreateDirectory(baseDirectory);
            var downloader = new HerculesDownloader(baseDirectory, log);

            herculesBinariesPaths = downloader.GetLatestBinaries(ComponentNames.Values.ToArray());
            HerculesLoggerAppender.AppendLogger(downloader.GetLogger(), herculesBinariesPaths.Values, log);

            var cluster = new HerculesCluster();

            try
            {
                cluster.ZooKeeperEnsemble = ZooKeeperEnsemble.DeployNew(new ZooKeeperEnsembleSettings {
                    BaseDirectory = baseDirectory
                }, log);
                cluster.KafkaInstance = KafkaInstance.DeployNew(new KafkaSettings {
                    BaseDirectory = baseDirectory, ZooKeeperConnectionString = cluster.ZooKeeperEnsemble.ConnectionString
                }, log);

                DeployHercules(cluster);

                return(cluster);
            }
            catch (Exception error)
            {
                log.Error(error, "Error in deploy. Will try to cleanup.");
                cluster.Dispose();
                throw;
            }
        }
Beispiel #2
0
        private void DeployHercules(HerculesCluster cluster)
        {
            var clusterSettings = new HerculesClusterSettings
            {
                ZooKeeperConnectionString = cluster.ZooKeeperEnsemble.ConnectionString,
                KafkaConnectionString     = cluster.KafkaInstance.ConnectionString
            };

            InitializeHercules(clusterSettings);

            ApiKeyInitializer.AddApiKey(ApiKeys.ApiKey, clusterSettings.ZooKeeperConnectionString, log);

            AddServices(
                cluster,
                deploySettings.HerculesGateCount,
                id => new HerculesGate(GetHerculesComponentSettings <HerculesGate>(id), clusterSettings, log));

            AddServices(
                cluster,
                deploySettings.HerculesManagementApiCount,
                id => new HerculesManagementApi(GetHerculesComponentSettings <HerculesManagementApi>(id), clusterSettings, ApiKeys.AdminApiKey, log));

            AddServices(
                cluster,
                deploySettings.HerculesStreamApiCount,
                id => new HerculesStreamApi(GetHerculesComponentSettings <HerculesStreamApi>(id), clusterSettings, log));

            AddServices(
                cluster,
                deploySettings.HerculesStreamManagerCount,
                id => new HerculesStreamManager(GetHerculesComponentSettings <HerculesStreamManager>(id), clusterSettings, log));

            DeployServices(cluster.HerculesServices);
        }
Beispiel #3
0
 public static void Cleanup(HerculesCluster cluster)
 {
     foreach (var service in cluster.HerculesServices)
     {
         TryDeleteDirectory(service.BaseDirectory);
     }
 }
        public static HerculesCluster DeployNew(HerculesDeploySettings deploySettings, ILog log, bool started = true)
        {
            HerculesCluster cluster = null;

            Retrier.RetryOnException(() =>
            {
                cluster = new HerculesDeployer(deploySettings, log).Deploy();

                if (started)
                {
                    cluster.Start();
                }
            },
                                     3,
                                     "Unable to start Hercules.Local",
                                     () =>
            {
                log.Warn("Retrying Hercules.Local deployment...");
                cluster?.Dispose();
            });

            return(cluster);
        }
Beispiel #5
0
 private static void AddServices(HerculesCluster cluster, int count, Func <int, HerculesService> constructor)
 {
     cluster.HerculesServices.AddRange(CreateServices(count, constructor));
 }