Search in sources :

Example 26 with ServiceModel

use of org.apache.knox.gateway.topology.discovery.cm.ServiceModel in project knox by apache.

the class NifiServiceModelGenerator 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)

Example 27 with ServiceModel

use of org.apache.knox.gateway.topology.discovery.cm.ServiceModel in project knox by apache.

the class RangerServiceModelGenerator method generateService.

@Override
public ServiceModel generateService(ApiService service, ApiServiceConfig serviceConfig, ApiRole role, ApiConfigList roleConfig) {
    String hostname = role.getHostRef().getHostname();
    String scheme;
    String port;
    String sslEnabled = getRoleConfigValue(roleConfig, SSL_ENABLED);
    if (Boolean.parseBoolean(sslEnabled)) {
        scheme = "https";
        port = getServiceConfigValue(serviceConfig, HTTPS_PORT);
    } else {
        scheme = "http";
        port = getServiceConfigValue(serviceConfig, HTTP_PORT);
    }
    ServiceModel model = createServiceModel(String.format(Locale.getDefault(), "%s://%s:%s", scheme, hostname, port));
    model.addServiceProperty(HTTP_PORT, getServiceConfigValue(serviceConfig, HTTP_PORT));
    model.addServiceProperty(HTTPS_PORT, getServiceConfigValue(serviceConfig, HTTPS_PORT));
    model.addRoleProperty(getRoleType(), SSL_ENABLED, sslEnabled);
    return model;
}
Also used : ServiceModel(org.apache.knox.gateway.topology.discovery.cm.ServiceModel)

Example 28 with ServiceModel

use of org.apache.knox.gateway.topology.discovery.cm.ServiceModel in project knox by apache.

the class ResourceManagerApiServiceModelGenerator method generateService.

@Override
public ServiceModel generateService(ApiService service, ApiServiceConfig serviceConfig, ApiRole role, ApiConfigList roleConfig) throws ApiException {
    String hostname = role.getHostRef().getHostname();
    String port = getRoleConfigValue(roleConfig, RM_PORT);
    ServiceModel model = createServiceModel(String.format(Locale.getDefault(), "rpc://%s:%s", hostname, port));
    model.addRoleProperty(getRoleType(), RM_PORT, port);
    return model;
}
Also used : ServiceModel(org.apache.knox.gateway.topology.discovery.cm.ServiceModel)

Example 29 with ServiceModel

use of org.apache.knox.gateway.topology.discovery.cm.ServiceModel in project knox by apache.

the class JobTrackerServiceModelGenerator method generateService.

@Override
public ServiceModel generateService(ApiService service, ApiServiceConfig serviceConfig, ApiRole role, ApiConfigList roleConfig) throws ApiException {
    String hostname = role.getHostRef().getHostname();
    String port = getRoleConfigValue(roleConfig, RM_PORT);
    ServiceModel model = createServiceModel(String.format(Locale.getDefault(), "rpc://%s:%s", hostname, port));
    model.addRoleProperty(getRoleType(), RM_PORT, port);
    return model;
}
Also used : ServiceModel(org.apache.knox.gateway.topology.discovery.cm.ServiceModel)

Example 30 with ServiceModel

use of org.apache.knox.gateway.topology.discovery.cm.ServiceModel in project knox by apache.

the class YarnUIServiceModelGenerator method generateService.

@Override
public ServiceModel generateService(ApiService service, ApiServiceConfig serviceConfig, ApiRole role, ApiConfigList roleConfig) throws ApiException {
    ServiceModel model = createServiceModel(generateURL(service, serviceConfig, role, roleConfig));
    model.addRoleProperty(getRoleType(), RM_HTTP_PORT, getRoleConfigValue(roleConfig, RM_HTTP_PORT));
    model.addRoleProperty(getRoleType(), RM_HTTPS_PORT, getRoleConfigValue(roleConfig, RM_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