issues/31 подключил тестовые контроллеры к простому http api
This commit is contained in:
parent
bf3ba4e6aa
commit
2b3571ec85
20 changed files with 933 additions and 596 deletions
|
|
@ -9,12 +9,17 @@
|
||||||
<artifactId>test-api-clearing</artifactId>
|
<artifactId>test-api-clearing</artifactId>
|
||||||
<name>Test-api-clearing</name>
|
<name>Test-api-clearing</name>
|
||||||
<version>SPCEX-1.0.0.0</version>
|
<version>SPCEX-1.0.0.0</version>
|
||||||
<description>Тестовые контроллеры для отладки клиринговой системы. Только для разработчиков.</description>
|
<description>
|
||||||
|
Тестовые контроллеры для отладки клиринговой системы.
|
||||||
|
Только для разработчиков.
|
||||||
|
</description>
|
||||||
|
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>17</maven.compiler.source>
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
<maven.compiler.target>17</maven.compiler.target>
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
|
||||||
|
<keycloak-spring-boot-starter.version>17.0.1</keycloak-spring-boot-starter.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
@ -34,13 +39,13 @@
|
||||||
<groupId>ru.spcex.clearing</groupId>
|
<groupId>ru.spcex.clearing</groupId>
|
||||||
<artifactId>classes</artifactId>
|
<artifactId>classes</artifactId>
|
||||||
<version>SPCEX-1.0.0.0</version>
|
<version>SPCEX-1.0.0.0</version>
|
||||||
<scope>compile</scope>
|
<!-- <scope>compile</scope>-->
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ru.spcex.clearing</groupId>
|
<groupId>ru.spcex.clearing</groupId>
|
||||||
<artifactId>dictionary</artifactId>
|
<artifactId>dictionary</artifactId>
|
||||||
<version>SPCEX-1.0.0.0</version>
|
<version>SPCEX-1.0.0.0</version>
|
||||||
<scope>compile</scope>
|
<!-- <scope>compile</scope>-->
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
@ -63,10 +68,45 @@
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>ru.spcex.clearing</groupId>-->
|
||||||
|
<!-- <artifactId>test-clearing</artifactId>-->
|
||||||
|
<!-- <scope>test</scope>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
|
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||||
|
<!-- <artifactId>spring-boot-starter-web</artifactId>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||||
|
<!-- <artifactId>spring-boot-starter-security</artifactId>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>org.keycloak</groupId>-->
|
||||||
|
<!-- <artifactId>keycloak-spring-boot-starter</artifactId>-->
|
||||||
|
<!-- <version>${keycloak-spring-boot-starter.version}</version>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
|
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||||
|
<!-- <artifactId>spring-security-config</artifactId>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ru.spcex.clearing</groupId>
|
<groupId>ru.spcex.platform</groupId>
|
||||||
<artifactId>test-clearing</artifactId>
|
<artifactId>platform-imdg-api-hazelcast-impl</artifactId>
|
||||||
<scope>test</scope>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>ru.spcex.platform</groupId>
|
||||||
|
<artifactId>platform-messaging</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.springfox</groupId>
|
||||||
|
<artifactId>springfox-swagger2</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.springfox</groupId>
|
||||||
|
<artifactId>springfox-swagger-ui</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
||||||
|
|
@ -7,16 +7,17 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import ru.clearing.classes.objects.BusinessObject;
|
import ru.clearing.classes.objects.BusinessObject;
|
||||||
|
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class ImdgService {
|
public class ImdgService {
|
||||||
protected final Logger log= LoggerFactory.getLogger(getClass());
|
protected final Logger log = LoggerFactory.getLogger(getClass());
|
||||||
int thread=3;
|
|
||||||
|
|
||||||
HazelcastInstance hazelcastServerInstance;
|
HazelcastInstance hazelcastServerInstance;
|
||||||
|
|
||||||
|
|
@ -24,16 +25,22 @@ public class ImdgService {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int reloadMapFromDB() {
|
public int reloadMapFromDB() {
|
||||||
log.info("Reload all from DB...");
|
log.info("Reload all from DB...");
|
||||||
long loadTime = System.currentTimeMillis();
|
long loadTime = System.currentTimeMillis();
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
|
HashSet<String> ignoreUpdateMap = new HashSet<>(); // Эти мапы не должны обновляться
|
||||||
|
ignoreUpdateMap.add(IMDGDistributedNames.Map_RequestInfo);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
List<Callable<Long>> tasks = new ArrayList<>();
|
List<Callable<Long>> tasks = new ArrayList<>();
|
||||||
Collection<String> mapNames = hazelcastServerInstance.getConfig().getMapConfigs().keySet();
|
Collection<String> mapNames = hazelcastServerInstance.getConfig().getMapConfigs().keySet();
|
||||||
for (String mapName : mapNames) {
|
for (String mapName : mapNames) {
|
||||||
|
if (ignoreUpdateMap.contains(mapName)) {
|
||||||
|
log.info("Ignore sync for map {}", mapName);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
tasks.add(() -> {
|
tasks.add(() -> {
|
||||||
Long maxKey = null;
|
Long maxKey = null;
|
||||||
MapStoreConfig mapStoreConfig = hazelcastServerInstance.getConfig().getMapConfig(mapName).getMapStoreConfig();
|
MapStoreConfig mapStoreConfig = hazelcastServerInstance.getConfig().getMapConfig(mapName).getMapStoreConfig();
|
||||||
|
|
@ -41,15 +48,20 @@ public class ImdgService {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
log.debug("evict map {}", mapName);
|
log.debug("evict map {}", mapName);
|
||||||
IMap<Long, BusinessObject> map = hazelcastServerInstance.getMap(mapName);
|
IMap<Long, BusinessObject> map = hazelcastServerInstance.getMap(mapName);
|
||||||
// todo проверить что ничего лишнего не попадет map.evictAll();
|
// todo проверить что ничего лишнего не попадет
|
||||||
// log.debug("Load map {}", mapName);
|
int size1 = map.size();
|
||||||
// map.loadAll(false);
|
map.evictAll();
|
||||||
|
log.debug("Load map {}", mapName);
|
||||||
|
map.loadAll(false);
|
||||||
int size = map.size();
|
int size = map.size();
|
||||||
long time = System.currentTimeMillis() - start;
|
long time = System.currentTimeMillis() - start;
|
||||||
log.debug("{} {} rows reloaded in {}ms", mapName, size, time);
|
log.debug("{} {} rows reloaded in {}ms", mapName, size, time);
|
||||||
|
if (size1 != size)
|
||||||
|
log.warn("Map {} change size from {} to {}", mapName, size1, size);
|
||||||
|
|
||||||
Object mapStore = mapStoreConfig.getImplementation();
|
Object mapStore = mapStoreConfig.getImplementation();
|
||||||
//todo проверить реализацию.
|
//todo проверить реализацию.
|
||||||
|
maxKey = map.keySet().stream().max(Long::compareTo).orElse(null);
|
||||||
// if (mapStore instanceof SimpleObjectMapStore) {
|
// if (mapStore instanceof SimpleObjectMapStore) {
|
||||||
// String tableName = ((SimpleObjectMapStore) mapStore).getTableName();
|
// String tableName = ((SimpleObjectMapStore) mapStore).getTableName();
|
||||||
// maxKey = map.keySet().stream().max(Long::compareTo).orElse(null); // jdbcTemplate.queryForObject("select max(id) from " + tableName, Long.class);
|
// maxKey = map.keySet().stream().max(Long::compareTo).orElse(null); // jdbcTemplate.queryForObject("select max(id) from " + tableName, Long.class);
|
||||||
|
|
@ -67,7 +79,7 @@ public class ImdgService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
long maxKey = 0L;
|
long maxKey = 0L;
|
||||||
int threadCount = Runtime.getRuntime().availableProcessors();// todo config * Config.get().getRoot().getSettings().getInitHazelcastThreadMultiplier();
|
int threadCount = 2; //Runtime.getRuntime().availableProcessors();
|
||||||
log.info("Initializing threads count = {}", threadCount);
|
log.info("Initializing threads count = {}", threadCount);
|
||||||
ExecutorService executor = Executors.newWorkStealingPool(threadCount);
|
ExecutorService executor = Executors.newWorkStealingPool(threadCount);
|
||||||
try {
|
try {
|
||||||
|
|
@ -91,9 +103,8 @@ public class ImdgService {
|
||||||
throw new RuntimeException("MapStore multithreaded reload not complete.", e);
|
throw new RuntimeException("MapStore multithreaded reload not complete.", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// HazelcastHelper.imdgSystem_setStorageState(true, hazelcastServerInstance);
|
|
||||||
loadTime = System.currentTimeMillis() - loadTime;
|
loadTime = System.currentTimeMillis() - loadTime;
|
||||||
log.info("All map reload time {} ms", loadTime);
|
log.info("All {} map reload time {} ms", count, loadTime);
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,45 @@
|
||||||
package ru.spcex.clearing.test;
|
package ru.spcex.clearing.test;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.databind.JavaType;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.ClassUtils;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
import ru.spcex.clearing.platform.messaging.service.sender.KafkaSender;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class KafkaService {
|
public class KafkaService {
|
||||||
|
private static final ObjectMapper json = new ObjectMapper();
|
||||||
|
protected final Logger log = LoggerFactory.getLogger(getClass());
|
||||||
|
private final KafkaSender kafkaSender;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public KafkaService(KafkaSender kafkaSender) {
|
||||||
|
this.kafkaSender = kafkaSender;
|
||||||
|
}
|
||||||
|
|
||||||
Collection<String> allTopics() {
|
Collection<String> allTopics() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
int putMessage(String topic, String json) {
|
public Long putMessage(String fullClassName, String topic, String jsonBody) throws ClassNotFoundException, JsonProcessingException {
|
||||||
//todo
|
log.info("Call test method for kafka, class=\"{}\"; topic=\"{}\"; message=\"{}\"", fullClassName, topic, jsonBody);
|
||||||
return 0;
|
if (StringUtils.isEmpty(fullClassName)) throw new IllegalArgumentException("Class was emppty");
|
||||||
|
if (StringUtils.isEmpty(topic)) throw new IllegalArgumentException("Topic was emppty");
|
||||||
|
if (StringUtils.isEmpty(jsonBody)) throw new IllegalArgumentException("json was emppty");
|
||||||
|
|
||||||
|
Class<?> parameterType = ClassUtils.forName(fullClassName, ClassUtils.getDefaultClassLoader());
|
||||||
|
JavaType requestType = json.getTypeFactory().constructSimpleType(parameterType, null);
|
||||||
|
Object obj = json.readValue(jsonBody, requestType);
|
||||||
|
Long idOfBaseRequestMessage = kafkaSender.sendRequestToQueue(topic, obj);
|
||||||
|
log.debug("Test message to topic {} with request id={}", topic, idOfBaseRequestMessage);
|
||||||
|
return idOfBaseRequestMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,66 +0,0 @@
|
||||||
package ru.spcex.clearing.test.config;
|
|
||||||
|
|
||||||
import com.hazelcast.client.HazelcastClient;
|
|
||||||
import com.hazelcast.client.config.ClientConfig;
|
|
||||||
import com.hazelcast.core.HazelcastInstance;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import ru.spcex.clearing.test.config.settings.TestServiceSettings;
|
|
||||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
|
||||||
import ru.spcex.platform.imdg.iml.hazelcast.config.HazelcastClientParams;
|
|
||||||
import ru.spcex.platform.imdg.iml.hazelcast.service.HazelcastService;
|
|
||||||
import ru.spcex.platform.imdg.iml.hazelcast.util.HazelcastHelper;
|
|
||||||
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
public class DirectImdgConfig {
|
|
||||||
Logger log = LoggerFactory.getLogger(getClass());
|
|
||||||
|
|
||||||
// @Autowired
|
|
||||||
// @Bean
|
|
||||||
// public ImdgProvider imdgProvider(
|
|
||||||
// @Qualifier("taskExecutorHazelcastClientInitializer") ThreadPoolTaskExecutor taskExecutorHazelcastClientInitializer,
|
|
||||||
// @Qualifier("taskExecutorIdGeneratorAwaiter") ThreadPoolTaskExecutor taskExecutorIdGeneratorAwaiter,
|
|
||||||
// TestServiceSettings clientSetting
|
|
||||||
// ) {
|
|
||||||
// ImdgProvider imdg = new HazelcastService(taskExecutorHazelcastClientInitializer,
|
|
||||||
// taskExecutorIdGeneratorAwaiter,
|
|
||||||
// clientSetting.getHazelcast());
|
|
||||||
// return imdg;
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
@Bean("imdgNative")
|
|
||||||
public HazelcastInstance imdgNativeService(TestServiceSettings settings) {
|
|
||||||
HazelcastClientParams settingsElementHazelcastClient = settings.getHazelcast();
|
|
||||||
// if (hazelcastInstance != null) {
|
|
||||||
// try {
|
|
||||||
// hazelcastInstance.shutdown();
|
|
||||||
// } catch (Throwable ignored) {
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
HazelcastInstance hazelcastInstance;
|
|
||||||
log.info("Hazelcast: client init");
|
|
||||||
ClientConfig clientConfig = HazelcastHelper.getClientConfig(
|
|
||||||
settingsElementHazelcastClient.getClusterMembers(),
|
|
||||||
settingsElementHazelcastClient.getLogin(),
|
|
||||||
settingsElementHazelcastClient.getPassword(),
|
|
||||||
settingsElementHazelcastClient.getInstanceName(),
|
|
||||||
settingsElementHazelcastClient.getNearCacheConfig()
|
|
||||||
);
|
|
||||||
// if (environment != null && Arrays.asList(environment.getActiveProfiles()).contains("tests")) {
|
|
||||||
// clientConfig.getNetworkConfig().setConnectionAttemptLimit(HazelcastHelper.TEST_CONNECTION_ATTEMPT_LIMIT);
|
|
||||||
// }
|
|
||||||
log.info("Hazelcast: client created, trying connect to server ({}) ...", settingsElementHazelcastClient.getClusterMembers());
|
|
||||||
hazelcastInstance = HazelcastClient.newHazelcastClient(clientConfig);
|
|
||||||
log.info("Hazelcast: client created and connected");
|
|
||||||
return hazelcastInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,265 @@
|
||||||
|
package ru.spcex.clearing.test.config;
|
||||||
|
|
||||||
|
import com.hazelcast.client.HazelcastClient;
|
||||||
|
import com.hazelcast.client.config.ClientConfig;
|
||||||
|
import com.hazelcast.core.*;
|
||||||
|
import com.hazelcast.query.Predicate;
|
||||||
|
import com.hazelcast.query.Predicates;
|
||||||
|
import com.hazelcast.query.SqlPredicate;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||||
|
import ru.spcex.clearing.test.config.settings.TestServiceSettings;
|
||||||
|
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||||
|
import ru.spcex.platform.imdg.api.Imdg;
|
||||||
|
import ru.spcex.platform.imdg.api.ImdgId;
|
||||||
|
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||||
|
import ru.spcex.platform.imdg.api.ImdgTransaction;
|
||||||
|
import ru.spcex.platform.imdg.iml.hazelcast.adapter.ImdgIdGeneratorHazelcast;
|
||||||
|
import ru.spcex.platform.imdg.iml.hazelcast.adapter.ImdgTransactionalHazelcast;
|
||||||
|
import ru.spcex.platform.imdg.iml.hazelcast.config.HazelcastClientParams;
|
||||||
|
import ru.spcex.platform.imdg.iml.hazelcast.service.HazelcastService;
|
||||||
|
import ru.spcex.platform.imdg.iml.hazelcast.util.HazelcastHelper;
|
||||||
|
import ru.spcex.platform.utils.log.ExceptionUtils;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class ImdgConfig {
|
||||||
|
Logger log = LoggerFactory.getLogger(getClass());
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
@Bean
|
||||||
|
public ImdgProvider imdgProvider(
|
||||||
|
// @Qualifier("taskExecutorHazelcastClientInitializer") ThreadPoolTaskExecutor taskExecutorHazelcastClientInitializer,
|
||||||
|
// @Qualifier("taskExecutorIdGeneratorAwaiter") ThreadPoolTaskExecutor taskExecutorIdGeneratorAwaiter,
|
||||||
|
TestServiceSettings clientSetting, HazelcastInstance hcInstance
|
||||||
|
) {
|
||||||
|
// ImdgProvider imdg = new HazelcastService(taskExecutorHazelcastClientInitializer,
|
||||||
|
// taskExecutorIdGeneratorAwaiter,
|
||||||
|
// clientSetting.getHazelcast());
|
||||||
|
|
||||||
|
ImdgProvider imdg = new ImdgProvider() {
|
||||||
|
@Override
|
||||||
|
public <T extends SpcexObjectBase> Imdg<T> getImdg(String key, Class<T> clazz) {
|
||||||
|
ImdgDirectHazelcast<T> imdg = new ImdgDirectHazelcast<>();
|
||||||
|
imdg.setMap(hcInstance.getMap(key));
|
||||||
|
imdg.setHzInstance(hcInstance);
|
||||||
|
imdg.setMapName(key);
|
||||||
|
imdg.setIdGenerator(hcInstance.getIdGenerator(IMDGDistributedNames.MAP_SEQUENCE_NAME));
|
||||||
|
return imdg;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ImdgId getImdgIdGenerator() {
|
||||||
|
ImdgIdGeneratorHazelcast generator = new ImdgIdGeneratorHazelcast();
|
||||||
|
generator.setIdGenerator(hcInstance.getIdGenerator(IMDGDistributedNames.MAP_SEQUENCE_NAME));
|
||||||
|
return generator;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ImdgTransaction newTransaction() {
|
||||||
|
throw new UnsupportedOperationException("Stump has not implement high level function");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return imdg;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
@Bean("imdgNative")
|
||||||
|
public HazelcastInstance imdgNativeService(TestServiceSettings settings) {
|
||||||
|
HazelcastClientParams settingsElementHazelcastClient = settings.getHazelcast();
|
||||||
|
HazelcastInstance hazelcastInstance;
|
||||||
|
log.info("Hazelcast: client init");
|
||||||
|
ClientConfig clientConfig = HazelcastHelper.getClientConfig(
|
||||||
|
settingsElementHazelcastClient.getClusterMembers(),
|
||||||
|
settingsElementHazelcastClient.getLogin(),
|
||||||
|
settingsElementHazelcastClient.getPassword(),
|
||||||
|
settingsElementHazelcastClient.getInstanceName(),
|
||||||
|
settingsElementHazelcastClient.getNearCacheConfig()
|
||||||
|
);
|
||||||
|
// hazelcastInstance = Mockito.mock(HazelcastInstance.class); // debug
|
||||||
|
log.info("Hazelcast: client created, trying connect to server ({}) ...", settingsElementHazelcastClient.getClusterMembers());
|
||||||
|
hazelcastInstance = HazelcastClient.newHazelcastClient(clientConfig);
|
||||||
|
log.info("Hazelcast: client created and connected");
|
||||||
|
return hazelcastInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static class ImdgDirectHazelcast<T extends SpcexObjectBase> implements Imdg<T> {
|
||||||
|
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||||
|
private IdGenerator idGenerator;
|
||||||
|
|
||||||
|
private IMap<Long, T> map;
|
||||||
|
|
||||||
|
private String mapName;
|
||||||
|
|
||||||
|
private HazelcastInstance hzInstance;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long insert(T paramT) {
|
||||||
|
if (paramT.getId() == null) {
|
||||||
|
paramT.setId(idGenerator.newId());
|
||||||
|
}
|
||||||
|
map.put(paramT.getId(), paramT);
|
||||||
|
return paramT.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void lockAndPerform(Runnable operation) {
|
||||||
|
ILock hzLock = null;
|
||||||
|
try {
|
||||||
|
//в качестве альтернативы getCPSubsystem, поддерживается только при 3+ нодах хазелкаста
|
||||||
|
hzLock = hzInstance.getLock(mapName);
|
||||||
|
hzLock.lock();
|
||||||
|
operation.run();
|
||||||
|
} finally {
|
||||||
|
if (hzLock != null) {
|
||||||
|
try {
|
||||||
|
hzLock.unlock();
|
||||||
|
} catch (Throwable e) {
|
||||||
|
log.error("{} {}", mapName, ExceptionUtils.getStackTrace(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(T paramT) {
|
||||||
|
map.put(paramT.getId(), paramT);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delete(T paramT) {
|
||||||
|
map.remove(paramT.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public T getSingleObjectByID(Long paramLong) {
|
||||||
|
return map.get(paramLong);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* возвращает объект удовлетворяющий условиям
|
||||||
|
* не проверяет, если удовлетворяющих условиям > 1
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public T getFirstObjectByFieldValues(Map<String, ? extends Comparable<?>> conditions) {
|
||||||
|
Predicate<Long, ?>[] predicates = new Predicate[conditions.size()];
|
||||||
|
final int[] i = {0};
|
||||||
|
conditions.forEach((key, value) -> {
|
||||||
|
predicates[i[0]] = Predicates.equal(key, value);
|
||||||
|
i[0]++;
|
||||||
|
});
|
||||||
|
Predicate<Long, T> and = Predicates.and(predicates);
|
||||||
|
Set<Long> ids = map.keySet(and);
|
||||||
|
Iterator<Long> idsIterator = ids.iterator();
|
||||||
|
if (idsIterator.hasNext()) {
|
||||||
|
return map.get(idsIterator.next());
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public T getFirstObjectBySQL(String paramString) {
|
||||||
|
SqlPredicate sqlPredicate = new SqlPredicate(paramString);
|
||||||
|
Set<Long> found = map.keySet(sqlPredicate);
|
||||||
|
Iterator<Long> allFoundByCondition = found.iterator();
|
||||||
|
if (allFoundByCondition.hasNext()) {
|
||||||
|
return map.get(allFoundByCondition.next());
|
||||||
|
} else return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public T getSingleObjectBySQL(String paramString) {
|
||||||
|
SqlPredicate sqlPredicate = new SqlPredicate(paramString);
|
||||||
|
Set<Long> found = map.keySet(sqlPredicate);
|
||||||
|
if (found.size() > 1) {
|
||||||
|
throw new RuntimeException("More than one element found by predicate [" + paramString + "] - " + found.size());
|
||||||
|
}
|
||||||
|
Iterator<Long> allFoundByCondition = found.iterator();
|
||||||
|
if (allFoundByCondition.hasNext()) {
|
||||||
|
return map.get(allFoundByCondition.next());
|
||||||
|
} else return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<T> getCollectionObjectsBySQL(String paramString) {
|
||||||
|
SqlPredicate sqlPredicate = new SqlPredicate(paramString);
|
||||||
|
Collection<T> found = map.values(sqlPredicate);
|
||||||
|
List<T> result = new ArrayList<>(found); // Hazelcast может вернуть proxy-коллекцию
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* возвращает коллекцию объектов, удовлетворяющий условиям на поля
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public Collection<T> getCollectionObjectsByFieldValues(Map<String, ? extends Comparable<?>> conditions) {
|
||||||
|
Predicate<Long, ?>[] predicates = new Predicate[conditions.size()];
|
||||||
|
final int[] i = {0};
|
||||||
|
conditions.forEach((key, value) -> {
|
||||||
|
predicates[i[0]] = Predicates.equal(key, value);
|
||||||
|
i[0]++;
|
||||||
|
});
|
||||||
|
Predicate<Long, T> or = Predicates.or(predicates);
|
||||||
|
Set<Long> ids = map.keySet(or);
|
||||||
|
Iterator<Long> idIterator = ids.iterator();
|
||||||
|
Collection<T> searchResult = new ArrayList<>();
|
||||||
|
while (idIterator.hasNext()) {
|
||||||
|
T element = map.get(idIterator.next());
|
||||||
|
if (element != null) {
|
||||||
|
searchResult.add(element);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return searchResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IMap<Long, T> getMap() {
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMap(IMap<Long, T> map) {
|
||||||
|
this.map = map;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IdGenerator getIdGenerator() {
|
||||||
|
return idGenerator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIdGenerator(IdGenerator idGenerator) {
|
||||||
|
this.idGenerator = idGenerator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HazelcastInstance getHzInstance() {
|
||||||
|
return hzInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHzInstance(HazelcastInstance hzInstance) {
|
||||||
|
this.hzInstance = hzInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMapName() {
|
||||||
|
return mapName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMapName(String mapName) {
|
||||||
|
this.mapName = mapName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long nextIDSequenceFor() {
|
||||||
|
return idGenerator.newId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,73 @@
|
||||||
|
package ru.spcex.clearing.test.config;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||||
|
import com.fasterxml.jackson.annotation.PropertyAccessor;
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectReader;
|
||||||
|
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||||
|
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
// todo it is copy-paste from test-clearing
|
||||||
|
public class JsonUtil {
|
||||||
|
|
||||||
|
public static <T> List<T> readValues(String json, Class<T> clazz) {
|
||||||
|
ObjectReader reader = JacksonObjectMapper.getMapper().readerFor(clazz);
|
||||||
|
try {
|
||||||
|
return reader.<T>readValues(json).readAll();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new IllegalArgumentException("Invalid read array from JSON:\n'" + json + "'", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> T readValue(String json, Class<T> clazz) {
|
||||||
|
try {
|
||||||
|
return JacksonObjectMapper.getMapper().readValue(json, clazz);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new IllegalArgumentException("Invalid read from JSON:\n'" + json + "'", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> String writeValue(T obj) {
|
||||||
|
try {
|
||||||
|
return JacksonObjectMapper.getMapper().writeValueAsString(obj);
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
throw new IllegalStateException("Invalid write to JSON:\n'" + obj + "'", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> String writeIgnoreProps(T obj, String... ignoreProps) {
|
||||||
|
Map<String, Object> map = JacksonObjectMapper.getMapper().convertValue(obj, new TypeReference<>() {
|
||||||
|
});
|
||||||
|
map.keySet().removeAll(Set.of(ignoreProps));
|
||||||
|
return writeValue(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class JacksonObjectMapper extends ObjectMapper {
|
||||||
|
private static final ObjectMapper MAPPER = new JacksonObjectMapper();
|
||||||
|
|
||||||
|
private JacksonObjectMapper() {
|
||||||
|
//настройки Ильи
|
||||||
|
configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true);
|
||||||
|
//модуль для корректной сериализации LocalDateTime в поля JSON - JavaTimeModule модуль библиотеки jackson-datatype-jsr310
|
||||||
|
registerModule(new JavaTimeModule());
|
||||||
|
configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
|
||||||
|
//запрещаем доступ ко всем полям и методам класса и потом разрешаем доступ только к полям, нужны чтобы не было лишних полей из-за методов как: public ActionType getActionType() у BankAccountNewAction
|
||||||
|
setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE);
|
||||||
|
setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
|
||||||
|
//не сериализуем null-поля
|
||||||
|
// setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ObjectMapper getMapper() {
|
||||||
|
return MAPPER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -2,6 +2,7 @@ package ru.spcex.clearing.test.config;
|
||||||
|
|
||||||
import org.apache.kafka.clients.consumer.Consumer;
|
import org.apache.kafka.clients.consumer.Consumer;
|
||||||
import org.apache.kafka.clients.producer.Producer;
|
import org.apache.kafka.clients.producer.Producer;
|
||||||
|
import org.mockito.Mockito;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
|
@ -23,23 +24,26 @@ import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
public class KafkaConfig {
|
public class KafkaConfig {
|
||||||
@Autowired
|
// @Autowired
|
||||||
@Bean
|
// @Bean
|
||||||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
// @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
public Consumer<String, Object> createConsumer(TestServiceSettings settings) {
|
// public Consumer<String, Object> createConsumer(TestServiceSettings settings) {
|
||||||
return KafkaConsumerFactory.consumer(settings.getKafkaConsumer());
|
// return KafkaConsumerFactory.consumer(settings.getKafkaConsumer());
|
||||||
}
|
//// return Mockito.mock(Consumer.class);
|
||||||
|
// }
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@Bean
|
@Bean
|
||||||
public Producer<String, Object> createProducer(TestServiceSettings settings) {
|
public Producer<String, Object> createProducer(TestServiceSettings settings) {
|
||||||
return KafkaProducerFactory.producer(settings.getKafkaProducer());
|
return KafkaProducerFactory.producer(settings.getKafkaProducer());
|
||||||
|
// return Mockito.mock(Producer.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public ProducerFactory<String, Object> pf(TestServiceSettings settings) {
|
public ProducerFactory<String, Object> pf(TestServiceSettings settings) {
|
||||||
KafkaProducerSettings kafkaSettings = settings.getKafkaProducer();
|
KafkaProducerSettings kafkaSettings = settings.getKafkaProducer();
|
||||||
return KafkaProducerFactory.producerFactory(kafkaSettings);
|
return KafkaProducerFactory.producerFactory(kafkaSettings);
|
||||||
|
// return Mockito.mock(ProducerFactory.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean("kafkaTemplate")
|
@Bean("kafkaTemplate")
|
||||||
|
|
@ -50,7 +54,8 @@ public class KafkaConfig {
|
||||||
@Autowired
|
@Autowired
|
||||||
@Bean
|
@Bean
|
||||||
public KafkaSender kafkaSender(@Qualifier("kafkaTemplate") KafkaTemplate<String, Object> kafkaTemplate,
|
public KafkaSender kafkaSender(@Qualifier("kafkaTemplate") KafkaTemplate<String, Object> kafkaTemplate,
|
||||||
ImdgProvider imdgProvider) {
|
ImdgProvider imdgProvider
|
||||||
|
) {
|
||||||
ImdgId imdgIdGenerator = imdgProvider.getImdgIdGenerator();
|
ImdgId imdgIdGenerator = imdgProvider.getImdgIdGenerator();
|
||||||
return KafkaSender
|
return KafkaSender
|
||||||
.setup()
|
.setup()
|
||||||
|
|
@ -61,5 +66,7 @@ public class KafkaConfig {
|
||||||
return imdg::insert;
|
return imdg::insert;
|
||||||
})
|
})
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
// return Mockito.mock(KafkaSender.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,39 +0,0 @@
|
||||||
package ru.spcex.clearing.test.config;
|
|
||||||
|
|
||||||
import com.google.common.base.Predicates;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import springfox.documentation.builders.ApiInfoBuilder;
|
|
||||||
import springfox.documentation.builders.PathSelectors;
|
|
||||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
|
||||||
import springfox.documentation.service.ApiInfo;
|
|
||||||
import springfox.documentation.spi.DocumentationType;
|
|
||||||
import springfox.documentation.spring.web.plugins.Docket;
|
|
||||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
|
||||||
|
|
||||||
@SuppressWarnings("Guava")
|
|
||||||
@Configuration
|
|
||||||
@EnableSwagger2
|
|
||||||
public class SwaggerConfig {
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public Docket api() {
|
|
||||||
return new Docket(DocumentationType.SWAGGER_2)
|
|
||||||
.groupName("clearing-backend-api")
|
|
||||||
.apiInfo(metadata())
|
|
||||||
.select()
|
|
||||||
.apis(Predicates.not(RequestHandlerSelectors.basePackage("org.springframework.boot")))
|
|
||||||
.paths(PathSelectors.any())
|
|
||||||
.build()
|
|
||||||
.useDefaultResponseMessages(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ApiInfo metadata() {
|
|
||||||
return new ApiInfoBuilder()
|
|
||||||
.title("Spcex Clearing service")
|
|
||||||
.description("Сервис клиринга")
|
|
||||||
.version("0.0.1")
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,106 +0,0 @@
|
||||||
package ru.spcex.clearing.test.config;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
|
||||||
import org.springframework.boot.web.server.Cookie;
|
|
||||||
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
|
|
||||||
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
|
|
||||||
import org.springframework.boot.web.servlet.server.CookieSameSiteSupplier;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.http.converter.HttpMessageConverter;
|
|
||||||
import org.springframework.http.converter.StringHttpMessageConverter;
|
|
||||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
|
||||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
|
||||||
import org.springframework.web.context.request.RequestContextListener;
|
|
||||||
import org.springframework.web.servlet.config.annotation.*;
|
|
||||||
import ru.spcex.clearing.test.config.settings.TestServiceSettings;
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
@SuppressWarnings("Duplicates")
|
|
||||||
@Configuration
|
|
||||||
@EnableWebMvc
|
|
||||||
//todo remove? see ClearingCorsFilter
|
|
||||||
@CrossOrigin
|
|
||||||
public class WebConfig implements WebMvcConfigurer {
|
|
||||||
private final MappingJackson2HttpMessageConverter customJsonHttpConverter;
|
|
||||||
private final String sameSite;
|
|
||||||
|
|
||||||
@Bean("customJsonHttpConverter")
|
|
||||||
public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() {
|
|
||||||
return new MappingJackson2HttpMessageConverter(JsonUtil.JacksonObjectMapper.getMapper());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public WebConfig(@Qualifier("customJsonHttpConverter") MappingJackson2HttpMessageConverter customJsonHttpConverter,
|
|
||||||
TestServiceSettings backendSettings
|
|
||||||
) {
|
|
||||||
this.customJsonHttpConverter = customJsonHttpConverter;
|
|
||||||
sameSite = null; // this.sameSite = backendSettings.getSecurity().getSameSite();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
|
|
||||||
configurer.enable();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
@Override
|
|
||||||
public void configureMessageConverters(List<HttpMessageConverter<?>> messageConverters) {
|
|
||||||
Consumer<HttpMessageConverter<?>> addConverter = httpMessageConverter -> {
|
|
||||||
messageConverters.removeIf(registeredConverter -> registeredConverter.getClass().equals(httpMessageConverter.getClass()));
|
|
||||||
messageConverters.add(httpMessageConverter);
|
|
||||||
};
|
|
||||||
addConverter.accept(new StringHttpMessageConverter());
|
|
||||||
addConverter.accept(customJsonHttpConverter);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addViewControllers(ViewControllerRegistry registry) {
|
|
||||||
registry.addRedirectViewController("/v2/api-docs", "/v2/api-docs?group=api");
|
|
||||||
registry.addRedirectViewController("/swagger-resources/configuration/ui", "/swagger-resources/configuration/ui");
|
|
||||||
registry.addRedirectViewController("/swagger-resources/configuration/security", "/swagger-resources/configuration/security");
|
|
||||||
registry.addRedirectViewController("/swagger-resources", "/swagger-resources");
|
|
||||||
registry.addRedirectViewController("", "/swagger-ui.html");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
|
||||||
registry
|
|
||||||
.addResourceHandler("/swagger-ui.html**")
|
|
||||||
.addResourceLocations("classpath:/META-INF/resources/swagger-ui.html");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public WebServerFactoryCustomizer<ConfigurableServletWebServerFactory> enableDefaultServlet() {
|
|
||||||
return (factory) -> factory.setRegisterDefaultServlet(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addCorsMappings(CorsRegistry registry) {
|
|
||||||
registry.addMapping("/**").allowedMethods("*");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public RequestContextListener requestContextListener() {
|
|
||||||
return new RequestContextListener();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public CookieSameSiteSupplier applicationCookieSameSiteSupplier() {
|
|
||||||
if (sameSite == null) {
|
|
||||||
return null;
|
|
||||||
} else if (sameSite.equalsIgnoreCase(Cookie.SameSite.NONE.attributeValue())) {
|
|
||||||
return CookieSameSiteSupplier.ofNone();
|
|
||||||
} else if (sameSite.equalsIgnoreCase(Cookie.SameSite.LAX.attributeValue())) {
|
|
||||||
return CookieSameSiteSupplier.ofLax();
|
|
||||||
} else if (sameSite.equalsIgnoreCase(Cookie.SameSite.STRICT.attributeValue())) {
|
|
||||||
return CookieSameSiteSupplier.ofStrict();
|
|
||||||
} else {
|
|
||||||
throw new IllegalStateException("unknown SameSite setting");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -15,7 +15,7 @@ public class TestServiceSettings {
|
||||||
private KafkaConsumerSettings kafkaConsumer;
|
private KafkaConsumerSettings kafkaConsumer;
|
||||||
private KafkaProducerSettings kafkaProducer;
|
private KafkaProducerSettings kafkaProducer;
|
||||||
|
|
||||||
private ControllerSettings controllerSettings;//todo refactoring
|
private ControllerSettings controllerSettings;
|
||||||
|
|
||||||
public ControllerSettings getControllerSettings() {
|
public ControllerSettings getControllerSettings() {
|
||||||
return controllerSettings;
|
return controllerSettings;
|
||||||
|
|
|
||||||
|
|
@ -3,92 +3,73 @@ package ru.spcex.clearing.test.controller;
|
||||||
import com.sun.net.httpserver.HttpExchange;
|
import com.sun.net.httpserver.HttpExchange;
|
||||||
import com.sun.net.httpserver.HttpHandler;
|
import com.sun.net.httpserver.HttpHandler;
|
||||||
import com.sun.net.httpserver.HttpServer;
|
import com.sun.net.httpserver.HttpServer;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.DisposableBean;
|
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
import ru.spcex.clearing.test.ImdgService;
|
import ru.spcex.clearing.test.ImdgService;
|
||||||
import ru.spcex.clearing.test.config.settings.ControllerSettings;
|
import ru.spcex.clearing.test.KafkaService;
|
||||||
import ru.spcex.clearing.test.config.settings.TestServiceSettings;
|
import ru.spcex.clearing.test.config.settings.TestServiceSettings;
|
||||||
import ru.spcex.platform.utils.log.ExceptionUtils;
|
import ru.spcex.platform.utils.log.ExceptionUtils;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.net.InetSocketAddress;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class Controller implements InitializingBean, DisposableBean {
|
public class Controller extends HttpServerSimpleFramework {
|
||||||
protected final Logger log = LoggerFactory.getLogger(getClass());
|
protected final ImdgService imdgService;
|
||||||
HttpServer server;
|
protected final KafkaService kafkaService;
|
||||||
|
|
||||||
final ControllerSettings settings;
|
|
||||||
final ImdgService imdgService;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public Controller(ImdgService imdgService, TestServiceSettings settings) {
|
public Controller(ImdgService imdgService, KafkaService kafkaService,
|
||||||
|
TestServiceSettings settings) {
|
||||||
|
super(Integer.parseInt(settings.getControllerSettings().getPort()), settings.getControllerSettings().getContextPath());
|
||||||
|
if (settings.getControllerSettings() == null || settings.getControllerSettings().getPort() == null) {
|
||||||
|
log.warn("Debug HTTP port not set, can not init HTTP controller service.");
|
||||||
|
}
|
||||||
this.imdgService = imdgService;
|
this.imdgService = imdgService;
|
||||||
this.settings = settings.getControllerSettings();
|
this.kafkaService = kafkaService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterPropertiesSet() throws Exception {
|
protected void createContextPages(HttpServer server, String baseUrl) throws IOException {
|
||||||
Integer port = null; // 8701
|
//server.createContext(baseUrl, new RedirectPage(baseUrl+"index.html"));
|
||||||
try {
|
//server.createContext(baseUrl + "/favicon.ico", staticPageFromResource("pages/favicon.ico", null).contentType="image/icon");
|
||||||
if (settings == null || StringUtils.isEmpty(settings.getPort())) {
|
server.createContext(baseUrl + "", staticPageFromResource("pages/index.html", null));
|
||||||
log.debug("Debug HTTP port not set, do not init HTTP controller service.");
|
|
||||||
return;
|
// Database
|
||||||
|
server.createContext(baseUrl + "imdg/reload", new ImdgHandler());
|
||||||
|
//server.createContext(baseUrl+"db/info", new ImdgInfoHandler());
|
||||||
|
|
||||||
|
// Message
|
||||||
|
server.createContext(baseUrl + "message.html", staticPageFromResource("pages/message.html", null));
|
||||||
|
server.createContext(baseUrl + "message.do", new KafkaHandler());
|
||||||
|
}
|
||||||
|
|
||||||
|
class KafkaHandler extends CustomHtmlHandler {
|
||||||
|
@Override
|
||||||
|
public void makePage(HttpExchange exchange, OutputStream os) throws IOException {
|
||||||
|
if ("post".equalsIgnoreCase(exchange.getRequestMethod())) {
|
||||||
|
Map<String, String> parsed = parsePostBody(exchange);
|
||||||
|
|
||||||
|
String fullCLass = parsed.get("field0");
|
||||||
|
String qName = parsed.get("field1");
|
||||||
|
String msg = parsed.get("field2");
|
||||||
|
writeLine(os, "<p>Sending message to" + qName + "</p>");
|
||||||
|
try {
|
||||||
|
Long n = kafkaService.putMessage(fullCLass, qName, msg);
|
||||||
|
writeLine(os, "<b>Message #" + n + "</b> success send: ");
|
||||||
|
} catch (Exception er) {
|
||||||
|
writeLine(os, "<p>Message error:" + ExceptionUtils.getStackTrace(er) + "</p>");
|
||||||
|
}
|
||||||
|
writeLine(os, "<p>" + msg + "</p>");
|
||||||
|
} else {
|
||||||
|
writeLine(os, "<p>HTTP method " + exchange.getRequestMethod() + ". Use POST method.</p>");
|
||||||
}
|
}
|
||||||
port = Integer.parseInt(settings.getPort().trim());
|
|
||||||
String url = settings.getContextPath().trim();
|
|
||||||
log.info("Controller for debug reload star at port {} with url \"{}\"", port, url);
|
|
||||||
this.server = HttpServer.create(new InetSocketAddress(port), 0);
|
|
||||||
IndexHandler index=new IndexHandler();
|
|
||||||
server.createContext(url, index);
|
|
||||||
server.createContext(url+"/index.html", index);
|
|
||||||
server.createContext(url+"/imdg", new ImdgHandler());
|
|
||||||
server.createContext(url+"/kafka", new KafkaHandler());
|
|
||||||
server.setExecutor(null); // default
|
|
||||||
server.start();
|
|
||||||
} catch (Throwable t) {
|
|
||||||
log.error("Can not start debug HTTP server in port {}: {}", port, ExceptionUtils.getStackTrace(t));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
class ImdgHandler extends CustomHtmlHandler {
|
||||||
public void destroy() throws Exception {
|
|
||||||
if (server != null) {
|
|
||||||
server.stop(100);
|
|
||||||
log.info("Controller for reload stop.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class IndexHandler extends HtmlHandler {
|
|
||||||
@Override
|
|
||||||
public void makePage(HttpExchange t, OutputStream os) throws IOException {
|
|
||||||
writeLine(os, "Welcome!</br>");
|
|
||||||
writeLine(os, " <a href=\"imdg\">Reload IMDG.</a> ");
|
|
||||||
writeLine(os, " <a href=\"kafka\">Send to kafka.</a> ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class KafkaHandler extends HtmlHandler {
|
|
||||||
@Override
|
|
||||||
public void makePage(HttpExchange t, OutputStream os) throws IOException {
|
|
||||||
writeLine(os, "Welcome kafka send!</br>");
|
|
||||||
byte[] jsonB = t.getRequestBody().readAllBytes();
|
|
||||||
//t.getRequestHeaders().getFirst()
|
|
||||||
String json=new String(jsonB, "windows-1251");
|
|
||||||
//todo ...
|
|
||||||
writeLine(os, " <a href=\"imdg\">Reload IMDG.</a> ");
|
|
||||||
writeLine(os, " <a href=\"kafka\">Send to kafka.</a> ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class ImdgHandler extends HtmlHandler {
|
|
||||||
@Override
|
@Override
|
||||||
public void makePage(HttpExchange t, OutputStream os) throws IOException {
|
public void makePage(HttpExchange t, OutputStream os) throws IOException {
|
||||||
writeLine(os, "Wait, reload all maps from DB... </br>");
|
writeLine(os, "Wait, reload all maps from DB... </br>");
|
||||||
|
|
@ -110,30 +91,4 @@ public class Controller implements InitializingBean, DisposableBean {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
abstract class HtmlHandler implements HttpHandler {
|
|
||||||
public abstract void makePage(HttpExchange t, OutputStream os) throws IOException;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(HttpExchange t) throws IOException {
|
|
||||||
log.info("{} request by user \"{}\"", getClass().getSimpleName(), t.getRemoteAddress().getAddress());
|
|
||||||
t.sendResponseHeaders(200, 0);
|
|
||||||
t.setAttribute("Content-Type", "text/html; charset=windows-1251"); // or "text/plain или text/html; charset=windows-1251"
|
|
||||||
try (OutputStream os = t.getResponseBody()) {
|
|
||||||
writeLine(os, "<!DOCTYPE html>\n<html><head></head>\n<body style=\"background-color:lightgray; font-size:14pt;color:black;\">");
|
|
||||||
writeLine(os, "<div>");
|
|
||||||
makePage(t, os);
|
|
||||||
writeLine(os, "</div>");
|
|
||||||
writeLine(os, "</body></html>");
|
|
||||||
}
|
|
||||||
log.trace("HTTP Request done.");
|
|
||||||
}
|
|
||||||
|
|
||||||
void writeLine(OutputStream os, String text) throws IOException {
|
|
||||||
if (text != null)
|
|
||||||
os.write(text.getBytes("windows-1251"));
|
|
||||||
os.write("\n".getBytes("windows-1251"));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,185 @@
|
||||||
|
package ru.spcex.clearing.test.controller;
|
||||||
|
|
||||||
|
import com.sun.net.httpserver.Headers;
|
||||||
|
import com.sun.net.httpserver.HttpExchange;
|
||||||
|
import com.sun.net.httpserver.HttpHandler;
|
||||||
|
import com.sun.net.httpserver.HttpServer;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
|
import java.net.URLDecoder;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.DisposableBean;
|
||||||
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Простой HTTP server и фреимворк для HTML5 страниц.
|
||||||
|
* Только для отладки.
|
||||||
|
*/
|
||||||
|
public abstract class HttpServerSimpleFramework implements InitializingBean, DisposableBean {
|
||||||
|
protected final Logger log = LoggerFactory.getLogger(getClass());
|
||||||
|
protected HttpServer server;
|
||||||
|
protected Integer port;
|
||||||
|
protected String baseUrl;
|
||||||
|
|
||||||
|
|
||||||
|
public HttpServerSimpleFramework(Integer port, String baseUrl) {
|
||||||
|
this.port = port;
|
||||||
|
this.baseUrl = baseUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void createContextPages(HttpServer server, String baseUrl) throws IOException {
|
||||||
|
server.createContext(baseUrl, new RedirectPage(baseUrl + "index.html"));
|
||||||
|
server.createContext(baseUrl + "index.html", staticPageFromResource("pages/index.html", null));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterPropertiesSet() throws Exception {
|
||||||
|
Integer port = null; // 8080
|
||||||
|
try {
|
||||||
|
log.info("Server star at port {} with url \"{}\"", port, baseUrl);
|
||||||
|
this.server = HttpServer.create(new InetSocketAddress(port), 0);
|
||||||
|
server.setExecutor(null); // default
|
||||||
|
createContextPages(server, baseUrl);
|
||||||
|
server.start();
|
||||||
|
} catch (Throwable t) {
|
||||||
|
log.error("Can not start HTTP server in port {}: {}", port, ExceptionUtils.getStackTrace(t));
|
||||||
|
throw t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void destroy() throws Exception {
|
||||||
|
if (server != null) {
|
||||||
|
server.stop(100);
|
||||||
|
log.info("HTTP test controller stop.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Map<String, String> parsePostBody(HttpExchange exchange) throws IOException {
|
||||||
|
try (InputStreamReader isr = new InputStreamReader(exchange.getRequestBody(), "utf-8");
|
||||||
|
BufferedReader br = new BufferedReader(isr)) {
|
||||||
|
String query = br.readLine();
|
||||||
|
return parsePostBody(query);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Map<String, String> parsePostBody(String data) {
|
||||||
|
String[] elems = data.split("&");
|
||||||
|
Map<String, String> param = new LinkedHashMap<>();
|
||||||
|
for (String token : elems) {
|
||||||
|
int separator = token.indexOf("=");
|
||||||
|
if (separator == -1) throw new IllegalArgumentException("Separator '=' not found in: " + token);
|
||||||
|
String key = token.substring(0, separator);
|
||||||
|
String value = token.substring(separator + 1, token.length());
|
||||||
|
key = URLDecoder.decode(key);
|
||||||
|
value = URLDecoder.decode(value);
|
||||||
|
param.put(key, value);
|
||||||
|
}
|
||||||
|
return param;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract class CustomHtmlHandler implements HttpHandler {
|
||||||
|
protected final Logger log = LoggerFactory.getLogger(getClass());
|
||||||
|
protected final Charset encodung = Charset.forName("windows-1251");
|
||||||
|
|
||||||
|
public abstract void makePage(HttpExchange he, OutputStream os) throws IOException;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(HttpExchange he) throws IOException {
|
||||||
|
log.info("{} request by user \"{}\" {} url {}", getClass().getSimpleName(),
|
||||||
|
he.getRemoteAddress().getAddress(), he.getRequestMethod(), he.getRequestURI());
|
||||||
|
he.sendResponseHeaders(200, 0);
|
||||||
|
he.setAttribute("Content-Type", "text/html; charset=windows-1251"); // or "text/plain или text/html; charset=windows-1251"
|
||||||
|
try (OutputStream os = he.getResponseBody()) {
|
||||||
|
writeLine(os, "<!DOCTYPE html>\n<html><head></head>\n<body style=\"background-color:lightgray; font-size:14pt;color:black;\">");
|
||||||
|
writeLine(os, "<div>");
|
||||||
|
makePage(he, os);
|
||||||
|
writeLine(os, "</div>");
|
||||||
|
writeLine(os, "</body></html>");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Content build error at page \"{}\": {}",
|
||||||
|
he.getRequestURI(), ExceptionUtils.getStackTrace(e));
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
log.trace("HTTP Request done.");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void writeLine(OutputStream os, String text) throws IOException {
|
||||||
|
if (text != null)
|
||||||
|
os.write(text.getBytes(encodung));
|
||||||
|
os.write("\n".getBytes(encodung));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class RedirectPage implements HttpHandler {
|
||||||
|
protected final Logger log = LoggerFactory.getLogger(getClass());
|
||||||
|
protected String toUrl;
|
||||||
|
|
||||||
|
public RedirectPage(String toUrl) {
|
||||||
|
this.toUrl = Objects.requireNonNull(toUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(HttpExchange he) throws IOException {
|
||||||
|
log.info("Access {} url \"{}\" IP {}; redirect to \"{}\"", he.getRequestMethod(),
|
||||||
|
he.getRequestURI(), he.getRemoteAddress().getAddress().getHostAddress(), toUrl);
|
||||||
|
Headers responseHeaders = he.getResponseHeaders();
|
||||||
|
responseHeaders.set("Location", toUrl);
|
||||||
|
he.sendResponseHeaders(301, 0); // https://developer.mozilla.org/ru/docs/Web/HTTP/Redirections
|
||||||
|
he.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static StaticPage staticPageFromFile(File fromFile, String encoding) throws IOException {
|
||||||
|
if (encoding == null) encoding = "windows-1251";
|
||||||
|
String str = Files.readString(fromFile.toPath(), Charset.forName(encoding));
|
||||||
|
StaticPage page = new StaticPage(str);
|
||||||
|
page.encoding = Charset.forName(encoding);
|
||||||
|
page.contentType = "text/html; charset=" + page.encoding.name();
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static StaticPage staticPageFromResource(String inRes, String encoding) throws IOException {
|
||||||
|
if (encoding == null) encoding = "windows-1251";
|
||||||
|
String str = new String(StaticPage.class.getClassLoader().getResourceAsStream(inRes).readAllBytes(), encoding);
|
||||||
|
StaticPage page = new StaticPage(str);
|
||||||
|
page.encoding = Charset.forName(encoding);
|
||||||
|
page.contentType = "text/html; charset=" + page.encoding.name();
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class StaticPage implements HttpHandler {
|
||||||
|
protected final Logger log = LoggerFactory.getLogger(getClass());
|
||||||
|
protected Charset encoding = Charset.forName("windows-1251");
|
||||||
|
protected String contentType = "text/html; charset=" + encoding.name();
|
||||||
|
protected String content;
|
||||||
|
|
||||||
|
public StaticPage(String content) {
|
||||||
|
this.content = Objects.requireNonNull(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(HttpExchange he) throws IOException {
|
||||||
|
log.info("Access {} url \"{}\" IP {}", he.getRequestMethod(), he.getRequestURI(),
|
||||||
|
he.getRemoteAddress().getAddress().getHostAddress());
|
||||||
|
he.sendResponseHeaders(200, 0);
|
||||||
|
if (contentType != null)
|
||||||
|
he.setAttribute("Content-Type", contentType);
|
||||||
|
try (OutputStream os = he.getResponseBody()) {
|
||||||
|
os.write(content.getBytes(encoding));
|
||||||
|
} catch (Exception err) {
|
||||||
|
he.sendResponseHeaders(500, 0); // too late
|
||||||
|
log.error("StaticPage error {}", ExceptionUtils.getStackTrace(err));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,111 +0,0 @@
|
||||||
package ru.spcex.clearing.test.controller;
|
|
||||||
|
|
||||||
|
|
||||||
import com.sun.net.httpserver.HttpExchange;
|
|
||||||
import com.sun.net.httpserver.HttpHandler;
|
|
||||||
import com.sun.net.httpserver.HttpServer;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.DisposableBean;
|
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import ru.spcex.clearing.test.ImdgService;
|
|
||||||
import ru.spcex.clearing.test.config.settings.ControllerSettings;
|
|
||||||
import ru.spcex.clearing.test.config.settings.TestServiceSettings;
|
|
||||||
import ru.spcex.platform.utils.log.ExceptionUtils;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.net.InetSocketAddress;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class ImdgController implements InitializingBean, DisposableBean {
|
|
||||||
protected final Logger log = LoggerFactory.getLogger(getClass());
|
|
||||||
protected HttpServer server;
|
|
||||||
|
|
||||||
protected final ControllerSettings settings;
|
|
||||||
protected final ImdgService imdgService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public ImdgController(ImdgService imdgService, TestServiceSettings settings) {
|
|
||||||
this.imdgService = imdgService;
|
|
||||||
this.settings = settings.getControllerSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void afterPropertiesSet() throws Exception {
|
|
||||||
Integer port = null; // 8701
|
|
||||||
try {
|
|
||||||
if (settings == null || StringUtils.isEmpty(settings.getPort())) {
|
|
||||||
log.debug("Debug HTTP port not set, do not init HTTP controller service.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
port = Integer.parseInt(settings.getPort().trim());
|
|
||||||
String url = StringUtils.isBlank(settings.getContextPath()) ? "/imdg" : settings.getContextPath().trim();
|
|
||||||
log.info("Controller for debug reload star at port {} with url \"{}\"", port, url);
|
|
||||||
this.server = HttpServer.create(new InetSocketAddress(port), 0);
|
|
||||||
server.createContext(url, new MyHandler());
|
|
||||||
server.setExecutor(null); // default
|
|
||||||
server.start();
|
|
||||||
} catch (Throwable t) {
|
|
||||||
log.error("Can not start debug HTTP server in port {}: {}", port, ExceptionUtils.getStackTrace(t));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void destroy() throws Exception {
|
|
||||||
if (server != null) {
|
|
||||||
server.stop(100);
|
|
||||||
log.info("Controller for reload stop.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class MyHandler implements HttpHandler {
|
|
||||||
@Override
|
|
||||||
public void handle(HttpExchange t) throws IOException {
|
|
||||||
log.info("Reload request by user \"{}\"", t.getRemoteAddress().getAddress());
|
|
||||||
t.sendResponseHeaders(200, 0);
|
|
||||||
t.setAttribute("Content-Type", "text/html; charset=windows-1251"); // or "text/plain или text/html; charset=windows-1251"
|
|
||||||
try (OutputStream os = t.getResponseBody()) {
|
|
||||||
writeHead(os);
|
|
||||||
writeLine(os, "Wait, reload all maps from DB... </br>");
|
|
||||||
synchronized (ImdgController.this) {
|
|
||||||
os.flush();
|
|
||||||
try {
|
|
||||||
long clock = System.currentTimeMillis();
|
|
||||||
int count = imdgService.reloadMapFromDB();
|
|
||||||
clock = System.currentTimeMillis() - clock;
|
|
||||||
writeLine(os, count + " map per " + clock + " ms</br>");
|
|
||||||
} catch (Throwable e) {
|
|
||||||
String msg = "Error reload: " + ExceptionUtils.getStackTrace(e);
|
|
||||||
log.error(msg);
|
|
||||||
writeLine(os, msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
writeLine(os, "<b title=\":)\">Done.</b> " + LocalDateTime.now() + "</br>");
|
|
||||||
writeLine(os, " <a href=\"\">Reload again.</a> ");
|
|
||||||
writeEnd(os);
|
|
||||||
} //os.close();
|
|
||||||
log.trace("HTTP Request done.");
|
|
||||||
}
|
|
||||||
|
|
||||||
void writeHead(OutputStream os) throws IOException {
|
|
||||||
writeLine(os, "<!DOCTYPE html>\n<html><head></head>\n<body style=\"background-color:lightgray; font-size:14pt;color:black;\">");
|
|
||||||
writeLine(os, "<div>");
|
|
||||||
}
|
|
||||||
|
|
||||||
void writeLine(OutputStream os, String text) throws IOException {
|
|
||||||
if (text != null)
|
|
||||||
os.write(text.getBytes("windows-1251"));
|
|
||||||
os.write("\n".getBytes("windows-1251"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void writeEnd(OutputStream os) throws IOException {
|
|
||||||
writeLine(os, "</div>");
|
|
||||||
writeLine(os, "</body></html>");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,59 +1,59 @@
|
||||||
package ru.spcex.clearing.test.controller.kafka;
|
//package ru.spcex.clearing.test.controller.kafka;
|
||||||
|
//
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
//import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import com.fasterxml.jackson.annotation.JsonRawValue;
|
//import com.fasterxml.jackson.annotation.JsonRawValue;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
//import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
//import io.swagger.annotations.ApiModelProperty;
|
||||||
import ru.spcex.clearing.platform.messaging.domain.ActionType;
|
//import ru.spcex.clearing.platform.messaging.domain.ActionType;
|
||||||
import ru.spcex.clearing.platform.messaging.domain.cud.registry.TradingClearingRegistryNewRequest;
|
//import ru.spcex.clearing.platform.messaging.domain.cud.registry.TradingClearingRegistryNewRequest;
|
||||||
|
//
|
||||||
public class AnyKafkaMessageAction /*implements IAction<TradingClearingRegistryNewRequest>*/ {
|
//public class AnyKafkaMessageAction /*implements IAction<TradingClearingRegistryNewRequest>*/ {
|
||||||
@ApiModelProperty(value = "полное имя класса payload для BaseRequest", example = "ru.spcex.clearing.platform.messaging.domain.cud.schedule.LauncherCommandRequest")
|
// @ApiModelProperty(value = "полное имя класса payload для BaseRequest", example = "ru.spcex.clearing.platform.messaging.domain.cud.schedule.LauncherCommandRequest")
|
||||||
@JsonProperty
|
// @JsonProperty
|
||||||
private String fullClassName;
|
// private String fullClassName;
|
||||||
@JsonProperty
|
// @JsonProperty
|
||||||
private String topicName;
|
// private String topicName;
|
||||||
@JsonRawValue
|
// @JsonRawValue
|
||||||
public String json;
|
// public String json;
|
||||||
|
//
|
||||||
@JsonProperty("json")
|
// @JsonProperty("json")
|
||||||
private void unpackRawJson(JsonNode json) {
|
// private void unpackRawJson(JsonNode json) {
|
||||||
this.json = json.toString();
|
// this.json = json.toString();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// @Override
|
//// @Override
|
||||||
public TradingClearingRegistryNewRequest toRequest() {
|
// public TradingClearingRegistryNewRequest toRequest() {
|
||||||
var req = new TradingClearingRegistryNewRequest();
|
// var req = new TradingClearingRegistryNewRequest();
|
||||||
return req;
|
// return req;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@ApiModelProperty(hidden = true)
|
// @ApiModelProperty(hidden = true)
|
||||||
// @Override
|
//// @Override
|
||||||
public ActionType getActionType() {
|
// public ActionType getActionType() {
|
||||||
return ActionType.SYSTEM;
|
// return ActionType.SYSTEM;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public String getFullClassName() {
|
// public String getFullClassName() {
|
||||||
return fullClassName;
|
// return fullClassName;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void setFullClassName(String fullClassName) {
|
// public void setFullClassName(String fullClassName) {
|
||||||
this.fullClassName = fullClassName;
|
// this.fullClassName = fullClassName;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public String getTopicName() {
|
// public String getTopicName() {
|
||||||
return topicName;
|
// return topicName;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void setTopicName(String topicName) {
|
// public void setTopicName(String topicName) {
|
||||||
this.topicName = topicName;
|
// this.topicName = topicName;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public String getJson() {
|
// public String getJson() {
|
||||||
return json;
|
// return json;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void setJson(String json) {
|
// public void setJson(String json) {
|
||||||
this.json = json;
|
// this.json = json;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
||||||
|
|
@ -1,88 +1,88 @@
|
||||||
package ru.spcex.clearing.test.controller.kafka;
|
//package ru.spcex.clearing.test.controller.kafka;
|
||||||
|
//
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
//import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.JavaType;
|
//import com.fasterxml.jackson.databind.JavaType;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
//import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import io.swagger.annotations.ApiOperation;
|
//import io.swagger.annotations.ApiOperation;
|
||||||
import io.swagger.annotations.ApiParam;
|
//import io.swagger.annotations.ApiParam;
|
||||||
import io.swagger.annotations.ApiResponse;
|
//import io.swagger.annotations.ApiResponse;
|
||||||
import io.swagger.annotations.ApiResponses;
|
//import io.swagger.annotations.ApiResponses;
|
||||||
import org.slf4j.Logger;
|
//import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
//import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.MediaType;
|
//import org.springframework.http.MediaType;
|
||||||
import org.springframework.stereotype.Controller;
|
//import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.util.ClassUtils;
|
//import org.springframework.util.ClassUtils;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
//import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
//import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
//import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
//import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import ru.spcex.clearing.platform.messaging.service.sender.KafkaSender;
|
//import ru.spcex.clearing.platform.messaging.service.sender.KafkaSender;
|
||||||
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
//import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||||
import ru.spcex.platform.utils.enumeration.IErrorEnumId;
|
//import ru.spcex.platform.utils.enumeration.IErrorEnumId;
|
||||||
import ru.spcex.platform.utils.error.ValidationException;
|
//import ru.spcex.platform.utils.error.ValidationException;
|
||||||
import ru.spcex.platform.utils.text.TextUtil;
|
//import ru.spcex.platform.utils.text.TextUtil;
|
||||||
|
//
|
||||||
@Controller
|
//@Controller
|
||||||
@RequestMapping("/anonymous/kafka-api")
|
//@RequestMapping("/anonymous/kafka-api")
|
||||||
public class KafkaApiController {
|
//public class KafkaApiController {
|
||||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
// private final Logger log = LoggerFactory.getLogger(getClass());
|
||||||
private final KafkaSender kafkaSender;
|
// private final KafkaSender kafkaSender;
|
||||||
private static final ObjectMapper json = new ObjectMapper();
|
// private static final ObjectMapper json = new ObjectMapper();
|
||||||
static {
|
// static {
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
enum BackEndError implements IErrorEnumId {
|
// enum BackEndError implements IErrorEnumId {
|
||||||
ValidationError(9000L),
|
// ValidationError(9000L),
|
||||||
UnknownJsonProperty(9001L),
|
// UnknownJsonProperty(9001L),
|
||||||
FailedToReadHttpMessage(9002L),
|
// FailedToReadHttpMessage(9002L),
|
||||||
KeycloakRepeatedRoles(9003L),
|
// KeycloakRepeatedRoles(9003L),
|
||||||
DictionaryNotFound(9004L),
|
// DictionaryNotFound(9004L),
|
||||||
ResourceNotFound(9005L)
|
// ResourceNotFound(9005L)
|
||||||
;
|
// ;
|
||||||
private final Long id;
|
// private final Long id;
|
||||||
|
//
|
||||||
BackEndError(Long id) {
|
// BackEndError(Long id) {
|
||||||
this.id = id;
|
// this.id = id;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public Long getId() {
|
// public Long getId() {
|
||||||
return id;
|
// return id;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
public KafkaApiController(KafkaSender kafkaSender) {
|
// public KafkaApiController(KafkaSender kafkaSender) {
|
||||||
this.kafkaSender = kafkaSender;
|
// this.kafkaSender = kafkaSender;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@ApiOperation(value = "Test backend-api availability.")
|
// @ApiOperation(value = "Test backend-api availability.")
|
||||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = String.class)})
|
// @ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = String.class)})
|
||||||
@RequestMapping(method = RequestMethod.POST, path = "/any/message", produces = MediaType.TEXT_PLAIN_VALUE)
|
// @RequestMapping(method = RequestMethod.POST, path = "/any/message", produces = MediaType.TEXT_PLAIN_VALUE)
|
||||||
@ResponseBody
|
// @ResponseBody
|
||||||
public String processGet(@ApiParam(value = "Параметры команды в JSON формате.", required = true)
|
// public String processGet(@ApiParam(value = "Параметры команды в JSON формате.", required = true)
|
||||||
@RequestBody AnyKafkaMessageAction bankAccountNewAction) throws ClassNotFoundException, ValidationException, JsonProcessingException {
|
// @RequestBody AnyKafkaMessageAction bankAccountNewAction) throws ClassNotFoundException, ValidationException, JsonProcessingException {
|
||||||
log.info("Call test method for backend-api controller");
|
// log.info("Call test method for backend-api controller");
|
||||||
validate(bankAccountNewAction);
|
// validate(bankAccountNewAction);
|
||||||
Class<?> parameterType = ClassUtils.forName(bankAccountNewAction.getFullClassName(), ClassUtils.getDefaultClassLoader());
|
// Class<?> parameterType = ClassUtils.forName(bankAccountNewAction.getFullClassName(), ClassUtils.getDefaultClassLoader());
|
||||||
JavaType requestType = json.getTypeFactory().constructSimpleType(parameterType, null);
|
// JavaType requestType = json.getTypeFactory().constructSimpleType(parameterType, null);
|
||||||
Object obj = json.readValue(bankAccountNewAction.getJson(), requestType);
|
// Object obj = json.readValue(bankAccountNewAction.getJson(), requestType);
|
||||||
Long idOfBaseRequestMessage = kafkaSender.sendRequestToQueue(bankAccountNewAction.getTopicName(), obj);
|
// Long idOfBaseRequestMessage = kafkaSender.sendRequestToQueue(bankAccountNewAction.getTopicName(), obj);
|
||||||
log.debug("Test message to topic {} with request id={}", bankAccountNewAction.getTopicName(), idOfBaseRequestMessage);
|
// log.debug("Test message to topic {} with request id={}", bankAccountNewAction.getTopicName(), idOfBaseRequestMessage);
|
||||||
return "success: baseRequest.id = " + idOfBaseRequestMessage;
|
// return "success: baseRequest.id = " + idOfBaseRequestMessage;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private void validate(AnyKafkaMessageAction bankAccountNewAction) throws ValidationException {
|
// private void validate(AnyKafkaMessageAction bankAccountNewAction) throws ValidationException {
|
||||||
if (TextUtil.isEmpty(bankAccountNewAction.getTopicName())) {
|
// if (TextUtil.isEmpty(bankAccountNewAction.getTopicName())) {
|
||||||
throw new ValidationException(new EnumMessage(BackEndError.ValidationError, "topicName"));
|
// throw new ValidationException(new EnumMessage(BackEndError.ValidationError, "topicName"));
|
||||||
}
|
// }
|
||||||
if (TextUtil.isEmpty(bankAccountNewAction.getFullClassName())) {
|
// if (TextUtil.isEmpty(bankAccountNewAction.getFullClassName())) {
|
||||||
throw new ValidationException(new EnumMessage(BackEndError.ValidationError, "fullClassName"));
|
// throw new ValidationException(new EnumMessage(BackEndError.ValidationError, "fullClassName"));
|
||||||
}
|
// }
|
||||||
if (TextUtil.isEmpty(bankAccountNewAction.getJson())) {
|
// if (TextUtil.isEmpty(bankAccountNewAction.getJson())) {
|
||||||
throw new ValidationException(new EnumMessage(BackEndError.ValidationError, "json"));
|
// throw new ValidationException(new EnumMessage(BackEndError.ValidationError, "json"));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,13 @@
|
||||||
#spring.main.web-application-type=none
|
#spring.main.web-application-type=none
|
||||||
|
|
||||||
test-service.port=8701
|
|
||||||
test-service.url=/clearing/test/
|
|
||||||
|
|
||||||
#debug tester mode:
|
#debug tester mode:
|
||||||
test-service.debug-server.port=8701
|
test-service.controller-settings.port=8701
|
||||||
test-service.debug-server.context-path=/imdg/reload
|
test-service.controller-settings.context-path=/
|
||||||
|
|
||||||
server.port=8070
|
# /clearing/test/ /imdg/reload
|
||||||
server.servlet.context-path=/backend-api-test
|
|
||||||
|
#server.port=8701
|
||||||
|
#server.servlet.context-path=/
|
||||||
|
|
||||||
|
|
||||||
test-service.hazelcast.cluster-members=127.0.0.1:5701
|
test-service.hazelcast.cluster-members=127.0.0.1:5701
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
</encoder>
|
</encoder>
|
||||||
</appender>
|
</appender>
|
||||||
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
<file>./logs/utility-service.log</file>
|
<file>./logs/test-api-clearing.log</file>
|
||||||
<encoder>
|
<encoder>
|
||||||
<!-- |%X{ru.nbch.scoring.web.logging.mdc_key}-->
|
<!-- |%X{ru.nbch.scoring.web.logging.mdc_key}-->
|
||||||
<Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %class{0}:%msg%n</Pattern>
|
<Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %class{0}:%msg%n</Pattern>
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
</encoder>
|
</encoder>
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
|
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
|
||||||
<fileNamePattern>
|
<fileNamePattern>
|
||||||
./logs/utility-service.%i.log
|
./logs/test-api-clearing.%i.log
|
||||||
</fileNamePattern>
|
</fileNamePattern>
|
||||||
<minIndex>1</minIndex>
|
<minIndex>1</minIndex>
|
||||||
<maxIndex>10</maxIndex>
|
<maxIndex>10</maxIndex>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html><head>
|
||||||
|
<style type="text/css">
|
||||||
|
div.oldtab {background-color:darkblue;color:yellow;border:1pt double yellow; padding:2pt; margin:3pt;}
|
||||||
|
div.oldtab_line {margin:3pt;}
|
||||||
|
div.oldtab_line:hover {background-color:white;color:black;}
|
||||||
|
a{background-color:lightgray;color:black;border-bottom:2pt solid yellow;text-decoration: none;}
|
||||||
|
|
||||||
|
label{cursor:help;}
|
||||||
|
button {cursor:pointer;}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body style="background-color:lightgray; font-size:14pt;color:black;">
|
||||||
|
<div>
|
||||||
|
<h1>Debug control panel</h1>
|
||||||
|
<p>Action:</p>
|
||||||
|
|
||||||
|
<div class="oldtab">
|
||||||
|
<p style="text-align:center;cursor:default;">Sending message dialog</p>
|
||||||
|
<div class="oldtab_line">
|
||||||
|
Send <a href="message.html"/>Message to queue</a>
|
||||||
|
</div>
|
||||||
|
<div class="oldtab_line">
|
||||||
|
<form action="imdg/reload" method="POST">
|
||||||
|
Do <button>reload database</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div style="text-align:right;"><a href="">Reload page.</a> </div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</body></html>
|
||||||
|
|
@ -0,0 +1,55 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html><head>
|
||||||
|
<style type="text/css">
|
||||||
|
div.oldtab {background-color:#000500;color:white;border:1pt double yellow; padding:2pt; margin:3pt;}
|
||||||
|
div.oldtab_line {margin:3pt;}
|
||||||
|
div.oldtab_line:hover {background-color:white;color:black;}
|
||||||
|
label{cursor:help;}
|
||||||
|
button {cursor:pointer;}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body style="background-color:lightgray; font-size:14pt;color:black;">
|
||||||
|
<div>
|
||||||
|
|
||||||
|
<div class="oldtab">
|
||||||
|
<p style="text-align:center;cursor:default;">Sending message dialog</p>
|
||||||
|
<form action="message.do" method="POST" style="background-color:light-gray;">
|
||||||
|
<div class="oldtab_line">
|
||||||
|
<label for="field0">Full class name</label>
|
||||||
|
<input name="field0" id="field0" style="width:60em;" value="ru.clearing.classes.statics.data.account.Account" />
|
||||||
|
</div>
|
||||||
|
<div class="oldtab_line">
|
||||||
|
<label for="field1">Topic name</label>
|
||||||
|
|
||||||
|
<input name="field1" id="field1" style="width:60em;" value="correspondent-account-new" />
|
||||||
|
</div>
|
||||||
|
<div class="oldtab_line">
|
||||||
|
<label for="field2">Json message</label>
|
||||||
|
|
||||||
|
<textArea name="field2" id="field2" rows="10" cols="120" >
|
||||||
|
{
|
||||||
|
"id":0,"actionType":"UPDATE",
|
||||||
|
"requestPayload":{
|
||||||
|
"id":3,
|
||||||
|
"companyId":0,
|
||||||
|
"account":"123456789123",
|
||||||
|
"status":"ACTV",
|
||||||
|
"accountType":"CORR"
|
||||||
|
},
|
||||||
|
"userId":1000}
|
||||||
|
</textArea>
|
||||||
|
</div>
|
||||||
|
<div style="text-align:center;">
|
||||||
|
<button>Send to kafka</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="text-align:left;background-color:black; font-size:14pt;color:lightgray;height: 20em;">
|
||||||
|
Enter Kafka debug message...
|
||||||
|
</br>
|
||||||
|
\message> <a style="color:white;border-bottom:1pt solid yellow;text-decoration: none;" href="/">CD ..</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</body></html>
|
||||||
10
clearing-parent/test-api-clearing/test-api-clearing.sh
Normal file
10
clearing-parent/test-api-clearing/test-api-clearing.sh
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
CLEARING_HOME=/opt/mfd/clearing/
|
||||||
|
cd $CLEARING_HOME/bin
|
||||||
|
|
||||||
|
echo Warinig: start test module "test-api-clearing.jar". Do not use this on real system, please.
|
||||||
|
CMD="java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:7702 -jar test-api-clearing.jar --spring.config.location=$CLEARING_HOME/settings/test-api-clearing/"
|
||||||
|
|
||||||
|
$CMD >/dev/null 2>&1 &
|
||||||
|
|
||||||
Loading…
Add table
Reference in a new issue