Пример #1
0
        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 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);
        }