Skip to content

Commit 52cb59d

Browse files
sbespalovsbespalov-chess
authored andcommitted
issues/1649: Migrate Strongbox from OrientDB to JanusGraph
1 parent 0723cb2 commit 52cb59d

File tree

82 files changed

+3802
-1375
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+3802
-1375
lines changed

Jenkinsfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def notifyBranch = [recipients: [brokenTestsSuspects(), requestor()]]
1212
pipeline {
1313
agent {
1414
node {
15-
label 'alpine-jdk8-mvn-3.5'
15+
label 'alpine-jdk8-mvn3.6'
1616
}
1717
}
1818
parameters {

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
# strongbox-db
22

33
## The goal of this project
4-
This project has been created in order speed up the building of the OrientDB database snapshots during the initial [Strongbox](https://github.com/strongbox/strongbox) startup. Before this project was born, it took some time to do all of the database changes from the beginning of time up until the most recent version, so that the OrientDB database structure would be populated properly.
4+
This project has been created in order speed up the building of the JanusGraph database snapshots during the initial [Strongbox](https://github.com/strongbox/strongbox) startup. Before this project was born, it took some time to do all of the database changes from the beginning of time up until the most recent version, so that the JanusGraph database structure would be populated properly.
55

66
## Architecture
77
This application consists of the following modules:
8-
* `strongbox-db-liquibase` which creates a `jar` file consiting of the liquibase changesets that construct the [Strongbox](https://github.com/strongbox/strongbox) OrientDB database schema
8+
* `strongbox-db-schema` which creates a `jar` file consiting of the changesets that construct the [Strongbox](https://github.com/strongbox/strongbox) JanusGraph database schema
99
* `strongbox-db-import` which creates a `zip` file with packed built database snapshot built from the liquibase changesets
1010

1111
## How is this project used in [strongbox](https://github.com/strongbox/strongbox) ?
12-
[strongbox](https://github.com/strongbox/strongbox) uses this project submodules as required dependencies. During the startup of [Strongbox](https://github.com/strongbox/strongbox), the application detects if an OrientDB database already exists. If not, then the application uses an extracted empty OrientDB database snapshot from the `strongbox-db-import` artifact. If the OrientDB database already exists, then the application applies all missing liquibase changesets from the `strongbox-db-liquibase` artifact.
12+
[strongbox](https://github.com/strongbox/strongbox) uses this project submodules as required dependencies. During the startup of [Strongbox](https://github.com/strongbox/strongbox), the application detects if a JanusGraph database already exists. If one doesn't exist, it uses an extracted empty JanusGraph database snapshot from the `strongbox-db-import` artifact; if a database exists, then the application applies all missing changesets from the `strongbox-db-schema` artifact.
1313

1414
## How to build this project ?
1515
To build the code, simply execute:
1616
`mvn clean install`
1717

1818
## What's the result of the build process ?
1919
This project produces the following artifacts:
20-
* `strongbox-db-liquibase-${version}.jar` : Located in `strongbox-db-liquibase/target`, which contains current database liquibase changesets
20+
* `strongbox-db-schema-${version}.jar` : Located in `strongbox-db-schema/target`, which contains current database changesets
2121
* `strongbox-db-import-${version}.zip` : Located in `strongbox-db-import/target`, which contains zipped fresh database snapshot built from the above changesets

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
<parent>
77
<groupId>org.carlspring.strongbox</groupId>
88
<artifactId>strongbox-parent</artifactId>
9-
<version>1.0-SNAPSHOT</version>
9+
<version>1.0-PR-62-SNAPSHOT</version>
1010
</parent>
1111

1212
<artifactId>strongbox-db</artifactId>
1313
<packaging>pom</packaging>
14-
<version>1.0-SNAPSHOT</version>
14+
<version>1.0-PR-19-SNAPSHOT</version>
1515

1616
<properties>
1717
<serverId />
@@ -48,7 +48,7 @@
4848
</dependencies>
4949

5050
<modules>
51-
<module>strongbox-db-liquibase</module>
51+
<module>strongbox-db-schema</module>
5252
<module>strongbox-db-import</module>
5353
<module>strongbox-db-server</module>
5454
</modules>

strongbox-db-import/pom.xml

Lines changed: 8 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -8,87 +8,38 @@
88
<parent>
99
<groupId>org.carlspring.strongbox</groupId>
1010
<artifactId>strongbox-db</artifactId>
11-
<version>1.0-SNAPSHOT</version>
11+
<version>1.0-PR-19-SNAPSHOT</version>
1212
<relativePath>../pom.xml</relativePath>
1313
</parent>
1414

1515
<artifactId>strongbox-db-import</artifactId>
1616
<inceptionYear>2019</inceptionYear>
1717

18-
<properties>
19-
<strongbox.orientdb.path>${project.build.directory}/db</strongbox.orientdb.path>
20-
</properties>
21-
2218
<dependencies>
2319
<dependency>
2420
<groupId>${project.groupId}</groupId>
25-
<artifactId>strongbox-db-liquibase</artifactId>
21+
<artifactId>strongbox-db-server</artifactId>
2622
<version>${project.version}</version>
2723
</dependency>
2824
<dependency>
2925
<groupId>${project.groupId}</groupId>
30-
<artifactId>strongbox-db-server</artifactId>
26+
<artifactId>strongbox-db-schema</artifactId>
3127
<version>${project.version}</version>
3228
</dependency>
33-
29+
3430
<dependency>
3531
<groupId>org.springframework.boot</groupId>
36-
<artifactId>spring-boot-starter-jdbc</artifactId>
37-
</dependency>
38-
39-
<dependency>
40-
<groupId>com.orientechnologies</groupId>
41-
<artifactId>orientdb-jdbc</artifactId>
32+
<artifactId>spring-boot-starter</artifactId>
4233
</dependency>
4334

4435
<dependency>
4536
<groupId>commons-beanutils</groupId>
4637
<artifactId>commons-beanutils</artifactId>
4738
</dependency>
4839

49-
<!-- liquibase -->
50-
<dependency>
51-
<groupId>org.apache.ant</groupId>
52-
<artifactId>ant</artifactId>
53-
<version>1.10.5</version>
54-
</dependency>
55-
<dependency>
56-
<groupId>org.liquibase</groupId>
57-
<artifactId>liquibase-core</artifactId>
58-
<exclusions>
59-
<exclusion>
60-
<groupId>org.apache.ant</groupId>
61-
<artifactId>ant</artifactId>
62-
</exclusion>
63-
</exclusions>
64-
</dependency>
65-
<dependency>
66-
<groupId>org.unbroken-dome.liquibase-orientdb</groupId>
67-
<artifactId>liquibase-orientdb</artifactId>
68-
</dependency>
69-
<dependency>
70-
<groupId>com.mattbertolini</groupId>
71-
<artifactId>liquibase-slf4j</artifactId>
72-
</dependency>
73-
<dependency>
74-
<groupId>org.hibernate.validator</groupId>
75-
<artifactId>hibernate-validator</artifactId>
76-
</dependency>
77-
78-
<!-- helpers -->
79-
<dependency>
80-
<groupId>org.apache.commons</groupId>
81-
<artifactId>commons-lang3</artifactId>
82-
</dependency>
8340
</dependencies>
8441

8542
<build>
86-
<resources>
87-
<resource>
88-
<directory>src/main/resources</directory>
89-
<filtering>true</filtering>
90-
</resource>
91-
</resources>
9243
<plugins>
9344
<plugin>
9445
<groupId>org.springframework.boot</groupId>
@@ -102,6 +53,9 @@
10253
</goals>
10354
<configuration>
10455
<jvmArguments>-Xmx1024m</jvmArguments>
56+
<arguments>
57+
--strongbox.dbimport.root=${project.build.directory}
58+
</arguments>
10559
</configuration>
10660
</execution>
10761
</executions>

strongbox-db-import/src/main/assembly/db-schema.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
</formats>
1010
<fileSets>
1111
<fileSet>
12-
<directory>${project.build.directory}/db/strongbox</directory>
13-
<outputDirectory>META-INF/resources/strongbox/db/strongbox</outputDirectory>
12+
<directory>${project.build.directory}/db</directory>
13+
<outputDirectory>META-INF/org/carlsparing/strongbox/db</outputDirectory>
1414
</fileSet>
1515
</fileSets>
1616
</assembly>

strongbox-db-import/src/main/java/org/carlspring/strongbox/db/orient/OrientDbConfiguration.java

Lines changed: 0 additions & 106 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
1-
package org.carlspring.strongbox.db;
1+
package org.carlspring.strongbox.dbimport;
22

3+
import org.janusgraph.core.JanusGraph;
34
import org.springframework.boot.SpringApplication;
45
import org.springframework.boot.autoconfigure.SpringBootApplication;
6+
import org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration;
57
import org.springframework.context.ConfigurableApplicationContext;
68

79
/**
810
* @author Przemyslaw Fusik
911
*/
10-
@SpringBootApplication
12+
@SpringBootApplication(exclude = ValidationAutoConfiguration.class)
1113
public class Application
1214
{
1315

1416
public static void main(String[] args)
1517
{
1618
ConfigurableApplicationContext ctx = SpringApplication.run(Application.class, args);
19+
ctx.getBean(JanusGraph.class);
20+
1721
SpringApplication.exit(ctx, () -> 0);
1822
}
1923
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package org.carlspring.strongbox.dbimport;
2+
3+
import java.io.IOException;
4+
import java.nio.file.Path;
5+
import java.nio.file.Paths;
6+
7+
import org.carlspring.strongbox.db.schema.StrongboxSchema;
8+
import org.janusgraph.core.JanusGraph;
9+
import org.springframework.beans.factory.annotation.Value;
10+
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
11+
import org.springframework.context.annotation.Bean;
12+
import org.springframework.context.annotation.Configuration;
13+
import org.strongbox.db.server.CassandraEmbeddedConfiguration;
14+
import org.strongbox.db.server.CassandraEmbeddedProperties;
15+
import org.strongbox.db.server.JanusGraphConfiguration;
16+
import org.strongbox.db.server.JanusGraphProperties;
17+
import org.strongbox.db.server.JanusGraphServer;
18+
import org.strongbox.db.server.JanusGraphWithEmbeddedCassandra;
19+
import org.strongbox.util.ConfigurationUtils;
20+
21+
/**
22+
* @author Przemyslaw Fusik
23+
* @author sbespalov
24+
*/
25+
@Configuration
26+
@ConfigurationPropertiesScan
27+
class EmbeddedDbServerConfiguration
28+
{
29+
30+
@Bean
31+
JanusGraphServer embeddedDbServer(CassandraEmbeddedConfiguration cassandraConfiguration,
32+
JanusGraphConfiguration janusGraphConfiguration)
33+
throws IOException
34+
{
35+
return new JanusGraphWithEmbeddedCassandra(cassandraConfiguration, janusGraphConfiguration);
36+
}
37+
38+
@Bean
39+
JanusGraph janusGraph(JanusGraphServer server)
40+
throws Exception
41+
{
42+
return new StrongboxSchema().createSchema(server.getJanusGraph());
43+
}
44+
45+
@Bean
46+
JanusGraphProperties dbImportJanusGraphProperties(@Value("${strongbox.dbimport.root}") String dbImportRoot)
47+
throws IOException
48+
{
49+
ConfigurationUtils.extractConfigurationFile(dbImportRoot, "janusgraph-cassandra.properties");
50+
Path configFilePath = Paths.get(dbImportRoot).resolve("etc").resolve("conf").resolve("janusgraph-cassandra.properties");
51+
52+
return new JanusGraphProperties( String.format("file:%s", configFilePath.toAbsolutePath().toString()));
53+
}
54+
55+
@Bean
56+
CassandraEmbeddedProperties dbImportCassandraEmbeddedProperties(@Value("${strongbox.dbimport.root}") String dbImportRoot)
57+
throws IOException
58+
{
59+
ConfigurationUtils.extractConfigurationFile(dbImportRoot, "cassandra.yaml");
60+
Path rootPath = Paths.get(dbImportRoot).toAbsolutePath();
61+
Path configFilePath = rootPath.resolve("etc").resolve("conf").resolve("cassandra.yaml");
62+
Path storageRootPath = rootPath.resolve("db");
63+
64+
return new CassandraEmbeddedProperties(storageRootPath.toString(), String.format("file:%s", configFilePath.toString()));
65+
}
66+
67+
}

0 commit comments

Comments
 (0)