-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from TiesNetwork/filatov-dev
Alpha release version 0.1.2-ALPHA
- Loading branch information
Showing
198 changed files
with
25,380 additions
and
416 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
File renamed without changes.
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 @@ | ||
/target/ |
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,46 @@ | ||
|
||
# intellij files | ||
/.idea/ | ||
/*.iml | ||
/*.ipr | ||
/*.iws | ||
|
||
# eclipse files | ||
/.project | ||
/.classpath | ||
/eclipse-build | ||
/.settings | ||
/.versionsBackup | ||
|
||
# netbeans files | ||
/nb-configuration.xml | ||
/nbactions.xml | ||
|
||
# gradle stuff | ||
/.gradle/ | ||
/build/ | ||
/generated-resources/ | ||
/private/ | ||
|
||
# maven stuff (to be removed when trunk becomes 4.x) | ||
/*-execution-hints.log | ||
/target/ | ||
/dependency-reduced-pom.xml | ||
|
||
# testing stuff | ||
/**/.local* | ||
/.vagrant/ | ||
|
||
# osx stuff | ||
/.DS_Store | ||
|
||
# needed in case docs build is run...maybe we can configure doc build to generate files under build? | ||
/html_docs | ||
|
||
# random old stuff that we should look at the necessity of... | ||
//tmp/ | ||
/backwards/ | ||
|
||
# virtualenv | ||
/.venv/ | ||
/*.versionsBackup |
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,46 @@ | ||
|
||
# intellij files | ||
/.idea/ | ||
/*.iml | ||
/*.ipr | ||
/*.iws | ||
|
||
# eclipse files | ||
/.project | ||
/.classpath | ||
/eclipse-build | ||
/.settings | ||
/.versionsBackup | ||
|
||
# netbeans files | ||
/nb-configuration.xml | ||
/nbactions.xml | ||
|
||
# gradle stuff | ||
/.gradle/ | ||
/build/ | ||
/generated-resources/ | ||
/private/ | ||
|
||
# maven stuff (to be removed when trunk becomes 4.x) | ||
/*-execution-hints.log | ||
/target/ | ||
/dependency-reduced-pom.xml | ||
|
||
# testing stuff | ||
/**/.local* | ||
/.vagrant/ | ||
|
||
# osx stuff | ||
/.DS_Store | ||
|
||
# needed in case docs build is run...maybe we can configure doc build to generate files under build? | ||
/html_docs | ||
|
||
# random old stuff that we should look at the necessity of... | ||
//tmp/ | ||
/backwards/ | ||
|
||
# virtualenv | ||
/.venv/ | ||
/*.versionsBackup |
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,56 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright © 2017 Ties BV | ||
This file is part of Ties.DB project. | ||
Ties.DB project is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
Ties.DB project is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License along | ||
with Ties.DB project. If not, see <https://www.gnu.org/licenses/lgpl-3.0>. | ||
--> | ||
<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> | ||
|
||
<parent> | ||
<groupId>com.tiesdb.coordinator</groupId> | ||
<artifactId>core-impl</artifactId> | ||
<version>0.1.2-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>coordinator-bootstrap</artifactId> | ||
|
||
<name>TiesDB Coordinator Bootstrap</name> | ||
<description>TiesDB Coordinator boot sequence for standalone execution</description> | ||
|
||
<licenses> | ||
<license> | ||
<name>GNU Lesser General Public License, Version 3.0</name> | ||
<url>http://www.gnu.org/licenses/lgpl-3.0.txt</url> | ||
</license> | ||
</licenses> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.tiesdb</groupId> | ||
<artifactId>core-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
49 changes: 49 additions & 0 deletions
49
coordinator/core/impl/coordinator-bootstrap/src/main/java/com/tiesdb/TiesDB.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,49 @@ | ||
/** | ||
* Copyright © 2017 Ties BV | ||
* | ||
* This file is part of Ties.DB project. | ||
* | ||
* Ties.DB project is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Ties.DB project is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with Ties.DB project. If not, see <https://www.gnu.org/licenses/lgpl-3.0>. | ||
*/ | ||
package com.tiesdb; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import com.tiesdb.coordinator.bootstrap.TiesBootstrap; | ||
|
||
import network.tiesdb.exception.TiesStartupException; | ||
|
||
/** | ||
* TiedDB Daemon Main Class. | ||
* | ||
* <P> | ||
* Entry point to run TiesDB with underlying services. | ||
* | ||
* @author Anton Filatov (filatov@ties.network) | ||
*/ | ||
public class TiesDB { | ||
|
||
private static final Logger logger = LoggerFactory.getLogger(TiesDB.class); | ||
|
||
public static void main(String[] args) { | ||
try { | ||
new TiesBootstrap().init(args); | ||
} catch (TiesStartupException e) { | ||
logger.error("TiesDB failed", e); | ||
System.exit(e.getExitCode()); | ||
} | ||
} | ||
|
||
} |
54 changes: 54 additions & 0 deletions
54
...l/coordinator-bootstrap/src/main/java/com/tiesdb/coordinator/bootstrap/TiesBootstrap.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,54 @@ | ||
/** | ||
* Copyright © 2017 Ties BV | ||
* | ||
* This file is part of Ties.DB project. | ||
* | ||
* Ties.DB project is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Ties.DB project is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with Ties.DB project. If not, see <https://www.gnu.org/licenses/lgpl-3.0>. | ||
*/ | ||
package com.tiesdb.coordinator.bootstrap; | ||
|
||
import java.util.concurrent.atomic.AtomicReference; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import network.tiesdb.context.api.TiesContext; | ||
import network.tiesdb.exception.TiesStartupException; | ||
|
||
/** | ||
* Bootstrap class for TiesDB. | ||
* | ||
* @author Anton Filatov (filatov@ties.network) | ||
*/ | ||
public class TiesBootstrap { | ||
|
||
private static final Logger logger = LoggerFactory.getLogger(TiesBootstrap.class); | ||
|
||
final AtomicReference<TiesContext> contextRef = new AtomicReference<>(); | ||
|
||
public void init(String... args) throws TiesStartupException { | ||
logger.debug("Launching TiesDB services"); | ||
initTiesDb(); | ||
logger.debug("TiesDB services launched successfully"); | ||
} | ||
|
||
// TODO add a parameter or make another function for synchronous | ||
// initialization | ||
private void initTiesDb() { | ||
ThreadGroup tiesThreadGroup = new ThreadGroup(Thread.currentThread().getThreadGroup(), "TiesDB"); | ||
Thread tiesInitThread = new Thread(tiesThreadGroup, new TiesInitialization(this), "TiesInitialization"); | ||
tiesInitThread.setDaemon(false); | ||
tiesInitThread.start(); | ||
} | ||
} |
115 changes: 115 additions & 0 deletions
115
...rdinator-bootstrap/src/main/java/com/tiesdb/coordinator/bootstrap/TiesContextHandler.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,115 @@ | ||
/** | ||
* Copyright © 2017 Ties BV | ||
* | ||
* This file is part of Ties.DB project. | ||
* | ||
* Ties.DB project is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Ties.DB project is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with Ties.DB project. If not, see <https://www.gnu.org/licenses/lgpl-3.0>. | ||
*/ | ||
package com.tiesdb.coordinator.bootstrap; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.net.URL; | ||
import java.util.Set; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import network.tiesdb.context.api.TiesServiceConfig; | ||
import network.tiesdb.context.api.TiesContext; | ||
import network.tiesdb.context.api.TiesContextFactory; | ||
import network.tiesdb.exception.TiesConfigurationException; | ||
|
||
/** | ||
* TiesDB context wrapper. | ||
* | ||
* <P> | ||
* Contains some utility methods for TiesDB context handling. | ||
* | ||
* @author Anton Filatov (filatov@ties.network) | ||
*/ | ||
public class TiesContextHandler { | ||
|
||
private static final Logger logger = LoggerFactory.getLogger(TiesContextHandler.class); | ||
|
||
public static interface TiesContextHandlerFactory { | ||
TiesContextHandler createHandler(TiesContextFactory contextFactory, URL contextUrl) throws TiesConfigurationException; | ||
} | ||
|
||
private static TiesContextHandlerFactory factory = new TiesContextHandlerFactory() { | ||
@Override | ||
public TiesContextHandler createHandler(TiesContextFactory contextFactory, URL contextUrl) throws TiesConfigurationException { | ||
return new TiesContextHandler(contextFactory, contextUrl); | ||
} | ||
}; | ||
|
||
public static TiesContextHandlerFactory getFactory() { | ||
return factory; | ||
} | ||
|
||
public static void setFactory(TiesContextHandlerFactory newFactory) { | ||
if (null == newFactory) { | ||
throw new NullPointerException("The newFactory should not be null"); | ||
} | ||
factory = newFactory; | ||
} | ||
|
||
private final TiesContext context; | ||
|
||
protected TiesContextHandler(TiesContextFactory contextService, URL contextUrl) throws TiesConfigurationException { | ||
this(initContext(contextService, contextUrl)); | ||
} | ||
|
||
public TiesContextHandler(TiesContext context) { | ||
if (null == context) { | ||
throw new NullPointerException("The context should not be null"); | ||
} | ||
this.context = context; | ||
} | ||
|
||
public TiesServiceConfig getConfig(String name) { | ||
return context.getConfig().get(name); | ||
} | ||
|
||
protected static TiesContext initContext(TiesContextFactory contextService, URL contextUrl) throws TiesConfigurationException { | ||
if (null == contextService) { | ||
throw new NullPointerException("The contextService should not be null"); | ||
} | ||
if (null == contextUrl) { | ||
throw new NullPointerException("The contextUrl should not be null"); | ||
} | ||
TiesContext context = null; | ||
try (InputStream is = contextUrl.openStream()) { | ||
context = contextService.readContext(is); | ||
} catch (IOException e) { | ||
throw new TiesConfigurationException("Context initialization failed", e); | ||
} | ||
if (null == context) { | ||
throw new TiesConfigurationException("TiesDB Service settings could not be read from " + contextUrl); | ||
} | ||
logger.debug("TiesDB Service settings read from {}", contextUrl); | ||
if (null == context.getConfig() || context.getConfig().isEmpty()) { | ||
throw new TiesConfigurationException("TiesDB Service settings configuration is missing"); | ||
} | ||
return context; | ||
} | ||
|
||
public Set<String> getConfigsNames() { | ||
return context.getConfig().keySet(); | ||
} | ||
|
||
public TiesContext getDelegate() { | ||
return context; | ||
} | ||
} |
Oops, something went wrong.