public INeo4jInstance Create(Neo4jVersion neo4jVersion, string id) { Helper.Download(neo4jVersion, neo4JManagerConfig.Neo4jBasePath); Helper.Extract(neo4jVersion, neo4JManagerConfig.Neo4jBasePath); var deploymentFolderName = Helper.GenerateValidFolderName(id); if (string.IsNullOrEmpty(deploymentFolderName)) { throw new ArgumentException("Error creating folder with given Id"); } var targetDeploymentPath = Path.Combine(neo4JManagerConfig.Neo4jBasePath, deploymentFolderName); Helper.SafeDelete(targetDeploymentPath); Helper.CopyDeployment(neo4jVersion, neo4JManagerConfig.Neo4jBasePath, targetDeploymentPath); var endpoints = new Neo4jEndpoints { HttpEndpoint = new Uri($"http://localhost:{neo4JManagerConfig.StartHttpPort + Count}"), }; endpoints.BoltEndpoint = new Uri($"bolt://localhost:{neo4JManagerConfig.StartBoltPort + Count}"); var neo4jFolder = Directory.GetDirectories(targetDeploymentPath) .First(f => f.Contains(neo4jVersion.Version, StringComparison.OrdinalIgnoreCase)); var instance = neo4jInstanceFactory.Create(neo4jFolder, neo4jVersion, endpoints); Add(id, instance); return(instance); }
public static void Extract(Neo4jVersion neo4jVersion, string neo4jBasePath) { var zipFile = Path.Combine(neo4jBasePath, neo4jVersion.ZipFileName); var extractFolder = Path.Combine(neo4jBasePath, Path.GetFileNameWithoutExtension(neo4jVersion.ZipFileName)); if (Directory.Exists(extractFolder)) { return; } Console.WriteLine($"Extracting Neo4j from {neo4jVersion.ZipFileName} to {extractFolder}"); ZipFile.ExtractToDirectory(zipFile, extractFolder); }
public INeo4jInstance Create(string neo4jFolder, Neo4jVersion neo4jVersion, Neo4jEndpoints endpoints) { INeo4jInstance instance; switch (neo4jVersion.Architecture) { case Neo4jArchitecture.V3: instance = new Neo4jV3JavaInstanceProvider(javaPath, neo4jFolder, fileCopy, neo4jVersion, endpoints); const string configFile = Neo4jV3ProcessBasedInstanceProvider.Neo4jConfigFile; instance.Configure(configFile, "dbms.security.auth_enabled", "false"); instance.Configure(configFile, "dbms.allow_format_migration", "true"); instance.Configure(configFile, "dbms.directories.import", ""); instance.Configure(configFile, "dbms.connector.http.listen_address", $":{endpoints.HttpEndpoint.Port}"); if (endpoints.BoltEndpoint != null) { instance.Configure(configFile, "dbms.connector.bolt.listen_address", $":{endpoints.BoltEndpoint.Port}"); instance.Configure(configFile, "dbms.connector.bolt.enabled", "true"); } else { instance.Configure(configFile, "dbms.connector.bolt.enabled", "false"); } if (endpoints.HttpsEndpoint != null) { instance.Configure(configFile, "dbms.connector.https.listen_address", $":{endpoints.HttpsEndpoint.Port}"); instance.Configure(configFile, "dbms.connector.https.enabled", "true"); } else { instance.Configure(configFile, "dbms.connector.https.enabled", "false"); } break; default: throw new ArgumentException($"Architecture: {neo4jVersion.Architecture} unknown"); } return(instance); }
public static void Download(Neo4jVersion neo4jVersion, string neo4jBasePath) { var zipFile = Path.Combine(neo4jBasePath, neo4jVersion.ZipFileName); if (File.Exists(zipFile)) { return; } Console.WriteLine($"Downloading Neo4j from {neo4jVersion.DownloadUrl}"); var fileInfo = new FileInfo(zipFile); Directory.CreateDirectory(fileInfo.DirectoryName); using (var webClient = new WebClient()) { webClient.DownloadFile(neo4jVersion.DownloadUrl, zipFile); } }
private static void Main() { var tokenSource = new CancellationTokenSource(); var ct = tokenSource.Token; var neo4jV3 = new Neo4jVersion { Architecture = Neo4jArchitecture.V3, DownloadUrl = "https://neo4j.com/artifact.php?name=neo4j-community-3.5.3-windows.zip", Version = "3.5.3", ZipFileName = "neo4j-community-3.5.3-windows.zip" }; var config = new Neo4jManagerConfig { Neo4jBasePath = @"c:\Neo4jManager", StartBoltPort = 7687, StartHttpPort = 7401 }; var instanceFactory = new Neo4jInstanceFactory(new FileCopy()); using (var pool = new Neo4jDeploymentsPool(config, instanceFactory)) { pool.DeleteAll(); pool.Create(neo4jV3, "1"); pool.Create(neo4jV3, "2"); pool.Create(neo4jV3, "3"); pool.Create(neo4jV3, "4"); var task1 = Process(pool.Single(p => p.Key == "1"), ct); var task2 = Process(pool.Single(p => p.Key == "2"), ct); var task3 = Process(pool.Single(p => p.Key == "3"), ct); var task4 = Process(pool.Single(p => p.Key == "4"), ct); Task.WhenAll(task1, task2, task3, task4).Wait(ct); pool.DeleteAll(); } }
public static async Task DownloadAsync(Neo4jVersion neo4jVersion, string neo4jBasePath) { var zipFile = Path.Combine(neo4jBasePath, neo4jVersion.ZipFileName); if (File.Exists(zipFile)) { return; } Console.WriteLine($"Downloading Neo4j from {neo4jVersion.DownloadUrl}"); var fileInfo = new FileInfo(zipFile); Directory.CreateDirectory(fileInfo.DirectoryName); var fileBytes = await neo4jVersion.DownloadUrl.GetBytesFromUrlAsync(); using (var SourceStream = File.Open(zipFile, FileMode.OpenOrCreate)) { SourceStream.Seek(0, SeekOrigin.End); await SourceStream.WriteAsync(fileBytes, 0, fileBytes.Length); } }
public static void CopyDeployment(Neo4jVersion neo4jVersion, string neo4jBasePath, string targetDeploymentPath) { var extractFolder = Path.Combine(neo4jBasePath, Path.GetFileNameWithoutExtension(neo4jVersion.ZipFileName)); new FileCopy().MirrorFolders(extractFolder, targetDeploymentPath); }