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; } }
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); }
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); }
private static void AddServices(HerculesCluster cluster, int count, Func <int, HerculesService> constructor) { cluster.HerculesServices.AddRange(CreateServices(count, constructor)); }