Search in sources :

Example 11 with ServiceModel

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));
}
Also used : HashMap(java.util.HashMap) ServiceModel(org.apache.knox.gateway.topology.discovery.cm.ServiceModel) AbstractServiceModelGeneratorTest(org.apache.knox.gateway.topology.discovery.cm.model.AbstractServiceModelGeneratorTest) Test(org.junit.Test)

Example 12 with ServiceModel

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;
}
Also used : ServiceModel(org.apache.knox.gateway.topology.discovery.cm.ServiceModel)

Example 13 with ServiceModel

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;
}
Also used : ServiceModel(org.apache.knox.gateway.topology.discovery.cm.ServiceModel)

Example 14 with ServiceModel

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;
}
Also used : ServiceModel(org.apache.knox.gateway.topology.discovery.cm.ServiceModel)

Example 15 with ServiceModel

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;
}
Also used : ServiceModel(org.apache.knox.gateway.topology.discovery.cm.ServiceModel)

Aggregations

ServiceModel (org.apache.knox.gateway.topology.discovery.cm.ServiceModel)35 HashMap (java.util.HashMap)4 AbstractServiceModelGeneratorTest (org.apache.knox.gateway.topology.discovery.cm.model.AbstractServiceModelGeneratorTest)3 Test (org.junit.Test)3 ApiException (com.cloudera.api.swagger.client.ApiException)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1