use of org.apache.knox.gateway.topology.discovery.cm.ServiceModel in project knox by apache.
the class ZeppelinServiceModelGenerator 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 (isSSL(roleConfig)) {
scheme = "https";
port = getSSLPort(roleConfig);
} else {
scheme = "http";
port = getPort(roleConfig);
}
ServiceModel model = createServiceModel(String.format(Locale.getDefault(), "%s://%s:%s", scheme, hostname, port));
model.addRoleProperty(getRoleType(), SSL_ENABLED, getRoleConfigValue(roleConfig, SSL_ENABLED));
model.addRoleProperty(getRoleType(), SERVER_PORT, getPort(roleConfig));
model.addRoleProperty(getRoleType(), SERVER_SSL_PORT, getSSLPort(roleConfig));
return model;
}
use of org.apache.knox.gateway.topology.discovery.cm.ServiceModel in project knox by apache.
the class ZeppelinWSServiceModelGenerator method generateService.
@Override
public ServiceModel generateService(ApiService service, ApiServiceConfig serviceConfig, ApiRole role, ApiConfigList roleConfig) {
String hostname = role.getHostRef().getHostname();
String scheme;
String port;
if (isSSL(roleConfig)) {
scheme = "wss";
port = getSSLPort(roleConfig);
} else {
scheme = "ws";
port = getPort(roleConfig);
}
ServiceModel model = createServiceModel(String.format(Locale.getDefault(), "%s://%s:%s/ws", scheme, hostname, port));
model.addRoleProperty(getRoleType(), SSL_ENABLED, getRoleConfigValue(roleConfig, SSL_ENABLED));
model.addRoleProperty(getRoleType(), SERVER_PORT, getPort(roleConfig));
model.addRoleProperty(getRoleType(), SERVER_SSL_PORT, getSSLPort(roleConfig));
return model;
}
use of org.apache.knox.gateway.topology.discovery.cm.ServiceModel in project knox by apache.
the class AbstractURLCollectorTest method createMockServiceModel.
protected static ServiceModel createMockServiceModel(final String service, final String serviceType, final String roleType, final String url) {
ServiceModel sm = EasyMock.createNiceMock(ServiceModel.class);
EasyMock.expect(sm.getService()).andReturn(service).anyTimes();
EasyMock.expect(sm.getServiceType()).andReturn(serviceType).anyTimes();
EasyMock.expect(sm.getRoleType()).andReturn(roleType).anyTimes();
EasyMock.expect(sm.getServiceUrl()).andReturn(url).anyTimes();
EasyMock.replay(sm);
return sm;
}
use of org.apache.knox.gateway.topology.discovery.cm.ServiceModel in project knox by apache.
the class WebHdfsServiceModelGeneratorTest method testServiceModelMetadataWithNameService.
@Test
public void testServiceModelMetadataWithNameService() {
final Map<String, String> serviceConfig = new HashMap<>();
serviceConfig.put(WebHdfsServiceModelGenerator.WEBHDFS_ENABLED, "true");
serviceConfig.put(WebHdfsServiceModelGenerator.SSL_ENABLED, "false");
final Map<String, String> roleConfig = new HashMap<>();
roleConfig.put(WebHdfsServiceModelGenerator.AUTOFAILOVER_ENABLED, "true");
roleConfig.put(WebHdfsServiceModelGenerator.NN_NAMESERVICE, "myService");
roleConfig.put(WebHdfsServiceModelGenerator.NN_PORT, "12345");
ServiceModel generated = createServiceModel(serviceConfig, roleConfig);
validateServiceModel(generated, serviceConfig, roleConfig, false);
// Validate model metadata properties
final String qualifyingProperty = ServiceModel.QUALIFYING_SERVICE_PARAM_PREFIX + WebHdfsServiceModelGenerator.DISCOVERY_NAMESERVICE;
Map<String, String> modelProps = generated.getQualifyingServiceParams();
assertEquals("Expected one service model properties", 1, modelProps.size());
assertEquals("Expected " + qualifyingProperty + " model property.", roleConfig.get(WebHdfsServiceModelGenerator.NN_NAMESERVICE), modelProps.get(qualifyingProperty));
}
use of org.apache.knox.gateway.topology.discovery.cm.ServiceModel in project knox by apache.
the class SolrServiceModelGeneratorTest method testServiceModelMetadata.
@Test
public void testServiceModelMetadata() {
final Map<String, String> serviceConfig = new HashMap<>();
serviceConfig.put(SolrServiceModelGenerator.USE_SSL, "false");
final Map<String, String> roleConfig = new HashMap<>();
roleConfig.put(SolrServiceModelGenerator.HTTP_PORT, "2468");
roleConfig.put(SolrServiceModelGenerator.HTTPS_PORT, "1357");
ServiceModel generated = createServiceModel(serviceConfig, roleConfig);
validateServiceModel(generated, serviceConfig, roleConfig);
// Validate model metadata properties
final String serviceNameQualifier = QUALIFYING_SERVICE_PARAM_PREFIX + DISCOVERY_SERVICE_NAME;
final String displayNameQualifier = QUALIFYING_SERVICE_PARAM_PREFIX + DISCOVERY_SERVICE_DISPLAY_NAME;
Map<String, String> modelProps = generated.getQualifyingServiceParams();
assertEquals("Expected two service model properties", 2, modelProps.size());
assertEquals("Expected " + serviceNameQualifier + " model property.", getServiceType() + "-1", modelProps.get(serviceNameQualifier));
assertEquals("Expected " + displayNameQualifier + " model property.", "null", modelProps.get(displayNameQualifier));
}
Aggregations