Search in sources :

Example 6 with ServiceModel

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

the class KuduUIServiceModelGenerator method generateService.

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

Example 7 with ServiceModel

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

the class SolrServiceModelGenerator 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 = getServiceConfigValue(serviceConfig, USE_SSL);
    if (Boolean.parseBoolean(sslEnabled)) {
        scheme = "https";
        port = getRoleConfigValue(roleConfig, HTTPS_PORT);
    } else {
        scheme = "http";
        port = getRoleConfigValue(roleConfig, HTTP_PORT);
    }
    ServiceModel model = createServiceModel(String.format(Locale.getDefault(), "%s://%s:%s/solr/", scheme, hostname, port));
    model.addServiceProperty(USE_SSL, sslEnabled);
    model.addRoleProperty(getRoleType(), HTTP_PORT, getRoleConfigValue(roleConfig, HTTP_PORT));
    model.addRoleProperty(getRoleType(), HTTPS_PORT, getRoleConfigValue(roleConfig, HTTPS_PORT));
    // Add some service details for qualifying the discovery process for this service
    model.addQualifyingServiceParam(DISCOVERY_SERVICE_NAME, service.getName());
    model.addQualifyingServiceParam(DISCOVERY_SERVICE_DISPLAY_NAME, service.getDisplayName());
    return model;
}
Also used : ServiceModel(org.apache.knox.gateway.topology.discovery.cm.ServiceModel)

Example 8 with ServiceModel

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

the class JobHistoryUIServiceModelGenerator 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;
    if (isSSLEnabled(service, serviceConfig)) {
        scheme = "https";
        port = getRoleConfigValue(roleConfig, HTTPS_PORT);
    } else {
        scheme = "http";
        port = getRoleConfigValue(roleConfig, HTTP_PORT);
    }
    ServiceModel model = createServiceModel(String.format(Locale.getDefault(), "%s://%s:%s", scheme, hostname, port));
    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 9 with ServiceModel

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

the class SparkHistoryUIServiceModelGenerator 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 = getRoleConfigValue(roleConfig, SSL_SERVER_PORT);
    } else {
        scheme = "http";
        port = getRoleConfigValue(roleConfig, HISTORY_SERVER_PORT);
    }
    ServiceModel model = createServiceModel(String.format(Locale.getDefault(), "%s://%s:%s", scheme, hostname, port));
    model.addRoleProperty(getRoleType(), SSL_ENABLED, sslEnabled);
    model.addRoleProperty(getRoleType(), SSL_SERVER_PORT, getRoleConfigValue(roleConfig, SSL_SERVER_PORT));
    model.addRoleProperty(getRoleType(), HISTORY_SERVER_PORT, getRoleConfigValue(roleConfig, HISTORY_SERVER_PORT));
    return model;
}
Also used : ServiceModel(org.apache.knox.gateway.topology.discovery.cm.ServiceModel)

Example 10 with ServiceModel

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

the class ClouderaManagerClusterConfigurationMonitor method addServiceConfiguration.

/**
 * Add the specified cluster service configurations to the monitor.
 *
 * @param cluster         The cluster to be added.
 * @param discoveryConfig The discovery configuration associated with the cluster.
 */
public void addServiceConfiguration(final ClouderaManagerCluster cluster, final ServiceDiscoveryConfig discoveryConfig) {
    String address = discoveryConfig.getAddress();
    String clusterName = cluster.getName();
    // Because this is the result of a discovery, disregard restart events which
    // occurred before "now" in future polling
    internalMonitor.setEventQueryTimestamp(address, clusterName, Instant.now());
    // Persist the discovery configuration
    discoveryConfigStore.store(discoveryConfig);
    // Add the discovery configuration to the cache
    configCache.addDiscoveryConfig(discoveryConfig);
    Map<String, List<ServiceModel>> serviceModels = cluster.getServiceModels();
    // Process the service models
    Map<String, ServiceConfigurationModel> scpMap = new HashMap<>();
    for (String service : serviceModels.keySet()) {
        for (ServiceModel model : serviceModels.get(service)) {
            ServiceConfigurationModel scp = scpMap.computeIfAbsent(model.getServiceType(), p -> new ServiceConfigurationModel());
            Map<String, String> serviceProps = model.getServiceProperties();
            for (Map.Entry<String, String> entry : serviceProps.entrySet()) {
                scp.addServiceProperty(entry.getKey(), entry.getValue());
            }
            Map<String, Map<String, String>> roleProps = model.getRoleProperties();
            for (String roleName : roleProps.keySet()) {
                Map<String, String> rp = roleProps.get(roleName);
                for (Map.Entry<String, String> entry : rp.entrySet()) {
                    scp.addRoleProperty(roleName, entry.getKey(), entry.getValue());
                }
            }
        }
    }
    // Persist the service configurations
    serviceConfigStore.store(address, clusterName, scpMap);
    // Add the service configurations to the cache
    configCache.addServiceConfiguration(address, clusterName, scpMap);
}
Also used : HashMap(java.util.HashMap) ServiceModel(org.apache.knox.gateway.topology.discovery.cm.ServiceModel) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

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