Skip to content

Commit

Permalink
Merge pull request #21 from TiesNetwork/filatov-dev
Browse files Browse the repository at this point in the history
Alpha release version 0.1.2-ALPHA
  • Loading branch information
ya-enot committed Dec 21, 2018
2 parents db67395 + 5701063 commit abe975d
Show file tree
Hide file tree
Showing 198 changed files with 25,380 additions and 416 deletions.
2 changes: 1 addition & 1 deletion client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<parent>
<groupId>com.tiesdb</groupId>
<artifactId>parent</artifactId>
<version>0.1.1-SNAPSHOT</version>
<version>0.1.2-SNAPSHOT</version>
</parent>

<artifactId>client</artifactId>
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions coordinator/core/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target/
46 changes: 46 additions & 0 deletions coordinator/core/impl/.gitignore
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
46 changes: 46 additions & 0 deletions coordinator/core/impl/coordinator-bootstrap/.gitignore
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
56 changes: 56 additions & 0 deletions coordinator/core/impl/coordinator-bootstrap/pom.xml
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>
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());
}
}

}
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();
}
}
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;
}
}
Loading

0 comments on commit abe975d

Please sign in to comment.