- change version on 1.8

- add docker-compose
- update entaxy
This commit is contained in:
2021-09-10 22:42:19 +03:00
parent 7d80bb81c6
commit 094a3fe67f
77 changed files with 2561 additions and 854 deletions

View File

@ -24,10 +24,32 @@
<extensions>true</extensions>
<configuration>
<instructions>
<Entaxy-Initializer-Class>ru.entaxy.esb.platform.runtime.core.initializer.connection.ConnectionInitializer?id=connections&amp;repeat=false&amp;depends-on=core,datasources</Entaxy-Initializer-Class>
<Entaxy-Initializer-Class>ru.entaxy.esb.platform.runtime.core.initializer.connection.ConnectionInitializer?id=connections&amp;repeat=true&amp;depends-on=core,datasources</Entaxy-Initializer-Class>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>attach-artifacts</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>src/main/non-packaged-resources/etc/init/entaxy-platform-connections.json</file>
<type>json</type>
<classifier>init-config</classifier>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

View File

@ -0,0 +1,54 @@
{
"connections": [
{
"nodeType": "connection",
"uuid": "connection-uuid-1",
"name": "entaxy-file",
"adapterName": "fileAdapter",
"platform": true,
"pathParameter": "data/shared",
"properties": {},
"options": {
"noop": true,
"fileName": "default.txt",
"allowNullBody": "true"
}
},
{
"nodeType": "connection",
"uuid": "connection-uuid-2",
"name": "entaxy-broker",
"adapterName": "artemisAdapter",
"platform": true,
"pathParameter": "queue:entaxy.default",
"properties": {
"url": "(tcp://localhost:61616)",
"username": "entaxy",
"password": "entaxy",
"maxConnections": "20",
"maxSessionsPerConnection": "100"
},
"options": {}
},
{
"nodeType": "connection",
"uuid": "connection-uuid-3",
"name": "entaxy-db-storage",
"adapterName": "postgresqlAdapter",
"platform": true,
"pathParameter": "entaxy.esb.storage",
"properties": {},
"options": {}
},
{
"nodeType": "connection",
"uuid": "connection-uuid-4",
"name": "entaxy-db-cache",
"adapterName": "postgresqlAdapter",
"platform": true,
"pathParameter": "entaxy.esb.cache",
"properties": {},
"options": {}
}
]
}

View File

@ -26,10 +26,38 @@
<extensions>true</extensions>
<configuration>
<instructions>
<Entaxy-Initializer-Class>ru.entaxy.esb.platform.runtime.core.initializer.datasources.DataSourcesInitializer?id=datasources&amp;repeat=false</Entaxy-Initializer-Class>
<Entaxy-Initializer-Class>ru.entaxy.esb.platform.runtime.core.initializer.datasources.DataSourcesInitializer?id=datasources&amp;repeat=false&amp;retries=10&amp;interval=2000</Entaxy-Initializer-Class>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>attach-artifacts</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>src/main/non-packaged-resources/etc/org.ops4j.datasource-entaxy.esb.cache.cfg</file>
<type>cfg</type>
<classifier>datasource-cache</classifier>
</artifact>
<artifact>
<file>src/main/non-packaged-resources/etc/org.ops4j.datasource-entaxy.esb.storage.cfg</file>
<type>cfg</type>
<classifier>datasource-storage</classifier>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

View File

@ -0,0 +1,43 @@
/*-
* ~~~~~~licensing~~~~~~
* datasources-initializer
* ==========
* Copyright (C) 2020 - 2021 EmDev LLC
* ==========
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.esb.platform.runtime.core.initializer.datasources;
import javax.sql.DataSource;
public class DataSourcesCollector {
protected DataSource dsCache;
protected DataSource dsStorage;
protected void notifyOnComplete() {
if ((this.dsCache != null) && (this.dsStorage != null))
DataSourcesInitializer.collectorCompleted();
}
public void setDsCache(DataSource dsCache) {
this.dsCache = dsCache;
notifyOnComplete();
}
public void setDsStorage(DataSource dsStorage) {
this.dsStorage = dsStorage;
notifyOnComplete();
}
}

View File

@ -24,6 +24,7 @@ import org.osgi.framework.ServiceReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ru.entaxy.esb.platform.runtime.core.initializer.api.AbstractInitializer;
import ru.entaxy.esb.platform.runtime.core.initializer.api.Initializer;
import ru.entaxy.esb.platform.runtime.core.initializer.api.InitializerException;
import javax.sql.DataSource;
@ -33,6 +34,13 @@ public class DataSourcesInitializer extends AbstractInitializer {
protected static final Logger log = LoggerFactory.getLogger(DataSourcesInitializer.class);
protected static Initializer.Callback callback = null;
public static void collectorCompleted() {
if (DataSourcesInitializer.callback != null)
DataSourcesInitializer.callback.inited(new DataSourcesInitializer());
}
@Override
public void init() throws InitializerException {
log.info("Init in DataSourcesInitializer is called");
@ -55,5 +63,8 @@ public class DataSourcesInitializer extends AbstractInitializer {
log.info("ReInit in CoreInitializer is called");
}
@Override
public void setCalllback(Callback callback) {
DataSourcesInitializer.callback = callback;
}
}

View File

@ -0,0 +1,29 @@
###
# ~~~~~~licensing~~~~~~
# datasources-initializer
# ==========
# Copyright (C) 2020 - 2021 EmDev LLC
# ==========
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ~~~~~~/licensing~~~~~~
###
dataSourceName=entaxy.esb.cache
osgi.jdbc.driver.name=PostgreSQL JDBC Driver
serverName=localhost
portNumber=5432
databaseName=cache
user=entaxy
password=entaxy
pool=dbcp2
xa=true
jdbc.pool.maxTotal=100

View File

@ -0,0 +1,29 @@
###
# ~~~~~~licensing~~~~~~
# datasources-initializer
# ==========
# Copyright (C) 2020 - 2021 EmDev LLC
# ==========
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ~~~~~~/licensing~~~~~~
###
dataSourceName=entaxy.esb.storage
osgi.jdbc.driver.name=PostgreSQL JDBC Driver
serverName=localhost
portNumber=5432
databaseName=esb_entaxy
user=entaxy
password=entaxy
pool=dbcp2
xa=true
jdbc.pool.maxTotal=100

View File

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~~~~~~licensing~~~~~~
datasources-initializer
==========
Copyright (C) 2020 - 2021 EmDev LLC
==========
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
~~~~~~/licensing~~~~~~
-->
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
<reference id="dsCache" interface="javax.sql.DataSource" filter="(osgi.jndi.service.name=entaxy.esb.cache)"
availability="mandatory"/>
<reference id="dsStorage" interface="javax.sql.DataSource" filter="(osgi.jndi.service.name=entaxy.esb.storage)"
availability="mandatory"/>
<bean id="collector" class="ru.entaxy.esb.platform.runtime.core.initializer.datasources.DataSourcesCollector"
activation="eager">
<property name="dsCache" ref="dsCache" />
<property name="dsStorage" ref="dsStorage" />
</bean>
</blueprint>

View File

@ -76,7 +76,7 @@ public class InitManager {
protected List<String> waiting = new ArrayList<>();
protected class InitializerMeta {
protected class InitializerMeta implements Initializer.Callback {
String id;
String className;
@ -84,12 +84,16 @@ public class InitManager {
Bundle bundle;
List<InitializerMeta> dependsOn = new ArrayList<>();
List<InitializerMeta> dependedBy = new ArrayList<>();
Map<String, InitializerMeta> dependsOn = new HashMap<>();
Map<String, InitializerMeta> dependedBy = new HashMap<>();
boolean executed = false;
boolean toBeExecuted = true;
int retries = 1;
int interval = 1000;
public void load(String initializerData) {
String[] data = initializerData.split("\\?");
@ -120,6 +124,21 @@ public class InitManager {
String repeat = params.get(Initializer.INITIALIZER_QUERY_STRING_PARAM_REPEAT);
this.repeat = "true".equals(repeat);
String retriesValue = params.get(Initializer.INITIALIZER_QUERY_STRING_PARAM_RETRIES);
if (!Strings.isNullOrEmpty(retriesValue))
try {
this.retries = Integer.parseInt(retriesValue);
} catch (NumberFormatException e) {
log.error("Retries paramater [{}] is not an integer", retriesValue);
}
String intervalValue = params.get(Initializer.INITIALIZER_QUERY_STRING_PARAM_INTERVAL);
if (!Strings.isNullOrEmpty(intervalValue))
try {
this.interval = Integer.parseInt(intervalValue);
} catch (NumberFormatException e) {
log.error("Interval paramater [{}] is not an integer", intervalValue);
}
}
protected void addDependency(InitializerMeta meta) {
@ -127,7 +146,7 @@ public class InitManager {
if (meta.toBeExecuted && !meta.executed)
synchronized (this.dependsOn) {
meta.addDependent(this);
this.dependsOn.add(meta);
this.dependsOn.put(meta.id, meta);
}
}
}
@ -136,13 +155,15 @@ public class InitManager {
this.className = other.className;
this.bundle = other.bundle;
this.repeat = other.repeat;
for (InitializerMeta meta: other.dependsOn)
this.retries = other.retries;
this.interval = other.interval;
for (InitializerMeta meta: other.dependsOn.values())
this.addDependency(meta);
}
public void addDependent(InitializerMeta meta) {
synchronized (this.dependedBy) {
this.dependedBy.add(meta);
this.dependedBy.put(meta.id, meta);
}
}
@ -155,7 +176,7 @@ public class InitManager {
}
public void notifyDependent() {
for (InitializerMeta meta: this.dependedBy)
for (InitializerMeta meta: this.dependedBy.values())
meta.dependencyReady(this);
}
@ -190,14 +211,39 @@ public class InitManager {
}
public void setCallback() {
BundleWiring wiring = bundle.adapt(BundleWiring.class);
ClassLoader cl = wiring.getClassLoader();
Class<?> clazz;
try {
clazz = cl.loadClass(className);
log.info("Loaded class {}", clazz.getName());
Constructor<?> constructor = clazz.getConstructor();
Initializer initializer = (Initializer) constructor.newInstance();
initializer.setCalllback(this);
} catch (ClassNotFoundException | NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void dependencyReady(InitializerMeta meta) {
synchronized (this.dependsOn) {
this.dependsOn.remove(meta);
this.dependsOn.remove(meta.id);
if (!this.executed && this.canExecute())
this.execute();
}
}
@Override
public void inited(Initializer owner) {
log.info("Initializer with id {} notified of successful init via callback");
InitManager.this.updateById(id, true);
this.executed = true;
this.notifyDependent();
owner.setCalllback(null);
}
};
@ -268,7 +314,7 @@ public class InitManager {
}
if (!meta.canExecute()) {
String dependsOn = meta.dependsOn.stream().map((m)->m.id).collect(Collectors.joining(","));
String dependsOn = meta.dependsOn.values().stream().map((m)->m.id).collect(Collectors.joining(","));
log.info("Initializer with id {} is waiting for dependencies: {}", meta.id, dependsOn);
/*
@ -276,8 +322,25 @@ public class InitManager {
*/
return;
}
int retriesCount = meta.retries;
boolean result = false;
while (!result && (retriesCount > 0)) {
log.info("Executing initializer with id {}: try {} of {}", meta.id, meta.retries-retriesCount+1, meta.retries);
retriesCount--;
result = meta.execute();
if ((retriesCount > 0) && !result)
try {
log.info("Executing initializer with id {}: sleeping for {}", meta.id, meta.interval);
Thread.sleep(meta.interval);
} catch (InterruptedException e) {
log.error("Failed sleep for thread {} on initializer {}", Thread.currentThread().getId(), meta.id);
e.printStackTrace();
}
}
meta.execute();
// last try
if (!result)
meta.setCallback();
}
/* protected void execute(InitializerMeta meta) {

View File

@ -52,4 +52,8 @@ public abstract class AbstractInitializer implements Initializer {
return this.initializerId;
}
@Override
public void setCalllback(Callback callback) {
// Ignore it by default
}
}

View File

@ -23,6 +23,10 @@ import org.osgi.framework.BundleContext;
public interface Initializer {
public static interface Callback {
public void inited(Initializer owner);
}
public static final String INITIALIZER_CLASS_HEADER = "Entaxy-Initializer-Class";
@ -38,6 +42,8 @@ public interface Initializer {
public static final String INITIALIZER_QUERY_STRING_PARAM_ID = "id";
public static final String INITIALIZER_QUERY_STRING_PARAM_DEPENDS_ON = "depends-on";
public static final String INITIALIZER_QUERY_STRING_PARAM_REPEAT = "repeat";
public static final String INITIALIZER_QUERY_STRING_PARAM_RETRIES = "retries";
public static final String INITIALIZER_QUERY_STRING_PARAM_INTERVAL = "interval";
public void init() throws InitializerException;
@ -54,4 +60,6 @@ public interface Initializer {
public void setInitializerId(String id);
public String getInitializerId();
public void setCalllback(Initializer.Callback callback);
}

View File

@ -26,14 +26,14 @@
</properties>
<dependencies>
<dependency>
<!-- dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
</dependency -->
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>

View File

@ -20,30 +20,74 @@
-->
<features name="ru.entaxy.esb.platform.runtime.core-${project.version}"
xmlns="http://karaf.apache.org/xmlns/features/v1.6.0">
<features name="entaxy-platform-core-${project.version}"
xmlns="http://karaf.apache.org/xmlns/features/v1.3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.3.0 http://karaf.apache.org/xmlns/features/v1.3.0">
<feature name="core" version="${project.version}">
<feature version="${project.version}">management</feature>
<feature version="${project.version}">initializer</feature>
<repository>mvn:ru.entaxy.esb.platform.runtime/base/${project.version}/xml/features</repository>
<repository>mvn:ru.entaxy.esb.distribution/entaxy-karaf-features/${project.version}/xml/features</repository>
<feature name="entaxy-platform-core" version="${project.version}">
<feature version="${project.version}" prerequisite="true">entaxy-platform-base</feature>
<feature version="${project.version}">entaxy-initializer</feature>
<feature version="${project.version}">entaxy-management</feature>
</feature>
<feature name="entaxy-initializer" version="${project.version}">
<bundle>mvn:ru.entaxy.esb.platform.runtime.core.initializer/init-manager/${project.version}</bundle>
<feature version="${project.version}">entaxy-datasources-initializer</feature>
<feature version="${project.version}">entaxy-core-initializer</feature>
<feature version="${project.version}">entaxy-connection-initializer</feature>
<feature version="${project.version}">entaxy-storage-initializer</feature>
</feature>
<feature name="management" version="${project.version}">
<feature name="entaxy-datasources-initializer" version="${project.version}" >
<configfile finalname="${karaf.etc}/org.ops4j.datasource-entaxy.esb.cache.cfg" override="false">
mvn:ru.entaxy.esb.platform.runtime.core.initializer/datasources-initializer/${project.version}/cfg/datasource-cache
</configfile>
<configfile finalname="${karaf.etc}/org.ops4j.datasource-entaxy.esb.storage.cfg" override="false">
mvn:ru.entaxy.esb.platform.runtime.core.initializer/datasources-initializer/${project.version}/cfg/datasource-storage
</configfile>
<capability>
osgi.service;effective:=active;objectClass=javax.sql.DataSource;osgi.jndi.service.name=entaxy.esb.cache;
</capability>
<capability>
osgi.service;effective:=active;objectClass=javax.sql.DataSource;osgi.jndi.service.name=entaxy.esb.storage;
</capability>
<!-- why do we need the following? -->
<!--
<capability>
osgi.service;objectClass=javax.sql.DataSource;osgi.jndi.service.name=entaxy.esb.cache-connector;
</capability>
-->
<bundle>mvn:ru.entaxy.esb.platform.runtime.core.initializer/datasources-initializer/${project.version}</bundle>
</feature>
<feature name="entaxy-core-initializer" version="${project.version}" >
<bundle>mvn:ru.entaxy.esb.platform.runtime.core.initializer/core-initializer/${project.version}</bundle>
</feature>
<feature name="entaxy-connection-initializer" version="${project.version}">
<configfile finalname="${karaf.etc}/init/entaxy-platform-connections.json" override="false">
mvn:ru.entaxy.esb.platform.runtime.core.initializer/connection-initializer/${project.version}/json/init-config
</configfile>
<bundle>mvn:ru.entaxy.esb.platform.runtime.core.initializer/connection-initializer/${project.version}</bundle>
</feature>
<feature name="entaxy-storage-initializer" version="${project.version}">
<feature version="${project.version}" prerequisite="true">entaxy-karaf-liquibase-support</feature>
<bundle>mvn:ru.entaxy.esb.platform.runtime.core.initializer.storage.initializer/liquibase-updater/${project.version}</bundle>
<bundle>mvn:ru.entaxy.esb.platform.runtime.core.initializer.storage.initializer/storage-esb_entaxy/${project.version}</bundle>
<bundle>mvn:ru.entaxy.esb.platform.runtime.core.initializer.storage.initializer/storage-cache/${project.version}</bundle>
</feature>
<feature name="entaxy-management" version="${project.version}">
<bundle>mvn:ru.entaxy.esb.platform.runtime.core.management/connection-manager/${project.version}</bundle>
</feature>
<feature name="initializer" version="${project.version}">
<feature version="${project.version}">storage-initializer</feature>
<bundle>mvn:ru.entaxy.esb.platform.runtime.core.initializer/init-manager/${project.version}</bundle>
<bundle>mvn:ru.entaxy.esb.platform.runtime.core.initializer/core-initializer/${project.version}</bundle>
<bundle>mvn:ru.entaxy.esb.platform.runtime.core.initializer/datasources-initializer/${project.version}</bundle>
<bundle>mvn:ru.entaxy.esb.platform.runtime.core.initializer/connection-initializer/${project.version}</bundle>
</feature>
<feature name="storage-initializer" version="${project.version}">
<bundle>mvn:ru.entaxy.esb.platform.runtime.core.initializer.storage.initializer/liquibase-updater/${project.version}</bundle>
<bundle>mvn:ru.entaxy.esb.platform.runtime.core.initializer.storage.initializer/storage-esb_entaxy/${project.version}</bundle>
<bundle>mvn:ru.entaxy.esb.platform.runtime.core.initializer.storage.initializer/storage-cache/${project.version}</bundle>
</feature>
</features>
</features>