private static void CreateDirectories(ZooKeeperInstance instance) { if (Directory.Exists(instance.BaseDirectory)) { Directory.Delete(instance.BaseDirectory, true); } Directory.CreateDirectory(instance.BaseDirectory); Directory.CreateDirectory(instance.BinDirectory); Directory.CreateDirectory(instance.DataDirectory); Directory.CreateDirectory(instance.LibDirectory); Directory.CreateDirectory(instance.ConfDirectory); }
// ReSharper disable once InconsistentNaming private static string CreateLog4jConfig(ZooKeeperInstance instance) { var builder = new StringBuilder(); builder.AppendLine("log4j.rootLogger=DEBUG, ROLLINGFILE"); builder.AppendLine("log4j.appender.ROLLINGFILE=org.apache.log4j.RollingFileAppender"); builder.AppendLine("log4j.appender.ROLLINGFILE.File=" + $"../ZK-{instance.Id}.log"); builder.AppendLine("log4j.appender.ROLLINGFILE.Threshold=DEBUG"); builder.AppendLine("log4j.appender.ROLLINGFILE.layout=org.apache.log4j.PatternLayout"); builder.AppendLine("log4j.appender.ROLLINGFILE.layout.ConversionPattern=[myid:%X{myid}] - %d %-5p [%t:%C{1}@%L] - %m%n"); return(builder.ToString()); }
private static void DeployFiles(ZooKeeperInstance instance, string config) { // (iloktionov): Libraries. SaveResources(instance.LibDirectory, "jline_0_9_94.jar"); SaveResources(instance.LibDirectory, "log4j_1_2_15.jar"); SaveResources(instance.LibDirectory, "netty_3_2_2_Final.jar"); SaveResources(instance.LibDirectory, "slf4j_api_1_6_1.jar"); SaveResources(instance.LibDirectory, "slf4j_log4j12_1_6_1.jar"); // (iloktionov): Control scripts. Directory.CreateDirectory(instance.BinDirectory); // (iloktionov): Actual ZK lib. SaveResources(instance.BaseDirectory, "zookeeper_3_4_13.jar"); // (iloktionov): Configs. File.WriteAllText(Path.Combine(instance.ConfDirectory, "zoo.cfg"), config); File.WriteAllText(Path.Combine(instance.ConfDirectory, "log4j.properties"), CreateLog4jConfig(instance)); // (iloktionov): Self id. File.WriteAllText(Path.Combine(instance.DataDirectory, "myid"), instance.Id.ToString()); }
private static void DeployInstance(ZooKeeperInstance instance, string config) { CreateDirectories(instance); DeployFiles(instance, config); }