Bird eye view of how the smarthub-server component works: 

  1. reads configuration of systems, services, result mappings etc on startup from a configured datasource.
  2. periodically (every 2 seconds) check for new invocations
  3. executes invocation
  4. transfers invocation result (which is basically the rest api call response) according to the mapping rules
  5. saves the transformed data as SmartSourceTable, SmartSourceRow and SmartSourceColumn instances. As of now this is done via JPA/JDBC into the ToolSuite database.

Configuration sources

The application can read configuration can be read from various sources:

  • classpath: if the configuration files are on the classpath (packaged with the application) 
  • filesystem: if the configuration files are on the FS
  • git repository: if the configuration files are stored in a git repository.
    However, smarthub-server access git raw content via a HTTP API (REST) which is not standard.
    Hence, currently only BitBucket and Azure DevOps Git Repositories are supported. 

SmartHub configuration root

This is the entry file to load the configuration. As you will see below it is either in the /import.json file of your configuration git repository or you may overwrite that with the SMARTHUB_CONFIG_ROOT property, i.e. when you would like it to be loaded from the filesystem. It is not necessary to place all the configuration into this file, you can partition your configuration into different json files and reference those file in the configuration root. For example:

{
"systems" : ["file:///etc/smarthub/config/systems/example1.json", "file:///etc/smarthub/config/systems/mock-server.json", "file:///etc/smarthub/config/systems/local-mock-server.json"]
}

The rule is that one system cannot be split into several files, but several systems can be in one file. 

config.properties

The main config file of the application, this is stored with the application sources and packaged with application. Stores configuration of the config source, default values and git repository access. 
Expressions denoted with ${...} can refer to both environment variables or java system properites.

In the below configuration the environment name is passed from the GOCOMPLIANT_ENVIRONMENT env variable. The configuration (root) source is in the import.json file of the azure git repository that has branches corresponding to each environment. The access credentials for the Azure Git repo as passed in as AZ_USERNAME and AZ_PERSONAL_ACCESS_TOKEN env vars. The properties of ExternalSystem.defaults.* are default values which are applied in case the corresponding property of an ExternalSystem entity is not set.

#stage, either of DEV/IT/UAT/PROD
environment.stage=#{env['GOCOMPLIANT_ENVIRONMENT']}
#Basic auth username for http API access
BasicAuthenticationFilter.smartHubApiUserName=#{env['SMARTHUB_API_BASIC_AUTH_USERNAME']}
#Basic auth username for http API access; support SHA-256, only needs to use the "SHA:" prefix;
#use "echo -n ... | shasum -a 256" to calculate that
BasicAuthenticationFilter.smartHubApiPassword=#{env['SMARTHUB_API_BASIC_AUTH_PASSWORD']}
# config root
# this expression takes "git://import.json" as default when the SMARTHUB_CONFIG_ROOT is not set
# to load from the file system set the env var SMARTHUB_CONFIG_ROOT to i.e. file://path/to/your/systems/config.json
dataInitializer.configRoot=#{env['SMARTHUB_CONFIG_ROOT'] ?: 'git://import.json'}
# max concurrent invocations to the same external system; default, can bo overwritten is system config
ExternalSystem.defaults.maxParallelCalls=1
# max retry attempts to call a service of the external system before marking the invocation as failed; default, can bo overwritten is system config
ExternalSystem.defaults.maxRetryAttempts=2
# duration to wait between retry attempts, in seconds
ExternalSystem.defaults.retryWaitSeconds=60
# duration after which the remote call times out, in seconds
ExternalSystem.defaults.readTimeoutSeconds=20
# Azure Git repo of configuration
Loader.git.provider=Azure
azure.git.url=https://dev.azure.com/goco/product/_apis/git/repositories/smarthub-config/items
azure.git.branch=#{env['GOCOMPLIANT_ENVIRONMENT']}
# credentials for authenticating against above Azure Git repository
azure.username=#{env['AZ_USERNAME']}
azure.personalAccessToken=#{env['AZ_PERSONAL_ACCESS_TOKEN']}
#Loader.git.provider=BitBucket
#bitbucket.config.repo.url=https://api.bitbucket.org/2.0/repositories/joergmattes/
#bitbucket.config.repository=smarthub-config
#bitbucket.config.branch=#{env['GOCOMPLIANT_ENVIRONMENT']}
#bitbucket.clientId=#{env['BITBUCKET_CLIENT_ID']}
#bitbucket.clientSecret=#{env['BITBUCKET_CLIENT_SECRET']}

Database configuration

Database connection urls, usernames and passwords are read from the below environments variables:

  • SmartHub database: to store service configurations, invocations and intermittent responses
    • SMARTHUB_JDBC_URL
    • SMARTHUB_JDBC_USERNAME
    • SMARTHUB_JDBC_PASSWORD
  • ToolSuite database: to store the processed results
    • TOOLSUITE_JDBC_URL
    • TOOLSUITE_JDBC_USERNAME
    • TOOLSUITE_JDBC_PASSWORD

Environment variables

Using the above config.properties file, you need to set the following environment variables:

NameRequiredDescription
GOCOMPLIANT_ENVIRONMENTtrueDEV/IT/UAT/PROD
SMARTHUB_API_BASIC_AUTH_USERNAMEtrueExpected username for http api access
SMARTHUB_API_BASIC_AUTH_PASSWORDtrueExpected password for http api access; can be set as SHA-256 hash, in which case the 
SHA2: prefix needs to be prepended to the hash value;
use "echo -n $PASSWORD | shasum -a 256" to calculate the hash
SMARTHUB_CONFIG_ROOTfalsethe root config file from which systems and services configuration is loaded;
defaults to git:///import.json when not set
AZ_USERNAMEfalseUsername for reading configuration from Azure DevOps Git repo;
only necessary if root config is loaded from git and Loader.git.provider=Azure
AZ_PERSONAL_ACCESS_TOKENfalseAccess token for reading configuration from Azure DevOps Git repo
only necessary if root config is loaded from git and Loader.git.provider=Azure
BITBUCKET_CLIENT_IDfalseClient ID for reading configuration from BitBucket Git repo
only necessary if root config is loaded from git and Loader.git.provider=BitBucket
BITBUCKET_CLIENT_SECRETfalseClient ID for reading configuration from BitBucket Git repo
only necessary if root config is loaded from git and Loader.git.provider=BitBucket

SMARTHUB_JDBC_URL

trueJDBC url of MySql database where SmartHub stores configuration and runtime data

SMARTHUB_JDBC_USERNAME

trueUsername of above DB

SMARTHUB_JDBC_PASSWORD

truePassword of above user

TOOLSUITE_JDBC_URL

trueJDBC url of MySql database where SmartHub writes processed result of service invocations

TOOLSUITE_JDBC_USERNAME

trueUsername of above DB

TOOLSUITE_JDBC_PASSWORD

truePassword of above use
  • Keine Stichwörter