added settings and logback
This commit is contained in:
parent
becdf6dbc2
commit
5b23c26ab5
6 changed files with 100 additions and 7 deletions
|
|
@ -0,0 +1,31 @@
|
|||
package ru.spcex.clearing.imdg.config;
|
||||
|
||||
public class DatabaseConnectionElement {
|
||||
private String login;
|
||||
private String password;
|
||||
private String url;
|
||||
|
||||
public String getLogin() {
|
||||
return login;
|
||||
}
|
||||
|
||||
public void setLogin(String login) {
|
||||
this.login = login;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
}
|
||||
|
|
@ -14,17 +14,22 @@ import java.sql.Connection;
|
|||
@SuppressWarnings("UnnecessaryLocalVariable")
|
||||
@Configuration
|
||||
public class DbConnectionConfig {
|
||||
private Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private ConfigurationRootElement configRoot = DfaConfig.get().getRoot();
|
||||
private final DatabaseConnectionElement settings;
|
||||
|
||||
public DbConnectionConfig(ImdgSettings settings) {
|
||||
this.settings = settings.getDatabase();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public DataSource dataSource() {
|
||||
DataSource result;
|
||||
String login = "clearing";
|
||||
String password = "Aa111111";
|
||||
String login = settings.getLogin();
|
||||
String password = settings.getPassword();
|
||||
String logTimeoutPart = "";
|
||||
String dbPath = "jdbc:postgresql://10.200.200.133:5432/postgres";
|
||||
String dbPath = settings.getUrl();
|
||||
int timeoutSec = configRoot.getDatabase().getConnectionAcquireTimeoutSeconds();
|
||||
|
||||
ComboPooledDataSource cpds = new ComboPooledDataSource();
|
||||
|
|
|
|||
|
|
@ -31,12 +31,15 @@ public class HazelcastConfiguration {
|
|||
public Config hazelCastConfig() {
|
||||
Config config = new Config();
|
||||
config.setInstanceName("instance");
|
||||
config.setGroupConfig(new GroupConfig());
|
||||
config.setGroupConfig(new GroupConfig()
|
||||
.setName(hzSettings.getLogin())
|
||||
.setPassword(hzSettings.getPassword())
|
||||
);
|
||||
config.setProperty("hazelcast.shutdownhook.enabled", "true");
|
||||
config.setProperty("hazelcast.logging.type", "slf4j");
|
||||
config.setProperty("hazelcast.operation.call.timeout.millis", "600000");
|
||||
config.setNetworkConfig(new NetworkConfig()
|
||||
// .setPort(configRoot.getHazelcast().getListenPort())
|
||||
.setPort(hzSettings.getListenPort())
|
||||
.setJoin(new JoinConfig()
|
||||
.setMulticastConfig(new MulticastConfig()
|
||||
.setEnabled(false))
|
||||
|
|
|
|||
|
|
@ -10,6 +10,15 @@ import org.springframework.stereotype.Component;
|
|||
public class ImdgSettings {
|
||||
|
||||
private HazelcastServerElement hazelcast;
|
||||
private DatabaseConnectionElement database;
|
||||
|
||||
public DatabaseConnectionElement getDatabase() {
|
||||
return database;
|
||||
}
|
||||
|
||||
public void setDatabase(DatabaseConnectionElement database) {
|
||||
this.database = database;
|
||||
}
|
||||
|
||||
public HazelcastServerElement getHazelcast() {
|
||||
return hazelcast;
|
||||
|
|
|
|||
|
|
@ -1 +1,8 @@
|
|||
imdg.hazelcast.cluster-members[0]=127.0.0.1
|
||||
imdg.hazelcast.listenPort=5071
|
||||
imdg.hazelcast.login=dev
|
||||
imdg.hazelcast.password=dev-pass
|
||||
imdg.hazelcast.cluster-members[0]=127.0.0.1
|
||||
|
||||
imdg.database.login=clearing
|
||||
imdg.database.password=Aa111111
|
||||
imdg.database.url=jdbc:postgresql://10.200.200.133:5432/postgres
|
||||
38
clearing-parent/imdg/src/main/resources/logback.xml
Normal file
38
clearing-parent/imdg/src/main/resources/logback.xml
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<!-- |%X{ru.nbch.scoring.web.logging.mdc_key}-->
|
||||
<Pattern>%date{HH:mm:ss.SSS} [%thread] %-5level %class{0}:%line - %message%n</Pattern>
|
||||
<charset>utf-8</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>./logs/imdg.log</file>
|
||||
<encoder>
|
||||
<!-- |%X{ru.nbch.scoring.web.logging.mdc_key}-->
|
||||
<Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %class{0}:%msg%n</Pattern>
|
||||
<charset>utf8</charset>
|
||||
</encoder>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
|
||||
<fileNamePattern>
|
||||
./logs/imdg.%i.log
|
||||
</fileNamePattern>
|
||||
<minIndex>1</minIndex>
|
||||
<maxIndex>10</maxIndex>
|
||||
</rollingPolicy>
|
||||
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
|
||||
<maxFileSize>500MB</maxFileSize>
|
||||
</triggeringPolicy>
|
||||
</appender>
|
||||
|
||||
<root level="warn">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
<appender-ref ref="FILE"/>
|
||||
</root>
|
||||
|
||||
<logger name="ru.spcex" level="debug" additivity="false">
|
||||
<appender-ref ref="FILE"/>
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</logger>
|
||||
</configuration>
|
||||
Loading…
Add table
Reference in a new issue