-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basic ArcadeDB server implementation
- Loading branch information
1 parent
6402705
commit b16d55e
Showing
12 changed files
with
752 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "maven" | ||
directory: "/src/" | ||
target-branch: "develop" | ||
schedule: | ||
interval: "daily" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: Create release on version tag and publish core package | ||
on: | ||
push: | ||
# Sequence of patterns matched against refs/tags | ||
tags: | ||
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 | ||
jobs: | ||
build: | ||
name: Create Release | ||
runs-on: ubuntu-latest | ||
if: github.repository == 'BioDWH2/BioDWH2-ArcadeDB-Server' # Only run on main repository and not forks | ||
steps: | ||
- name: Retrieve tag name | ||
id: tag_name | ||
uses: little-core-labs/[email protected] | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ steps.tag_name.outputs.tag }} | ||
release_name: Release ${{ steps.tag_name.outputs.tag }} | ||
draft: false | ||
prerelease: false | ||
- uses: actions/setup-java@v1 | ||
with: | ||
java-version: 11 | ||
- name: Build with Maven | ||
env: | ||
USENAME: ${{ github.actor }} | ||
PASSWORD: ${{ secrets.GITHUB_TOKEN }} | ||
run: mvn package -DskipTests --file src/pom.xml --settings src/settings.xml | ||
- name: Upload Release Asset | ||
id: upload-release-asset | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./src/target/BioDWH2-ArcadeDB-Server-${{ steps.tag_name.outputs.tag }}.jar | ||
asset_name: BioDWH2-ArcadeDB-Server-${{ steps.tag_name.outputs.tag }}.jar | ||
asset_content_type: application/java-archive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: Java CI | ||
on: [push] | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: 11 | ||
- name: Build with Maven | ||
env: | ||
USENAME: ${{ github.actor }} | ||
PASSWORD: ${{ secrets.GITHUB_TOKEN }} | ||
run: mvn package --file src/pom.xml --settings src/settings.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>de.unibi.agbi.biodwh2.arcadedb.server</groupId> | ||
<artifactId>BioDWH2-ArcadeDB-Server</artifactId> | ||
<version>1.0.0</version> | ||
|
||
<build> | ||
<finalName>BioDWH2-ArcadeDB-Server-v${project.version}</finalName> | ||
<plugins> | ||
<plugin> | ||
<groupId>com.github.jinnovations</groupId> | ||
<artifactId>attribution-maven-plugin</artifactId> | ||
<version>0.9.8</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>generate-attribution-file</goal> | ||
</goals> | ||
<phase>generate-resources</phase> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<outputFile>${project.build.directory}/attribution.xml</outputFile> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
<version>3.2.4</version> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>shade</goal> | ||
</goals> | ||
<configuration> | ||
<transformers> | ||
<transformer | ||
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/> | ||
<transformer | ||
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> | ||
<mainClass>de.unibi.agbi.biodwh2.arcadedb.server.ArcadeDBServer</mainClass> | ||
<manifestEntries> | ||
<BioDWH2-version>${project.version}</BioDWH2-version> | ||
<BioDWH2-build-date>${maven.build.timestamp}</BioDWH2-build-date> | ||
</manifestEntries> | ||
</transformer> | ||
<transformer | ||
implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer"> | ||
<resource>META-INF/attribution.xml</resource> | ||
<file>${project.build.directory}/attribution.xml</file> | ||
</transformer> | ||
</transformers> | ||
<filters> | ||
<filter> | ||
<artifact>*:*</artifact> | ||
<excludes> | ||
<exclude>about.html</exclude> | ||
<exclude>META-INF/maven/</exclude> | ||
<exclude>META-INF/native/</exclude> | ||
<exclude>META-INF/native-image/</exclude> | ||
<exclude>META-INF/proguard/</exclude> | ||
<exclude>META-INF/versions/</exclude> | ||
<exclude>META-INF/*.SF</exclude> | ||
<exclude>META-INF/*.DSA</exclude> | ||
<exclude>META-INF/*.RSA</exclude> | ||
<exclude>META-INF/MANIFEST.MF</exclude> | ||
<exclude>META-INF/README*</exclude> | ||
<exclude>META-INF/CHANGES*</exclude> | ||
<exclude>META-INF/LICENSE*</exclude> | ||
<exclude>META-INF/NOTICE*</exclude> | ||
<exclude>META-INF/*.kotlin_module</exclude> | ||
<exclude>META-INF/io.netty.versions.properties</exclude> | ||
</excludes> | ||
</filter> | ||
</filters> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>de.unibi.agbi.biodwh2</groupId> | ||
<artifactId>biodwh2-core</artifactId> | ||
<version>0.4.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>info.picocli</groupId> | ||
<artifactId>picocli</artifactId> | ||
<version>4.6.2</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>commons-codec</groupId> | ||
<artifactId>commons-codec</artifactId> | ||
<version>1.15</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.arcadedb</groupId> | ||
<artifactId>arcadedb-server</artifactId> | ||
<version>21.11.1</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
<argLine>-XX:MaxDirectMemorySize=512g</argLine> | ||
</properties> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 | ||
http://maven.apache.org/xsd/settings-1.0.0.xsd"> | ||
|
||
<activeProfiles> | ||
<activeProfile>github</activeProfile> | ||
</activeProfiles> | ||
|
||
<profiles> | ||
<profile> | ||
<id>github</id> | ||
<repositories> | ||
<repository> | ||
<id>central</id> | ||
<url>https://repo1.maven.org/maven2</url> | ||
<releases><enabled>true</enabled></releases> | ||
<snapshots><enabled>true</enabled></snapshots> | ||
</repository> | ||
<repository> | ||
<id>BioDWH2 github</id> | ||
<name>GitHub Apache Maven Packages</name> | ||
<url>https://maven.pkg.github.com/biodwh2/biodwh2</url> | ||
<releases><enabled>true</enabled></releases> | ||
<snapshots><enabled>true</enabled></snapshots> | ||
</repository> | ||
</repositories> | ||
</profile> | ||
</profiles> | ||
|
||
<servers> | ||
<server> | ||
<id>BioDWH2 github</id> | ||
<username>${env.USERNAME}</username> | ||
<password>${env.PASSWORD}</password> | ||
</server> | ||
</servers> | ||
</settings> |
134 changes: 134 additions & 0 deletions
134
src/src/main/java/de/unibi/agbi/biodwh2/arcadedb/server/ArcadeDBServer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
package de.unibi.agbi.biodwh2.arcadedb.server; | ||
|
||
import de.unibi.agbi.biodwh2.core.net.BioDWH2Updater; | ||
import de.unibi.agbi.biodwh2.arcadedb.server.model.CmdArgs; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import picocli.CommandLine; | ||
|
||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
|
||
public class ArcadeDBServer { | ||
private static final Logger LOGGER = LoggerFactory.getLogger(ArcadeDBServer.class); | ||
|
||
private ArcadeDBServer() { | ||
} | ||
|
||
public static void main(final String... args) { | ||
final CmdArgs commandLine = parseCommandLine(args); | ||
new ArcadeDBServer().run(commandLine); | ||
} | ||
|
||
private static CmdArgs parseCommandLine(final String... args) { | ||
final CmdArgs result = new CmdArgs(); | ||
final CommandLine cmd = new CommandLine(result); | ||
cmd.parseArgs(args); | ||
return result; | ||
} | ||
|
||
private void run(final CmdArgs commandLine) { | ||
BioDWH2Updater.checkForUpdate("BioDWH2-ArcadeDB-Server", | ||
"https://api.github.com/repos/BioDWH2/BioDWH2-ArcadeDB-Server/releases"); | ||
if (commandLine.createStart != null) | ||
createAndStartWorkspaceServer(commandLine); | ||
else if (commandLine.start != null) | ||
startWorkspaceServer(commandLine); | ||
else if (commandLine.create != null) | ||
createWorkspaceDatabase(commandLine); | ||
else | ||
printHelp(commandLine); | ||
} | ||
|
||
private void createAndStartWorkspaceServer(final CmdArgs commandLine) { | ||
final String workspacePath = commandLine.createStart; | ||
if (!verifyWorkspaceExists(workspacePath)) { | ||
printHelp(commandLine); | ||
return; | ||
} | ||
final ArcadeDBService service = new ArcadeDBService(workspacePath); | ||
service.deleteOldDatabase(); | ||
service.startArcadeDBService(commandLine.port); | ||
service.createDatabase(); | ||
storeWorkspaceHash(workspacePath); | ||
service.openBrowser(); | ||
} | ||
|
||
private boolean verifyWorkspaceExists(final String workspacePath) { | ||
if (StringUtils.isEmpty(workspacePath) || !Paths.get(workspacePath).toFile().exists()) { | ||
if (LOGGER.isErrorEnabled()) | ||
LOGGER.error("Workspace path '" + workspacePath + "' was not found"); | ||
return false; | ||
} | ||
if (LOGGER.isInfoEnabled()) | ||
LOGGER.info("Using workspace directory '" + workspacePath + "'"); | ||
return true; | ||
} | ||
|
||
private void printHelp(final CmdArgs commandLine) { | ||
CommandLine.usage(commandLine, System.out); | ||
} | ||
|
||
private void storeWorkspaceHash(final String workspacePath) { | ||
if (LOGGER.isInfoEnabled()) | ||
LOGGER.info("Updating workspace ArcadeDB cache checksum..."); | ||
final Path hashFilePath = Paths.get(workspacePath, "arcadedb/checksum.txt"); | ||
try { | ||
final String hash = HashUtils.getFastPseudoHashFromFile( | ||
Paths.get(workspacePath, "sources/mapped.db").toString()); | ||
final FileWriter writer = new FileWriter(hashFilePath.toFile()); | ||
writer.write(hash); | ||
writer.close(); | ||
} catch (IOException e) { | ||
if (LOGGER.isErrorEnabled()) | ||
LOGGER.error("Failed to store hash of workspace mapped graph", e); | ||
} | ||
} | ||
|
||
private void startWorkspaceServer(final CmdArgs commandLine) { | ||
final String workspacePath = commandLine.start; | ||
if (!verifyWorkspaceExists(workspacePath)) { | ||
printHelp(commandLine); | ||
return; | ||
} | ||
if (!checkArcadeDBDatabaseMatchesWorkspace(workspacePath) && LOGGER.isInfoEnabled()) | ||
LOGGER.warn("The ArcadeDB database is out-of-date and should be recreated with the --create command"); | ||
final ArcadeDBService service = new ArcadeDBService(workspacePath); | ||
service.startArcadeDBService(commandLine.port); | ||
service.openBrowser(); | ||
} | ||
|
||
private boolean checkArcadeDBDatabaseMatchesWorkspace(final String workspacePath) { | ||
try { | ||
final String hash = HashUtils.getFastPseudoHashFromFile( | ||
Paths.get(workspacePath, "sources/mapped.db").toString()); | ||
final Path hashFilePath = Paths.get(workspacePath, "arcadedb/checksum.txt"); | ||
if (Files.exists(hashFilePath)) { | ||
final String storedHash = new String(Files.readAllBytes(hashFilePath)).trim(); | ||
return hash.equals(storedHash); | ||
} | ||
} catch (IOException e) { | ||
if (LOGGER.isWarnEnabled()) | ||
LOGGER.warn("Failed to check hash of workspace mapped graph", e); | ||
} | ||
return false; | ||
} | ||
|
||
private void createWorkspaceDatabase(final CmdArgs commandLine) { | ||
final String workspacePath = commandLine.create; | ||
if (!verifyWorkspaceExists(workspacePath)) { | ||
printHelp(commandLine); | ||
return; | ||
} | ||
final ArcadeDBService service = new ArcadeDBService(workspacePath); | ||
service.deleteOldDatabase(); | ||
service.startArcadeDBService(commandLine.port); | ||
service.createDatabase(); | ||
storeWorkspaceHash(workspacePath); | ||
service.stopArcadeDBService(); | ||
} | ||
} |
Oops, something went wrong.