Skip to content

Commit

Permalink
Merge Github
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Breu authored and TasDeniz committed Nov 27, 2020
1 parent d337e07 commit dadafe9
Show file tree
Hide file tree
Showing 227 changed files with 5,268 additions and 3,321 deletions.
22 changes: 22 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: 2
jobs:
build:
docker:
- image: circleci/openjdk:8-jdk
- image: postgres:9.6
environment:
POSTGRES_USER: samply
POSTGRES_PASSWORD: samply
POSTGRES_DB: samply.connector

working_directory: ~/repo

steps:
- checkout

- run: mvn -B package

- setup_remote_docker
- run: docker build -t martinbreu/samply-connector:${CIRCLE_SHA1} .
- run: docker login -u martinbreu -p "${DOCKER_HUB_PASSWD}"
- run: docker push martinbreu/samply-connector:${CIRCLE_SHA1}
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*
!src/docker
!target/connector
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.sh text eol=lf
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM tomcat:8.5.32-jre8-alpine

ADD target/connector /usr/local/tomcat/webapps/ROOT/

ADD src/docker/context.xml /usr/local/tomcat/conf/Catalina/localhost/ROOT.xml
ADD src/docker/context.xml /usr/local/tomcat/webapps/ROOT/META-INF/context.xml
ADD src/docker/server.xml /usr/local/tomcat/conf

ADD src/docker/samply_common_urls.xml /root/.config/samply/
ADD src/docker/samply_common_operator.xml /root/.config/samply/
ADD src/docker/samply_common_config.xml /root/.config/samply/
ADD src/docker/samply_bridgehead_info.xml /root/.config/samply/
ADD src/docker/mailSending.xml /root/.config/samply/

# JMX Exporter
ENV JMX_EXPORTER_VERSION 0.3.1
COPY src/docker/jmx-exporter.yml /samply/jmx-exporter.yml
ADD https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaagent/$JMX_EXPORTER_VERSION/jmx_prometheus_javaagent-$JMX_EXPORTER_VERSION.jar /samply/

ADD src/docker/start.sh /samply/
RUN chmod +x /samply/start.sh

CMD ["/samply/start.sh"]
148 changes: 51 additions & 97 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,110 +1,64 @@
# Samply Share Client

Samply Share Client (also referenced as "Teiler" in certain contexts) is part of a bridgehead
infrastructure. It poses as the interface between the local components (mainly, the local
datamanagement) and central components like searchbrokers for the decentral search infrastructure

# Features

- Connect to any amount of search brokers to participate in the decentral search
- Generate quality reports to monitor data quality of your local datasets
- Upload a defined set of attributes (**M**elde**d**aten**s**atz) to a central database

# Build

In order to build this project, you need to configure maven properly and use the maven profile that
fits to your project.

During the build process, the jooq plugin will update the database-related files according to the database
configured in _pom.xml_. So you have to create the necessary tables and relations first. This
can be done via the flyway plugin.

```
mvn flyway:migrate
[![Docker Pulls](https://img.shields.io/docker/pulls/martinbreu/samply-connector.svg)](https://hub.docker.com/r/martinbreu/samply-connector/)
[![CircleCI](https://circleci.com/gh/martinbreu/samply-connector/tree/master.svg?style=svg)](https://circleci.com/gh/martinbreu/samply-connector/tree/master)

# Connector

A Samply.Connector Docker image based on [tomcat:8.5.32-jre8-alpine][1]. The Samply.Connector is configured alike that one from the windows installer. The Postgres database has to be supplied in another Docker container. The connection settings are given by environment variables which are documented below.

## Environment

* POSTGRES_HOST - the host name of the Postgres DB
* POSTGRES_PORT - the port of the Postgres DB, defaults to `5432`
* POSTGRES_DB - the database name, defaults to `samply`
* POSTGRES_USER - the database username, defaults to `samply`
* POSTGRES_PASS - the database password, defaults to `samply`
* STORE_URL - the URL of the store to connect to
* MDR_URL - the URL of the mdr to connect to
* CATALINA_OPTS - JVM options for Tomcat like `-Xmx8g`
* OPERATOR_FIRST_NAME - the IT staff which runs the connector
* OPERATOR_LAST_NAME - the IT staff which runs the connector
* OPERATOR_EMAIL - the IT staff which runs the connector
* OPERATOR_PHONE - the IT staff which runs the connector
* HTTP_PROXY - the URL of the HTTP proxy to use for outgoing connections; enables proxy usage if set
* PROXY_USER - the user of the proxy account (optional)
* PROXY_PASS - the password of the proxy account (optional)
* MAIL_HOST - mail host which is able to send mails, defaults to ``
* MAIL_PORT - port to mail host, defaults to ``
* MAIL_PROTOCOL - protocol for mail, defaults to ``
* MAIL_FROM_ADDRESS - mail address from which mails are sent, defaults to ``
* MAIL_FROM_NAME - subject of mails, defaults to ``

### Proxy

You can configure your proxy in `~/.docker/config.json` as described [here][4].

## Usage

```sh
docker run -p 8080:8080 -e POSTGRES_HOST=<host> -e POSTGRES_PASS=<password> akiel/samply.connector:latest
```

Make sure to generate the Manifest file before, so that the project context will be set. Do so with
Open the following URL in a Browser:

```
mvn war:manifest -P<projectname>
```

Then, to build the war:

```
mvn clean package -P<projectname>
http://localhost:8080/gba-connector/login.xhtml
```

# Configuration
You should see the login page. The default username and password is `admin` and `adminpass`.

To configure your instance of Samply Share Client, you have to take care of the following settings.
The necessary tables, sequences and types will be created upon startup, given the configured user (see
below in _context.xml_) has the respecitve privileges.
You can register your Connector with the Search Broker under the following address: `https://search.germanbiobanknode.de/broker`.

### Database Connection
## Metrics

The database connection uses a connection pool, for which the datasource is defined in
_src/main/webapp/META-INF/context.xml_ and _src/main/webapp/WEB-INF/web.xml_. Samply Share Client uses
its own database schema, named "samply".
The Docker image contains an [agent][3] which exports various metrics of the JVM like memory statistics in a text format on port `9100`. After enabling metrics by setting `ENABLE_METRICS` to `true` and exporting port `9100`, the following command shows the metrics:

Your context.xml should resemble

```
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/">
<Resource name="jdbc/postgres" auth="Container"
type="javax.sql.DataSource" driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://<database_url>/<database_name>"
username="<username>" password="<password>" maxActive="50" maxIdle="20"
maxWait="-1" />
</Context>
```sh
curl http://localhost:9100/metrics
```

You have to set the parameters "database_url", "database_name", "username" and "password" according to
your setup

Your web.xml has to contain the following snippet
```
<!--Datasource definition-->
<resource-ref>
<description>postgreSQL Datasource</description>
<res-ref-name>jdbc/postgres</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
```
where the element "res-ref-name" has to be the exact same as the "name" Attribute from context.xml

### Network Settings

Network settings (i.e. proxy settings) are read from _<project-name>-common-config.xml_.

### URLs to other interfaces

#### Local Components

The URLs to other local components (ID-Management, Local Datamanagement) are read from
_<project-name>\_common\_urls.xml_.

#### Central Components

The connections to central components (Central MDS-Database, MDR, Decentral Searchbrokers) are
stored in the database. Some of them are read-only in the UI since they should rarely (or never) be
changed. You have to change them directly in the database.

# Jobs / Tasks / Triggers

Samply.Share.Client uses [Quartz](http://www.quartz-scheduler.org) to schedule Jobs. However,
an actual task (e.g. "execute an inquiry") consists of multiple jobs that are chained (in this case:
post inquiry to local datamanagement, check status, if necessary post again...).

All Jobs are defined in _/src/main/resources/quartz-jobs.xml_ without any triggers. Thus, all jobs have to be
declared as _durable_, to make sure the scheduler knows them. For jobs that run "on their own"
(e.g. inquiry collection), the cron expression has to be set in the database (table _job_schedule_).
To make the cron-expression changeable by the admin, set the "SHOW" entry of the job data map to true (like it is already
done for some jobs in the xml file).

For jobs that are spawned by other means (e.g. jobs or user interaction), the triggers are set programmatically.
The metrics should be polled by a [Prometheus][2] instance.

To learn more about jobs and triggers in quartz, check
[this tutorial page](https://www.quartz-scheduler.net/documentation/quartz-2.x/tutorial/jobs-and-triggers.html)
[1]: <https://hub.docker.com/_/tomcat/>
[2]: <https://prometheus.io>
[3]: <https://github.com/prometheus/jmx_exporter>
[4]: <https://docs.docker.com/network/proxy/>
74 changes: 35 additions & 39 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
<modelVersion>4.0.0</modelVersion>

<artifactId>share-client</artifactId>
<version>4.0.0-SNAPSHOT</version>
<version>3.0.7</version>
<packaging>war</packaging>
<name>${project.context}-share-client</name>

<parent>
<groupId>de.samply</groupId>
Expand All @@ -16,6 +15,7 @@
</parent>

<profiles>
<!-- ${project.context} also defines the folder where flyway looks for sql files -->
<profile>
<id>samply</id>
<activation>
Expand All @@ -36,42 +36,36 @@
<properties>
<project.context>osse</project.context>
<project.basename>OSSE.Share</project.basename>
<!-- general properties -->
<database.username>samplyshare</database.username>
<database.password>samplyshare</database.password>
<database.url>jdbc:postgresql://localhost:5432/samplyshare</database.url>
<database.schema>samply</database.schema>
</properties>
</profile>
<profile>
<id>dktk</id>
<properties>
<project.context>dktk</project.context>
<project.basename>DKTK.Teiler</project.basename>
</properties>
</profile>
<profile>
<id>gbn</id>
<properties>
<project.context>gbn</project.context>
<project.basename>GBN.Teiler</project.basename>
<!-- general properties -->
<database.username>samplyshare</database.username>
<database.password>samplyshare</database.password>
<database.url>jdbc:postgresql://localhost:5432/samplyshare</database.url>
<database.schema>samply</database.schema>
</properties>
</profile>
</profiles>


<properties>
<!-- Postgres settings -->
<database.username>${project.context}</database.username>
<database.password>${project.context}</database.password>
<database.url>jdbc:postgresql://localhost:5432/${project.context}.connector</database.url>
<database.schema>${project.context}</database.schema>

<!-- Samply dependencies -->
<version.samply.common.config>3.0.3-SNAPSHOT</version.samply.common.config>
<share-common.version>3.1.0</share-common.version>
<jsf-renderer.version>2.0.0</jsf-renderer.version>
<common-mailing.version>2.1.3-SNAPSHOT</common-mailing.version>
<common-mailing.version>2.0.0</common-mailing.version>
<common-http.version>5.0.0</common-http.version>
<common-ldmclient.centraxx.version>4.0.1</common-ldmclient.centraxx.version>
<common-ldmclient.samplystore.version>4.0.1</common-ldmclient.samplystore.version>
<common-ldmclient.samplystore.biobank.version>1.1.1</common-ldmclient.samplystore.biobank.version>
<common-ldmclient.samplystore.fhir.version>1.0.0-SNAPSHOT</common-ldmclient.samplystore.fhir.version>
<common-ldmclient.samplystore.biobank.version>1.1.0</common-ldmclient.samplystore.biobank.version>
<converter.dktk.patient.version>1.1.3</converter.dktk.patient.version>

<!-- general dependencies -->
Expand Down Expand Up @@ -109,7 +103,7 @@
</properties>

<build>
<finalName>${project.basename}-${project.version}</finalName>
<finalName>connector</finalName>
<resources>
<resource>
<directory>src/main/java</directory>
Expand Down Expand Up @@ -150,14 +144,6 @@
</execution>
</executions>
</plugin>
<!-- Skip tests because of jenkins error-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
Expand Down Expand Up @@ -278,16 +264,19 @@
</execution>
</executions>
</plugin>
<!-- Skip tests because of jenkins error-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>

<dependency>
<groupId>de.samply</groupId>
<artifactId>common-config</artifactId>
<version>${version.samply.common.config}</version>
</dependency>
<!-- JSF 2 -->
<dependency>
<groupId>com.sun.faces</groupId>
Expand Down Expand Up @@ -522,16 +511,23 @@
<artifactId>common-ldmclient.samplystore-biobank</artifactId>
<version>${common-ldmclient.samplystore.biobank.version}</version>
</dependency>
<dependency>
<groupId>de.samply</groupId>
<artifactId>samply.common.ldmclient.fhir</artifactId>
<version>${common-ldmclient.samplystore.fhir.version}</version>
</dependency>
<dependency>
<groupId>de.samply</groupId>
<artifactId>share-dto</artifactId>
<version>4.1.1-SNAPSHOT</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>samply-maven-oss-releases</id>
<name>Samply Maven Builds</name>
<url>https://maven.samply.de/nexus/content/repositories/oss-releases</url>
</repository>
<repository>
<id>samply-maven-oss-snapshots</id>
<name>Samply Maven Builds</name>
<url>https://maven.samply.de/nexus/content/repositories/oss-snapshots</url>
</repository>
</repositories>

</project>
Loading

0 comments on commit dadafe9

Please sign in to comment.