use of org.wildfly.clustering.service.ServiceSupplierDependency in project wildfly by wildfly.
the class RemoteCacheContainerConfigurationServiceConfigurator method configure.
@Override
public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException {
this.connectionTimeout = Attribute.CONNECTION_TIMEOUT.resolveModelAttribute(context, model).asInt();
this.defaultRemoteCluster = Attribute.DEFAULT_REMOTE_CLUSTER.resolveModelAttribute(context, model).asString();
this.maxRetries = Attribute.MAX_RETRIES.resolveModelAttribute(context, model).asInt();
this.protocolVersion = Attribute.PROTOCOL_VERSION.resolveModelAttribute(context, model).asString();
this.socketTimeout = Attribute.SOCKET_TIMEOUT.resolveModelAttribute(context, model).asInt();
this.tcpNoDelay = Attribute.TCP_NO_DELAY.resolveModelAttribute(context, model).asBoolean();
this.tcpKeepAlive = Attribute.TCP_KEEP_ALIVE.resolveModelAttribute(context, model).asBoolean();
this.statisticsEnabled = Attribute.STATISTICS_ENABLED.resolveModelAttribute(context, model).asBoolean();
this.transactionTimeout = Attribute.TRANSACTION_TIMEOUT.resolveModelAttribute(context, model).asLong();
this.marshallerFactory = HotRodMarshallerFactory.valueOf(Attribute.MARSHALLER.resolveModelAttribute(context, model).asString());
this.clusters.clear();
Resource container = context.readResource(PathAddress.EMPTY_ADDRESS);
for (Resource.ResourceEntry entry : container.getChildren(RemoteClusterResourceDefinition.WILDCARD_PATH.getKey())) {
String clusterName = entry.getName();
ModelNode cluster = entry.getModel();
List<String> bindings = StringListAttributeDefinition.unwrapValue(context, RemoteClusterResourceDefinition.Attribute.SOCKET_BINDINGS.resolveModelAttribute(context, cluster));
List<SupplierDependency<OutboundSocketBinding>> bindingDependencies = new ArrayList<>(bindings.size());
for (String binding : bindings) {
bindingDependencies.add(new ServiceSupplierDependency<>(CommonUnaryRequirement.OUTBOUND_SOCKET_BINDING.getServiceName(context, binding)));
}
this.clusters.put(clusterName, bindingDependencies);
}
this.server = context.hasOptionalCapability(CommonRequirement.MBEAN_SERVER.getName(), null, null) ? new ServiceSupplierDependency<>(CommonRequirement.MBEAN_SERVER.getServiceName(context)) : null;
this.properties.clear();
for (Property property : Attribute.PROPERTIES.resolveModelAttribute(context, model).asPropertyListOrEmpty()) {
this.properties.setProperty(property.getName(), property.getValue().asString());
}
return this;
}
use of org.wildfly.clustering.service.ServiceSupplierDependency in project wildfly by wildfly.
the class CacheDependenciesProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext context) {
DeploymentUnit unit = context.getDeploymentUnit();
final ServiceName name = unit.getServiceName();
EEModuleDescription moduleDescription = unit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
if (moduleDescription == null) {
return;
}
final CapabilityServiceSupport support = unit.getAttachment(org.jboss.as.server.deployment.Attachments.CAPABILITY_SERVICE_SUPPORT);
final ServiceTarget target = context.getServiceTarget();
Set<SupplierDependency<CacheFactoryBuilder<SessionID, StatefulSessionComponentInstance>>> dependencies = new HashSet<>();
for (ComponentDescription description : moduleDescription.getComponentDescriptions()) {
if (description instanceof StatefulComponentDescription) {
StatefulComponentDescription statefulDescription = (StatefulComponentDescription) description;
dependencies.add(new ServiceSupplierDependency<>(getCacheFactoryBuilderServiceName(statefulDescription)));
}
}
Service service = new ChildTargetService(new Consumer<ServiceTarget>() {
@Override
public void accept(ServiceTarget target) {
// Cache factory builder dependencies might still contain duplicates (if referenced via alias), so ensure we collect only distinct instances.
Set<CacheFactoryBuilder<SessionID, StatefulSessionComponentInstance>> builders = new HashSet<>(dependencies.size());
for (Supplier<CacheFactoryBuilder<SessionID, StatefulSessionComponentInstance>> dependency : dependencies) {
builders.add(dependency.get());
}
for (CacheFactoryBuilder<SessionID, StatefulSessionComponentInstance> builder : builders) {
for (CapabilityServiceConfigurator configurator : builder.getDeploymentServiceConfigurators(unit)) {
configurator.configure(support).build(target).install();
}
}
}
});
ServiceBuilder<?> builder = target.addService(name.append("cache-dependencies-installer"));
for (Dependency dependency : dependencies) {
dependency.register(builder);
}
builder.setInstance(service).install();
// Install versioned marshalling configuration
new MarshallingConfigurationRepositoryServiceConfigurator(unit).build(target).setInitialMode(ServiceController.Mode.ON_DEMAND).install();
}
use of org.wildfly.clustering.service.ServiceSupplierDependency in project wildfly by wildfly.
the class DistributableSingleSignOnManagerServiceConfigurator method configure.
@Override
public ServiceConfigurator configure(OperationContext context) {
String securityDomainName = this.configuration.getSecurityDomainName();
Supplier<String> generator = this.configuration.getIdentifierGenerator();
CapabilityServiceSupport support = context.getCapabilityServiceSupport();
SupplierDependency<DistributableSSOManagementProvider> provider = getProvider(context, securityDomainName);
ServiceName managerServiceName = this.getServiceName().append("manager");
this.manager = new ServiceSupplierDependency<>(managerServiceName);
this.provider = provider;
this.installer = new Consumer<ServiceTarget>() {
@Override
public void accept(ServiceTarget target) {
ServiceConfigurator factoryConfigurator = provider.get().getServiceConfigurator(securityDomainName).configure(support);
factoryConfigurator.build(target).install();
SupplierDependency<SSOManagerFactory<ElytronAuthentication, String, Map.Entry<String, URI>, Batch>> factoryDependency = new ServiceSupplierDependency<>(factoryConfigurator);
SupplierDependency<SessionIdGenerator> generatorDependency = new SimpleSupplierDependency<>(new SessionIdGeneratorAdapter(generator));
new SSOManagerServiceConfigurator<>(managerServiceName, factoryDependency, generatorDependency, new LocalSSOContextFactory()).configure(support).build(target).install();
}
};
return this;
}
use of org.wildfly.clustering.service.ServiceSupplierDependency in project wildfly by wildfly.
the class ProxyConfigurationServiceConfigurator method configure.
@SuppressWarnings("deprecation")
@Override
public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException {
// Advertise
String advertiseSocket = ADVERTISE_SOCKET.resolveModelAttribute(context, model).asStringOrNull();
this.advertiseSocketDependency = (advertiseSocket != null) ? new ServiceSupplierDependency<>(CommonUnaryRequirement.SOCKET_BINDING.getServiceName(context, advertiseSocket)) : null;
this.builder.advertise().setAdvertiseSecurityKey(ADVERTISE_SECURITY_KEY.resolveModelAttribute(context, model).asStringOrNull());
// MCMP
builder.mcmp().setAdvertise(ADVERTISE.resolveModelAttribute(context, model).asBoolean()).setProxyURL(PROXY_URL.resolveModelAttribute(context, model).asString()).setAutoEnableContexts(AUTO_ENABLE_CONTEXTS.resolveModelAttribute(context, model).asBoolean()).setStopContextTimeout(STOP_CONTEXT_TIMEOUT.resolveModelAttribute(context, model).asInt()).setStopContextTimeoutUnit(TimeUnit.valueOf(STOP_CONTEXT_TIMEOUT.getDefinition().getMeasurementUnit().getName())).setSocketTimeout(SOCKET_TIMEOUT.resolveModelAttribute(context, model).asInt() * 1000).setSessionDrainingStrategy(Enum.valueOf(SessionDrainingStrategyEnum.class, SESSION_DRAINING_STRATEGY.resolveModelAttribute(context, model).asString()));
if (model.hasDefined(EXCLUDED_CONTEXTS.getName())) {
String contexts = EXCLUDED_CONTEXTS.resolveModelAttribute(context, model).asString();
Map<String, Set<String>> excludedContextsPerHost;
if (contexts == null) {
excludedContextsPerHost = Collections.emptyMap();
} else {
String trimmedContexts = contexts.trim();
if (trimmedContexts.isEmpty()) {
excludedContextsPerHost = Collections.emptyMap();
} else {
excludedContextsPerHost = new HashMap<>();
for (String c : trimmedContexts.split(",")) {
String[] parts = c.trim().split(":");
if (parts.length > 2) {
throw ROOT_LOGGER.excludedContextsWrongFormat(trimmedContexts);
}
String host = null;
String trimmedContext = parts[0].trim();
if (parts.length == 2) {
host = trimmedContext;
trimmedContext = parts[1].trim();
}
String path;
switch(trimmedContext) {
case "ROOT":
ROOT_LOGGER.excludedContextsUseSlashInsteadROOT();
case "/":
path = "";
break;
default:
// normalize the context by pre-pending or removing trailing slash
trimmedContext = trimmedContext.startsWith("/") ? trimmedContext : ("/" + trimmedContext);
path = trimmedContext.endsWith("/") ? trimmedContext.substring(0, trimmedContext.length() - 1) : trimmedContext;
break;
}
Set<String> paths = excludedContextsPerHost.computeIfAbsent(host, k -> new HashSet<>());
paths.add(path);
}
}
}
builder.mcmp().setExcludedContextsPerHost(excludedContextsPerHost);
}
// Balancer
builder.balancer().setStickySession(STICKY_SESSION.resolveModelAttribute(context, model).asBoolean()).setStickySessionRemove(STICKY_SESSION_REMOVE.resolveModelAttribute(context, model).asBoolean()).setStickySessionForce(STICKY_SESSION_FORCE.resolveModelAttribute(context, model).asBoolean()).setWorkerTimeout(WORKER_TIMEOUT.resolveModelAttribute(context, model).asInt()).setMaxAttempts(MAX_ATTEMPTS.resolveModelAttribute(context, model).asInt());
// Node
builder.node().setFlushPackets(FLUSH_PACKETS.resolveModelAttribute(context, model).asBoolean()).setFlushWait(FLUSH_WAIT.resolveModelAttribute(context, model).asInt()).setPing(PING.resolveModelAttribute(context, model).asInt()).setSmax(SMAX.resolveModelAttribute(context, model).asInt()).setTtl(TTL.resolveModelAttribute(context, model).asInt()).setNodeTimeout(NODE_TIMEOUT.resolveModelAttribute(context, model).asInt());
ModelNode node = BALANCER.resolveModelAttribute(context, model);
if (node.isDefined()) {
builder.node().setBalancer(node.asString());
}
node = LOAD_BALANCING_GROUP.resolveModelAttribute(context, model);
if (node.isDefined()) {
builder.node().setLoadBalancingGroup(node.asString());
}
node = PROXIES.resolveModelAttribute(context, model);
if (node.isDefined()) {
for (ModelNode ref : node.asList()) {
String asString = ref.asString();
this.outboundSocketBindings.add(new ServiceSupplierDependency<>(CommonUnaryRequirement.OUTBOUND_SOCKET_BINDING.getServiceName(context, asString)));
}
}
String proxyList = PROXY_LIST.resolveModelAttribute(context, model).asStringOrNull();
if (proxyList != null && proxyList.length() != 0) {
Collection<ProxyConfiguration> proxyConfigurations;
String[] tokens = proxyList.split(",");
proxyConfigurations = new ArrayList<>(tokens.length);
for (String token : tokens) {
try {
final InetSocketAddress remoteAddress = Utils.parseSocketAddress(token.trim(), ModClusterService.DEFAULT_PORT);
proxyConfigurations.add(new ProxyConfiguration() {
@Override
public InetSocketAddress getRemoteAddress() {
return remoteAddress;
}
@Override
public InetSocketAddress getLocalAddress() {
return null;
}
});
} catch (UnknownHostException e) {
throw new IllegalArgumentException(e);
}
}
builder.mcmp().setProxyConfigurations(proxyConfigurations);
}
// Elytron-based security support
node = SSL_CONTEXT.resolveModelAttribute(context, model);
if (node.isDefined()) {
this.sslContextDependency = new ServiceSupplierDependency<>(CommonUnaryRequirement.SSL_CONTEXT.getServiceName(context, node.asString()));
}
if (model.get(SSLResourceDefinition.PATH.getKeyValuePair()).isDefined()) {
if (node.isDefined()) {
throw ROOT_LOGGER.bothElytronAndLegacySslContextDefined();
}
ModelNode sslModel = model.get(SSLResourceDefinition.PATH.getKeyValuePair());
ModClusterConfig sslConfiguration = new ModClusterConfig();
node = SSLResourceDefinition.Attribute.KEY_ALIAS.resolveModelAttribute(context, sslModel);
if (node.isDefined()) {
sslConfiguration.setSslKeyAlias(node.asString());
}
node = SSLResourceDefinition.Attribute.PASSWORD.resolveModelAttribute(context, sslModel);
if (node.isDefined()) {
String password = node.asString();
sslConfiguration.setSslTrustStorePassword(password);
sslConfiguration.setSslKeyStorePassword(password);
}
node = SSLResourceDefinition.Attribute.CERTIFICATE_KEY_FILE.resolveModelAttribute(context, sslModel);
if (node.isDefined()) {
sslConfiguration.setSslKeyStore(node.asString());
}
node = SSLResourceDefinition.Attribute.CIPHER_SUITE.resolveModelAttribute(context, sslModel);
if (node.isDefined()) {
sslConfiguration.setSslCiphers(node.asString());
}
node = SSLResourceDefinition.Attribute.PROTOCOL.resolveModelAttribute(context, sslModel);
if (node.isDefined()) {
sslConfiguration.setSslProtocol(node.asString());
}
node = SSLResourceDefinition.Attribute.CA_CERTIFICATE_FILE.resolveModelAttribute(context, sslModel);
if (node.isDefined()) {
sslConfiguration.setSslTrustStore(node.asString());
}
node = SSLResourceDefinition.Attribute.CA_REVOCATION_URL.resolveModelAttribute(context, sslModel);
if (node.isDefined()) {
sslConfiguration.setSslCrlFile(node.asString());
}
builder.mcmp().setSocketFactory(new JSSESocketFactory(sslConfiguration));
}
return this;
}
use of org.wildfly.clustering.service.ServiceSupplierDependency in project wildfly by wildfly.
the class ElectionPolicyServiceConfigurator method configure.
@Override
public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException {
List<ModelNode> socketBindingPreferences = SOCKET_BINDING_PREFERENCES.resolveModelAttribute(context, model).asListOrEmpty();
List<ModelNode> namePreferences = NAME_PREFERENCES.resolveModelAttribute(context, model).asListOrEmpty();
List<Preference> preferences = new ArrayList<>(socketBindingPreferences.size() + namePreferences.size());
List<Dependency> dependencies = new ArrayList<>(socketBindingPreferences.size());
for (ModelNode preference : socketBindingPreferences) {
SupplierDependency<OutboundSocketBinding> binding = new ServiceSupplierDependency<>(CommonUnaryRequirement.OUTBOUND_SOCKET_BINDING.getServiceName(context, preference.asString()));
preferences.add(new OutboundSocketBindingPreference(binding));
dependencies.add(binding);
}
for (ModelNode preference : namePreferences) {
preferences.add(new NamePreference(preference.asString()));
}
this.dependencies = dependencies;
this.preferences = preferences;
return this;
}
Aggregations