use of org.apache.knox.gateway.ha.provider.HaServiceConfig in project knox by apache.
the class HaProviderDeploymentContributor method contributeProvider.
@Override
public void contributeProvider(DeploymentContext context, Provider provider) {
Topology topology = context.getTopology();
Map<String, String> params = provider.getParams();
HaDescriptor descriptor = HaDescriptorFactory.createDescriptor();
for (Entry<String, String> entry : params.entrySet()) {
String role = entry.getKey();
String roleParams = entry.getValue();
// Create the config based on whatever is specified at the provider level
HaServiceConfig config = HaDescriptorFactory.createServiceConfig(role, roleParams);
// Check for service-level param overrides
Map<String, String> serviceLevelParams = null;
for (Service s : topology.getServices()) {
if (s.getRole().equals(role)) {
serviceLevelParams = s.getParams();
break;
}
}
// Apply any service-level param overrides
applyParamOverrides(config, serviceLevelParams);
// Add the reconciled HA service config to the descriptor
descriptor.addServiceConfig(config);
}
StringWriter writer = new StringWriter();
try {
HaDescriptorManager.store(descriptor, writer);
} catch (IOException e) {
LOG.failedToWriteHaDescriptor(e);
}
String asset = writer.toString();
context.getWebArchive().addAsWebInfResource(new StringAsset(asset), HaServletContextListener.DESCRIPTOR_DEFAULT_FILE_NAME);
context.addDescriptor(HA_DESCRIPTOR_NAME, descriptor);
}
use of org.apache.knox.gateway.ha.provider.HaServiceConfig in project knox by apache.
the class DefaultHaDispatch method init.
@Override
public void init() {
super.init();
LOG.initializingForResourceRole(getServiceRole());
if (haProvider != null) {
HaServiceConfig serviceConfig = haProvider.getHaDescriptor().getServiceConfig(getServiceRole());
maxFailoverAttempts = serviceConfig.getMaxFailoverAttempts();
failoverSleep = serviceConfig.getFailoverSleep();
}
}
use of org.apache.knox.gateway.ha.provider.HaServiceConfig in project knox by apache.
the class DefaultHaDescriptor method getEnabledServiceNames.
@Override
public List<String> getEnabledServiceNames() {
ArrayList<String> services = new ArrayList<String>(serviceConfigs.size());
Collection<HaServiceConfig> configs = serviceConfigs.values();
for (HaServiceConfig config : configs) {
if (config.isEnabled()) {
services.add(config.getServiceName());
}
}
return services;
}
use of org.apache.knox.gateway.ha.provider.HaServiceConfig in project knox by apache.
the class RMHaDispatch method init.
@Override
public void init() {
super.init();
if (haProvider != null) {
super.setResourceRole(RESOURCE_ROLE);
HaServiceConfig serviceConfig = haProvider.getHaDescriptor().getServiceConfig(RESOURCE_ROLE);
super.setMaxFailoverAttempts(serviceConfig.getMaxFailoverAttempts());
super.setFailoverSleep(serviceConfig.getFailoverSleep());
super.setMaxRetryAttempts(serviceConfig.getMaxRetryAttempts());
super.setRetrySleep(serviceConfig.getRetrySleep());
super.setHaProvider(haProvider);
}
}
use of org.apache.knox.gateway.ha.provider.HaServiceConfig in project knox by apache.
the class RMUIHaDispatch method init.
@Override
public void init() {
super.init();
if (haProvider != null) {
super.setResourceRole(RESOURCE_ROLE);
HaServiceConfig serviceConfig = haProvider.getHaDescriptor().getServiceConfig(RESOURCE_ROLE);
super.setMaxFailoverAttempts(serviceConfig.getMaxFailoverAttempts());
super.setFailoverSleep(serviceConfig.getFailoverSleep());
super.setMaxRetryAttempts(serviceConfig.getMaxRetryAttempts());
super.setRetrySleep(serviceConfig.getRetrySleep());
super.setHaProvider(haProvider);
}
}
Aggregations