static boolean isActiveInContext(final OperationContext context) {
return context.getAttachment(SUBSYSTEM_ADD_KEY) != null;
}
private ModClusterConfig getModClusterConfig(final OperationContext context, ModelNode model) throws OperationFailedException {
ModClusterConfig config = new ModClusterConfig();
config.setAdvertise(ADVERTISE.resolveModelAttribute(context, model).asBoolean());
if (model.get(ModClusterSSLResourceDefinition.PATH.getKeyValuePair()).isDefined()) {
// Add SSL configuration.
config.setSsl(true);
final ModelNode ssl = model.get(ModClusterSSLResourceDefinition.PATH.getKeyValuePair());
ModelNode keyAlias = KEY_ALIAS.resolveModelAttribute(context, ssl);
ModelNode password = PASSWORD.resolveModelAttribute(context, ssl);
if (keyAlias.isDefined()) {
config.setSslKeyAlias(keyAlias.asString());
}
if (password.isDefined()) {
config.setSslTrustStorePassword(password.asString());
config.setSslKeyStorePassword(password.asString());
}
if (ssl.hasDefined(CommonAttributes.CERTIFICATE_KEY_FILE)) {
config.setSslKeyStore(CERTIFICATE_KEY_FILE.resolveModelAttribute(context, ssl).asString());
}
if (ssl.hasDefined(CommonAttributes.CIPHER_SUITE)) {
config.setSslCiphers(CIPHER_SUITE.resolveModelAttribute(context, ssl).asString());
}
if (ssl.hasDefined(CommonAttributes.PROTOCOL)) {
config.setSslProtocol(PROTOCOL.resolveModelAttribute(context, ssl).asString());
}
if (ssl.hasDefined(CommonAttributes.CA_CERTIFICATE_FILE)) {
config.setSslTrustStore(CA_CERTIFICATE_FILE.resolveModelAttribute(context, ssl).asString());
}
if (ssl.hasDefined(CommonAttributes.CA_REVOCATION_URL)) {
config.setSslCrlFile(CA_REVOCATION_URL.resolveModelAttribute(context, ssl).asString());
}
}
if (model.hasDefined(CommonAttributes.PROXY_LIST)) {
throw new OperationFailedException(ROOT_LOGGER.proxyListNotAllowedInCurrentModel());
}
if (model.hasDefined(CommonAttributes.ADVERTISE_SECURITY_KEY)) {
config.setAdvertiseSecurityKey(ADVERTISE_SECURITY_KEY.resolveModelAttribute(context, model).asString());
}
config.setProxyURL(PROXY_URL.resolveModelAttribute(context, model).asString());
config.setExcludedContexts(EXCLUDED_CONTEXTS.resolveModelAttribute(context, model).asString().trim());
config.setAutoEnableContexts(AUTO_ENABLE_CONTEXTS.resolveModelAttribute(context, model).asBoolean());
config.setStopContextTimeout(STOP_CONTEXT_TIMEOUT.resolveModelAttribute(context, model).asInt());
config.setStopContextTimeoutUnit(TimeUnit.valueOf(STOP_CONTEXT_TIMEOUT.getMeasurementUnit().getName()));
//config.setStopContextTimeoutUnit(TimeUnit.SECONDS); //todo use AttributeDefinition.getMeasurementUnit
// the default value is 20000 = 20 seconds.
config.setSocketTimeout(SOCKET_TIMEOUT.resolveModelAttribute(context, model).asInt() * 1000);
config.setStickySession(STICKY_SESSION.resolveModelAttribute(context, model).asBoolean());
config.setStickySessionRemove(STICKY_SESSION_REMOVE.resolveModelAttribute(context, model).asBoolean());
config.setStickySessionForce(STICKY_SESSION_FORCE.resolveModelAttribute(context, model).asBoolean());
config.setWorkerTimeout(WORKER_TIMEOUT.resolveModelAttribute(context, model).asInt());
config.setMaxAttempts(MAX_ATTEMPTS.resolveModelAttribute(context, model).asInt());
config.setFlushPackets(FLUSH_PACKETS.resolveModelAttribute(context, model).asBoolean());
config.setFlushWait(FLUSH_WAIT.resolveModelAttribute(context, model).asInt());
config.setPing(PING.resolveModelAttribute(context, model).asInt());
config.setSmax(SMAX.resolveModelAttribute(context, model).asInt());
config.setTtl(TTL.resolveModelAttribute(context, model).asInt());
config.setNodeTimeout(NODE_TIMEOUT.resolveModelAttribute(context, model).asInt());
config.setSessionDrainingStrategy(SESSION_DRAINING_STRATEGY.resolveModelAttribute(context, model).asString());
if (model.hasDefined(CommonAttributes.BALANCER)) {
config.setBalancer(BALANCER.resolveModelAttribute(context, model).asString());
}
if (model.hasDefined(CommonAttributes.LOAD_BALANCING_GROUP)) {
config.setLoadBalancingGroup(LOAD_BALANCING_GROUP.resolveModelAttribute(context, model).asString());
}
return config;
}