use of org.apache.qpid.server.store.berkeleydb.logging.Slf4jLoggingHandler in project qpid-broker-j by apache.
the class ReplicatedEnvironmentFacade method createEnvironment.
private void createEnvironment(boolean createEnvironmentInSeparateThread, Runnable postCreationAction) {
String groupName = _configuration.getGroupName();
String helperHostPort = _configuration.getHelperHostPort();
String hostPort = _configuration.getHostPort();
boolean designatedPrimary = _configuration.isDesignatedPrimary();
int priority = _configuration.getPriority();
int quorumOverride = _configuration.getQuorumOverride();
String nodeName = _configuration.getName();
String helperNodeName = _configuration.getHelperNodeName();
if (LOGGER.isInfoEnabled()) {
LOGGER.info("Creating environment");
LOGGER.info("Environment path " + _environmentDirectory.getAbsolutePath());
LOGGER.info("Group name " + groupName);
LOGGER.info("Node name " + nodeName);
LOGGER.info("Node host port " + hostPort);
LOGGER.info("Helper host port " + helperHostPort);
LOGGER.info("Helper node name " + helperNodeName);
LOGGER.info("Durability " + _defaultDurability);
LOGGER.info("Designated primary (applicable to 2 node case only) " + designatedPrimary);
LOGGER.info("Node priority " + priority);
LOGGER.info("Quorum override " + quorumOverride);
LOGGER.info("Permitted node list " + _permittedNodes);
}
Map<String, String> replicationEnvironmentParameters = new HashMap<>(ReplicatedEnvironmentFacade.REPCONFIG_DEFAULTS);
replicationEnvironmentParameters.putAll(_configuration.getReplicationParameters());
ReplicationConfig replicationConfig = new ReplicationConfig(groupName, nodeName, hostPort);
replicationConfig.setHelperHosts(helperHostPort);
replicationConfig.setDesignatedPrimary(designatedPrimary);
replicationConfig.setNodePriority(priority);
replicationConfig.setElectableGroupSizeOverride(quorumOverride);
for (Map.Entry<String, String> configItem : replicationEnvironmentParameters.entrySet()) {
if (LOGGER.isInfoEnabled()) {
LOGGER.info("Setting ReplicationConfig key " + configItem.getKey() + " to '" + configItem.getValue() + "'");
}
replicationConfig.setConfigParam(configItem.getKey(), configItem.getValue());
}
Map<String, String> environmentParameters = new HashMap<>(EnvironmentFacade.ENVCONFIG_DEFAULTS);
environmentParameters.putAll(_configuration.getParameters());
EnvironmentConfig envConfig = new EnvironmentConfig();
envConfig.setAllowCreate(true);
envConfig.setTransactional(true);
envConfig.setExceptionListener(new ExceptionListener());
envConfig.setDurability(_defaultDurability);
envConfig.setCacheMode(_configuration.getCacheMode());
envConfig.setLoggingHandler(new Slf4jLoggingHandler(_configuration));
LOGGER.info("Cache mode {}", envConfig.getCacheMode());
for (Map.Entry<String, String> configItem : environmentParameters.entrySet()) {
if (LOGGER.isInfoEnabled()) {
LOGGER.info("Setting EnvironmentConfig key " + configItem.getKey() + " to '" + configItem.getValue() + "'");
}
envConfig.setConfigParam(configItem.getKey(), configItem.getValue());
}
DbInternal.setLoadPropertyFile(envConfig, false);
File propsFile = new File(_environmentDirectory, "je.properties");
if (propsFile.exists()) {
LOGGER.warn("The BDB configuration file at '" + _environmentDirectory + File.separator + "je.properties' will NOT be loaded. Configure BDB using Qpid context variables instead.");
}
if (createEnvironmentInSeparateThread) {
createEnvironmentInSeparateThread(_environmentDirectory, envConfig, replicationConfig, postCreationAction);
} else {
createEnvironment(_environmentDirectory, envConfig, replicationConfig, postCreationAction);
}
}
Aggregations