use of org.apache.knox.gateway.topology.discovery.cm.ServiceModel in project knox by apache.
the class NameNodeServiceModelGeneratorTest method testServiceModelMetadataWithNameService.
@Test
public void testServiceModelMetadataWithNameService() {
final Map<String, String> serviceConfig = Collections.emptyMap();
final Map<String, String> roleConfig = new HashMap<>();
roleConfig.put(NameNodeServiceModelGenerator.AUTOFAILOVER_ENABLED, "true");
roleConfig.put(NameNodeServiceModelGenerator.NN_NAMESERVICE, "myService");
roleConfig.put(NameNodeServiceModelGenerator.NN_PORT, "12345");
ServiceModel generated = createServiceModel(serviceConfig, roleConfig);
validateServiceModel(generated, serviceConfig, roleConfig);
// Validate model metadata properties
final String qualifyingProperty = ServiceModel.QUALIFYING_SERVICE_PARAM_PREFIX + NameNodeServiceModelGenerator.DISCOVERY_NAMESERVICE;
Map<String, String> modelProps = generated.getQualifyingServiceParams();
assertEquals("Expected one service model properties", 1, modelProps.size());
assertEquals("Expected " + qualifyingProperty + " model property.", roleConfig.get(NameNodeServiceModelGenerator.NN_NAMESERVICE), modelProps.get(qualifyingProperty));
}
use of org.apache.knox.gateway.topology.discovery.cm.ServiceModel in project knox by apache.
the class HBaseUIServiceModelGenerator method generateService.
@Override
public ServiceModel generateService(ApiService service, ApiServiceConfig serviceConfig, ApiRole role, ApiConfigList roleConfig) {
String hostname = role.getHostRef().getHostname();
String scheme;
// TODO: Is there an SSL port, or is this property re-used?
String port = getRoleConfigValue(roleConfig, MASTER_INFO_PORT);
boolean sslEnabled = Boolean.parseBoolean(getServiceConfigValue(serviceConfig, SSL_ENABLED));
if (sslEnabled) {
scheme = "https";
} else {
scheme = "http";
}
ServiceModel model = createServiceModel(String.format(Locale.getDefault(), "%s://%s:%s", scheme, hostname, port));
model.addServiceProperty(SSL_ENABLED, getServiceConfigValue(serviceConfig, SSL_ENABLED));
model.addRoleProperty(getRoleType(), MASTER_INFO_PORT, getRoleConfigValue(roleConfig, MASTER_INFO_PORT));
return model;
}
use of org.apache.knox.gateway.topology.discovery.cm.ServiceModel in project knox by apache.
the class HiveServiceModelGenerator method generateService.
@Override
public ServiceModel generateService(ApiService service, ApiServiceConfig serviceConfig, ApiRole role, ApiConfigList roleConfig) throws ApiException {
String hostname = role.getHostRef().getHostname();
boolean sslEnabled = Boolean.parseBoolean(getServiceConfigValue(serviceConfig, SSL_ENABLED));
String scheme = sslEnabled ? "https" : "http";
String port = getHttpPort(roleConfig);
String httpPath = getHttpPath(roleConfig);
if (httpPath == null) {
httpPath = DEFAULT_HTTP_PATH;
}
ServiceModel model = createServiceModel(String.format(Locale.getDefault(), "%s://%s:%s/%s", scheme, hostname, port, httpPath));
model.addRoleProperty(getRoleType(), SSL_ENABLED, Boolean.toString(sslEnabled));
model.addRoleProperty(getRoleType(), SAFETY_VALVE, getRoleConfigValue(roleConfig, SAFETY_VALVE));
return model;
}
use of org.apache.knox.gateway.topology.discovery.cm.ServiceModel in project knox by apache.
the class HueLBServiceModelGenerator method generateService.
@Override
public ServiceModel generateService(ApiService service, ApiServiceConfig serviceConfig, ApiRole role, ApiConfigList roleConfig) {
String hostname = role.getHostRef().getHostname();
String scheme = "http";
String port = getRoleConfigValue(roleConfig, LISTEN_PORT);
ServiceModel model = createServiceModel(String.format(Locale.getDefault(), "%s://%s:%s", scheme, hostname, port));
model.addRoleProperty(getRoleType(), LISTEN_PORT, port);
return model;
}
use of org.apache.knox.gateway.topology.discovery.cm.ServiceModel in project knox by apache.
the class NifiRegistryServiceModelGenerator method generateService.
@Override
public ServiceModel generateService(ApiService service, ApiServiceConfig serviceConfig, ApiRole role, ApiConfigList roleConfig) throws ApiException {
String hostname = role.getHostRef().getHostname();
String scheme;
String port;
boolean sslEnabled = Boolean.parseBoolean(getRoleConfigValue(roleConfig, SSL_ENABLED));
if (sslEnabled) {
scheme = "https";
port = getRoleConfigValue(roleConfig, HTTPS_PORT);
} else {
scheme = "http";
port = getRoleConfigValue(roleConfig, HTTP_PORT);
}
ServiceModel model = new ServiceModel(getModelType(), getService(), getServiceType(), getRoleType(), String.format(Locale.getDefault(), "%s://%s:%s", scheme, hostname, port));
model.addRoleProperty(getRoleType(), SSL_ENABLED, getRoleConfigValue(roleConfig, SSL_ENABLED));
model.addRoleProperty(getRoleType(), HTTP_PORT, getRoleConfigValue(roleConfig, HTTP_PORT));
model.addRoleProperty(getRoleType(), HTTPS_PORT, getRoleConfigValue(roleConfig, HTTPS_PORT));
return model;
}
Aggregations