some imdg refactoring
This commit is contained in:
parent
10dd8bdd1d
commit
c6b9a9060f
11 changed files with 14 additions and 413 deletions
|
|
@ -1,48 +0,0 @@
|
|||
package ru.spcex.clearing.imdg.config;
|
||||
|
||||
|
||||
/**
|
||||
* Корневой элемент конфигурации
|
||||
*/
|
||||
|
||||
@SuppressWarnings("DefaultAnnotationParam")
|
||||
public class ConfigurationRootElement /*extends ConfigurationRootBaseElement*/ {
|
||||
|
||||
/**
|
||||
* Конфигурация БД
|
||||
*/
|
||||
// @JsonProperty(value = "Database", required = true)
|
||||
private SettingsElementDatabase database = new SettingsElementDatabase();
|
||||
|
||||
// @JsonProperty(value = "Settings", required = false)
|
||||
private SettingsElement settings = new SettingsElement();
|
||||
|
||||
/**
|
||||
* Конфигурация Hazelcast
|
||||
*/
|
||||
// @JsonProperty(value = "HazelcastServer", required = true)
|
||||
// private HazelcastServerElement hazelcast = new HazelcastServerElement();
|
||||
|
||||
/**
|
||||
* Конфигурация сервисов Core
|
||||
*/
|
||||
// @JsonProperty(value = "Services")
|
||||
private ServicesElement servicesElement = new ServicesElement();
|
||||
|
||||
public SettingsElementDatabase getDatabase() {
|
||||
return database;
|
||||
}
|
||||
|
||||
// public HazelcastServerElement getHazelcast() {
|
||||
// return hazelcast;
|
||||
// }
|
||||
|
||||
public SettingsElement getSettings() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
public ServicesElement getServicesElement() {
|
||||
return servicesElement;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,71 +0,0 @@
|
|||
package ru.spcex.clearing.imdg.config;
|
||||
|
||||
import com.mchange.v2.c3p0.ComboPooledDataSource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import ru.spcex.clearing.imdg.error.ModuleInitializeException;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
|
||||
@SuppressWarnings("UnnecessaryLocalVariable")
|
||||
@Configuration
|
||||
public class DbConnectionConfig {
|
||||
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 = settings.getLogin();
|
||||
String password = settings.getPassword();
|
||||
String logTimeoutPart = "";
|
||||
String dbPath = settings.getUrl();
|
||||
int timeoutSec = configRoot.getDatabase().getConnectionAcquireTimeoutSeconds();
|
||||
|
||||
ComboPooledDataSource cpds = new ComboPooledDataSource();
|
||||
try {
|
||||
cpds.setDriverClass("org.postgresql.Driver");
|
||||
} catch (Exception ue) {
|
||||
throw new RuntimeException(ue);
|
||||
}
|
||||
cpds.setJdbcUrl(dbPath);
|
||||
cpds.setUser(login);
|
||||
cpds.setPassword(password);
|
||||
cpds.setInitialPoolSize(configRoot.getDatabase().getMinPoolSize());
|
||||
cpds.setMinPoolSize(configRoot.getDatabase().getMinPoolSize());
|
||||
cpds.setMaxPoolSize(configRoot.getDatabase().getMaxPoolSize());
|
||||
cpds.setNumHelperThreads(configRoot.getDatabase().getNumHelperThreads());
|
||||
cpds.setCheckoutTimeout(timeoutSec * 1000/*todo common 1000==ConstsCommon.SECOND*/);
|
||||
logTimeoutPart = String.format(" (timeout=%ds)", timeoutSec);
|
||||
result = cpds;
|
||||
|
||||
String OPERATION_DATABASE_CONNECTION_CHECK = String.format("Database [%s] connection check", dbPath);
|
||||
try {
|
||||
Connection conn = result.getConnection();
|
||||
conn.close();
|
||||
log.info("{}: success", OPERATION_DATABASE_CONNECTION_CHECK);
|
||||
return result;
|
||||
} catch (Throwable e) {
|
||||
String msg = String.format("%s%s: failed: %s -> %s",
|
||||
OPERATION_DATABASE_CONNECTION_CHECK, logTimeoutPart, e.getClass().getSimpleName(), e.getMessage());
|
||||
log.error(msg);
|
||||
throw new ModuleInitializeException(msg, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Bean
|
||||
public JdbcTemplate jdbcTemplate(DataSource dataSource) {
|
||||
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
return jdbcTemplate;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
package ru.spcex.clearing.imdg.config;
|
||||
|
||||
|
||||
public class DfaConfig {
|
||||
protected static DfaConfig self;
|
||||
|
||||
|
||||
ConfigurationRootElement root = new ConfigurationRootElement();
|
||||
|
||||
protected String defaultLogFileName() {
|
||||
return "storage";
|
||||
}
|
||||
|
||||
|
||||
public String appName() {
|
||||
return "clearing-storage";
|
||||
}
|
||||
|
||||
|
||||
protected Class parsedClazz() {
|
||||
return ConfigurationRootElement.class;
|
||||
}
|
||||
|
||||
public static DfaConfig get() {
|
||||
if (self == null) {
|
||||
self = new DfaConfig();
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
public ConfigurationRootElement getRoot() {
|
||||
return root;
|
||||
}
|
||||
}
|
||||
|
|
@ -12,7 +12,6 @@ import java.util.List;
|
|||
@Configuration
|
||||
public class HazelcastConfiguration {
|
||||
|
||||
private ConfigurationRootElement configRoot = DfaConfig.get().getRoot();
|
||||
private final PoolMapConfigs poolMapConfigs;
|
||||
private final HazelcastServerElement hzSettings;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.imdg.base.AutoconfiguredMap;
|
||||
import ru.spcex.clearing.imdg.base.DictionaryTMapStore;
|
||||
import ru.spcex.clearing.imdg.businessevent.CompanyHistoryMapStore;
|
||||
|
|
@ -15,7 +16,6 @@ import ru.spcex.clearing.imdg.dictionary.*;
|
|||
import ru.spcex.clearing.imdg.object.CompanySymbolsMapStore;
|
||||
import ru.spcex.clearing.imdg.object.ContactMapStore;
|
||||
import ru.spcex.clearing.imdg.object.ProfileDocumentMapStore;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
|
@ -26,11 +26,6 @@ import java.util.List;
|
|||
public class PoolMapConfigs {
|
||||
private Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
||||
private ConfigurationRootElement configRoot = DfaConfig.get().getRoot();
|
||||
|
||||
public PoolMapConfigs() {
|
||||
}
|
||||
|
||||
private MapStoreConfig makeDefaultMapStoreConfig(MapLoader<Long, ?> mapBean) {
|
||||
return new MapStoreConfig()
|
||||
.setImplementation(mapBean)
|
||||
|
|
|
|||
|
|
@ -1,34 +0,0 @@
|
|||
package ru.spcex.clearing.imdg.config;
|
||||
|
||||
//import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
//import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Настройка сервисов
|
||||
*/
|
||||
public class ServicesElement implements Serializable {
|
||||
|
||||
/**
|
||||
* Время, через которое выставленная заявка будет снята, в миллисекундах.
|
||||
*/
|
||||
// @JsonProperty(value = "ExpirationDelay")
|
||||
private Integer ExpirationDelay = 5 * 60 * 1000;
|
||||
|
||||
public Integer getExpirationDelay() {
|
||||
return ExpirationDelay;
|
||||
}
|
||||
|
||||
/**
|
||||
* Время окончания торговой сессии
|
||||
*/
|
||||
// @JsonProperty(value = "SessionEndTime")
|
||||
// @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm:ss", timezone = "Europe/Moscow")
|
||||
private Date SessionEndTime = null;
|
||||
|
||||
public Date getSessionEndTime() {
|
||||
return SessionEndTime;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
package ru.spcex.clearing.imdg.config;
|
||||
|
||||
//import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@SuppressWarnings({"DefaultAnnotationParam", "unused", "FieldCanBeLocal"})
|
||||
public class SettingsElement implements Serializable {
|
||||
// @JsonProperty(value = "InitHazelcastThreadMultiplier", required = false)
|
||||
private int initHazelcastThreadMultiplier = 2;
|
||||
|
||||
// @JsonProperty(value = "RecoveryLogPath", required = false)
|
||||
private String recoveryLogPath;
|
||||
|
||||
// @JsonProperty(value = "ExecutionLimitationPeriod", required = false)
|
||||
private Integer executionLimitationPeriod = 10;
|
||||
|
||||
public int getInitHazelcastThreadMultiplier() {
|
||||
return initHazelcastThreadMultiplier;
|
||||
}
|
||||
|
||||
public Integer getExecutionLimitationPeriod() {
|
||||
return executionLimitationPeriod;
|
||||
}
|
||||
|
||||
public String getRecoveryLogPath() {
|
||||
return recoveryLogPath;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,89 +0,0 @@
|
|||
package ru.spcex.clearing.imdg.config;
|
||||
|
||||
//import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@SuppressWarnings({"FieldCanBeLocal", "unused", "DefaultAnnotationParam"})
|
||||
public class SettingsElementDatabase implements Serializable {
|
||||
|
||||
// @JsonProperty(value = "Driver")
|
||||
private String driver = "org.firebirdsql.jdbc.FBDriver";
|
||||
|
||||
// @JsonProperty(value = "JdbcConnectionString", required = true)
|
||||
private String jdbcConnectionString;
|
||||
|
||||
// @JsonProperty(value = "Login", required = true)
|
||||
private String login;
|
||||
|
||||
// @JsonProperty(value = "Password", required = true)
|
||||
private String password;
|
||||
|
||||
// @JsonProperty(value = "MaxPoolSize")
|
||||
private int maxPoolSize = 30;
|
||||
|
||||
// @JsonProperty(value = "MinPoolSize")
|
||||
private int minPoolSize = 10;
|
||||
|
||||
// @JsonProperty(value = "EmbeddedFilePath", required = false)
|
||||
private String embeddedFilePath;
|
||||
|
||||
// @JsonProperty(value = "NumHelperThreads", required = false)
|
||||
private int numHelperThreads = Runtime.getRuntime().availableProcessors() * 2;
|
||||
|
||||
// @JsonProperty(value = "ConnectionAcquireTimeoutSeconds", required = false)
|
||||
private int connectionAcquireTimeoutSeconds = 30;
|
||||
|
||||
public String getDriver() {
|
||||
return driver;
|
||||
}
|
||||
|
||||
public String getJdbcConnectionString() {
|
||||
return jdbcConnectionString;
|
||||
}
|
||||
|
||||
public String getLogin() {
|
||||
return login;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public int getMaxPoolSize() {
|
||||
return maxPoolSize;
|
||||
}
|
||||
|
||||
public int getMinPoolSize() {
|
||||
return minPoolSize;
|
||||
}
|
||||
|
||||
public String getEmbeddedFilePath() {
|
||||
return embeddedFilePath;
|
||||
}
|
||||
|
||||
public int getNumHelperThreads() {
|
||||
return numHelperThreads;
|
||||
}
|
||||
|
||||
public int getConnectionAcquireTimeoutSeconds() {
|
||||
return connectionAcquireTimeoutSeconds;
|
||||
}
|
||||
|
||||
// для поддержки интеграционных тестов otc-test:
|
||||
public void setJdbcConnectionString(String jdbcConnectionString) {
|
||||
this.jdbcConnectionString = jdbcConnectionString;
|
||||
}
|
||||
|
||||
public void setLogin(String login) {
|
||||
this.login = login;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public void setEmbeddedFilePath(String embeddedFilePath) {
|
||||
this.embeddedFilePath = embeddedFilePath;
|
||||
}
|
||||
}
|
||||
|
|
@ -4,24 +4,20 @@ import com.hazelcast.config.MapStoreConfig;
|
|||
import com.hazelcast.core.HazelcastInstance;
|
||||
import com.hazelcast.core.IMap;
|
||||
import com.hazelcast.core.IdGenerator;
|
||||
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.dao.DataAccessException;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import ru.clearing.classes.objects.BusinessObject;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.imdg.base.DictionaryMapStore;
|
||||
import ru.spcex.clearing.imdg.base.SimpleObjectMapStore;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.platform.imdg.iml.hazelcast.util.HazelcastHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
//todo почистить класс
|
||||
public abstract class AbstractHazelcastLifecycleSupport implements InitializingBean, DisposableBean {
|
||||
|
|
@ -108,103 +104,19 @@ public abstract class AbstractHazelcastLifecycleSupport implements InitializingB
|
|||
log.info("IDGenerator {} already initialized in other node", IMDGDistributedNames.MAP_SEQUENCE_NAME);
|
||||
}
|
||||
|
||||
// MapStoreConfig mapStoreConfig = hazelcastServerInstance.getConfig().getMapConfig(HazelcastDistributedNames.Map_FixedIncomeProductExecution).getMapStoreConfig();
|
||||
// FixedIncomeProductExecutionMapStore fixedIncomeProductExecutionMapStore = (FixedIncomeProductExecutionMapStore) mapStoreConfig.getImplementation();
|
||||
// Long maxExecutionNumber = jdbcTemplate.queryForObject("select max(executionnumber) from " + fixedIncomeProductExecutionMapStore.getTableName(), Long.class);
|
||||
// log.info("{} max(executionnumber)={}", fixedIncomeProductExecutionMapStore.getTableName(), maxExecutionNumber);
|
||||
// if (maxExecutionNumber != null) {
|
||||
// if (Integer.MAX_VALUE - maxExecutionNumber < 1000000)
|
||||
// log.error("max(executionnumber) close to int32 max value");
|
||||
// IAtomicLong executionNumberAtomicLong = hazelcastServerInstance.getAtomicLong(HazelcastDistributedNames.AtomicLong_ExecutionNumber);
|
||||
// executionNumberAtomicLong.set(maxExecutionNumber);
|
||||
// }
|
||||
//
|
||||
// if (startupTasksAdministrator != null) {
|
||||
// startupTasksAdministrator.createTasks();
|
||||
// }
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
throw new RuntimeException("MapStore multithreaded not complete.", e);
|
||||
}
|
||||
|
||||
HazelcastHelper.otcSystem_setStorageState(true, hazelcastServerInstance);
|
||||
// hazelcastServerInstance.getClientService().addClientListener(clientListener);
|
||||
loadTime = System.currentTimeMillis() - loadTime;
|
||||
log.info("All map load time {} ms", loadTime);
|
||||
|
||||
// TextErrorService.setHazelcast(hazelcastServerInstance);
|
||||
|
||||
// clusterStatistic();
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Подсчитывает кол-во запусков, первый запуск. Пишет в лог.
|
||||
// * Storage note status: ...
|
||||
// */
|
||||
// protected void clusterStatistic() {
|
||||
// try {
|
||||
// boolean isFirstNodeReady = HazelcastCommon.otcSystem_setStorageInfo(new Date(), true, hazelcastServerInstance);
|
||||
// String msg = "Storage node status: " + (isFirstNodeReady ? "first Storage node" : "second node")
|
||||
// + ", first node start at " + HazelcastCommon.otcSystem_getFirstStorageTime(hazelcastServerInstance);
|
||||
// String firstOtcVersion = HazelcastCommon.otcSystem_getFirstStorageVersion(hazelcastServerInstance);
|
||||
// if (firstOtcVersion != null)
|
||||
// msg += "(OTC " + firstOtcVersion + ")";
|
||||
// msg += ", count of all storage connection " + HazelcastCommon.otcSystem_getStorageConnectCount(hazelcastServerInstance) + ".";
|
||||
// msg += " Hazelcast cluster members: " + hazelcastServerInstance.getCluster().getMembers().size() + ".";
|
||||
// log.info(msg);
|
||||
// } catch (Exception e) {
|
||||
// log.warn("Error at print Storage cluster info.", e);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
hazelcastServerInstance.shutdown();
|
||||
}
|
||||
|
||||
protected void databaseVersionCheck() throws RuntimeException, IllegalArgumentException {
|
||||
log.debug("Validate DB version, expected \"{}\"", getCheckDbVersion());
|
||||
String dbVersion = null;
|
||||
try {
|
||||
dbVersion = jdbcTemplate.queryForObject("select version from VERSIONEDID", String.class);
|
||||
log.info("DB version is \"{}\"", dbVersion);
|
||||
if (StringUtils.isBlank(dbVersion)) {
|
||||
String msg = "Database not contain version information (table VERSIONEDID)";//TextErrorService.text(StorageErrors.StorageErrors_WrongDBVersion) + " Database not contain version information (table VERSIONEDID)";
|
||||
log.error(msg);
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
if (!isAllowDBVersion(getCheckDbVersion(), dbVersion)) {
|
||||
String msg = " platform " + getCheckDbVersion() + ", db " + dbVersion;//TextErrorService.text(StorageErrors.StorageErrors_WrongDBVersion) + " platform " + getCheckDbVersion() + ", db " + dbVersion;
|
||||
log.error(msg);
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
} catch (DataAccessException | IllegalArgumentException e) { // EmptyResultDataAccessException
|
||||
String msg = e.toString();//TextErrorService.text(StorageErrors.StorageErrors_WrongDBVersion) + " platform " + getCheckDbVersion() + ", db " + dbVersion;
|
||||
log.error(msg);
|
||||
throw new RuntimeException(msg, e); // Ошибка 10002 - Версия Бд не поддерживается
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Првоерка версии. Формат: 1.2.*
|
||||
*
|
||||
* @param moduleVersion версия кода
|
||||
* @param dbVersion версия базы
|
||||
* @return true - версии правильные, false - версия БД устарела или не совпадает.
|
||||
* @throws IllegalArgumentException если неправильно распарсилась версия, в частности может случиться NumberFormatException.
|
||||
*/
|
||||
static boolean isAllowDBVersion(String moduleVersion, String dbVersion) throws IllegalArgumentException {
|
||||
Pattern versionPattern = Pattern.compile("(\\d+)\\.(\\d+)(\\..*){0,1}"); // (\d+)\.(\d+)(\..*){0,1}
|
||||
Matcher mModule = versionPattern.matcher(moduleVersion);
|
||||
Matcher mDB = versionPattern.matcher(dbVersion);
|
||||
if (!mModule.find())
|
||||
throw new IllegalArgumentException("Module version have wrong format: " + moduleVersion);
|
||||
if (!mDB.find())
|
||||
throw new IllegalArgumentException("Version from database have wrong format: " + moduleVersion);
|
||||
int majorModule = Integer.parseInt(mModule.group(1));
|
||||
int minorModule = Integer.parseInt(mModule.group(2));
|
||||
int majorDB = Integer.parseInt(mDB.group(1));
|
||||
int minorDB = Integer.parseInt(mDB.group(2));
|
||||
return majorDB == majorModule && minorDB >= minorModule;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ public abstract class HazelcastServiceBase
|
|||
while (!done) {
|
||||
log.debug("Execute awaitGeneratorId()");
|
||||
try {
|
||||
HazelcastHelper.otcSystem_waitTillReadyState(getHazelcast());
|
||||
HazelcastHelper.waitTillReadyState(getHazelcast());
|
||||
onAvailable();
|
||||
done = true;
|
||||
} catch (Throwable e) {
|
||||
|
|
@ -310,7 +310,7 @@ public abstract class HazelcastServiceBase
|
|||
try {
|
||||
HazelcastInstance instance = getHazelcast();
|
||||
if (instance != null) {
|
||||
HazelcastHelper.otcSystem_waitTillReadyState(instance);
|
||||
HazelcastHelper.waitTillReadyState(instance);
|
||||
done = true;
|
||||
break;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,8 @@ public final class HazelcastHelper {
|
|||
public static final int DEFAULT_CONNECTION_ATTEMPT_PERIOD_SEC = 10;
|
||||
public static final int DEFAULT_CONNECTION_ATTEMPT_LIMIT = Integer.MAX_VALUE;
|
||||
public static final int TEST_CONNECTION_ATTEMPT_LIMIT = 1;
|
||||
public static final String OTC_SYSTEM_MAP = "OTC_SYSTEM";
|
||||
public static final String CLEARING_SYSTEM_MAP = "CLEARING_SYSTEM";
|
||||
public static final String STATE_OF_IMDG_SERVER = "IMDG.STATE";
|
||||
|
||||
public static ClientConfig getClientConfig(String members, String login, String password, String instanceName) {
|
||||
return getClientConfig(members, login, password, instanceName, null);
|
||||
|
|
@ -79,8 +80,7 @@ public final class HazelcastHelper {
|
|||
while (!done) {
|
||||
try {
|
||||
instance = HazelcastClient.newHazelcastClient(hzClientConfig);// createHzClient();
|
||||
otcSystem_waitTillReadyState(instance);
|
||||
// TextErrorService.setHazelcast(instance);
|
||||
waitTillReadyState(instance);
|
||||
log.info("Hazelcast: TextErrorService done");
|
||||
done = true;
|
||||
} catch (InterruptedException e) {
|
||||
|
|
@ -99,10 +99,10 @@ public final class HazelcastHelper {
|
|||
return instance;
|
||||
}
|
||||
|
||||
public static void otcSystem_waitTillReadyState(HazelcastInstance hazelcast) throws InterruptedException {
|
||||
public static void waitTillReadyState(HazelcastInstance hazelcast) throws InterruptedException {
|
||||
int sleepCount = 0;
|
||||
try {
|
||||
while (!otcSystem_getStorageState(hazelcast)) {
|
||||
while (!getIdmgState(hazelcast)) {
|
||||
if (sleepCount++ % 30 == 0)
|
||||
log.info("Wait till STORAGE be ready...");
|
||||
Thread.sleep(100);
|
||||
|
|
@ -115,14 +115,14 @@ public final class HazelcastHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public static boolean otcSystem_getStorageState(HazelcastInstance hazelcast) {
|
||||
IMap<String, String> systemMap = hazelcast.getMap(OTC_SYSTEM_MAP);
|
||||
return Boolean.valueOf(systemMap.get("STORAGE.STATE"));
|
||||
public static boolean getIdmgState(HazelcastInstance hazelcast) {
|
||||
IMap<String, String> systemMap = hazelcast.getMap(CLEARING_SYSTEM_MAP);
|
||||
return Boolean.valueOf(systemMap.get(STATE_OF_IMDG_SERVER));
|
||||
}
|
||||
|
||||
public static void otcSystem_setStorageState(boolean val, HazelcastInstance hazelcast) {
|
||||
IMap<String, String> systemMap = hazelcast.getMap(OTC_SYSTEM_MAP);
|
||||
systemMap.set("STORAGE.STATE", Boolean.toString(val));
|
||||
IMap<String, String> systemMap = hazelcast.getMap(CLEARING_SYSTEM_MAP);
|
||||
systemMap.set(STATE_OF_IMDG_SERVER, Boolean.toString(val));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue