@Override public Collection<Service> getServices() { return super.getServices(); }
@Override public Collection<Service> getServices() { return super.getServices(); }
static void validateNoAppsWithRootUrlsInServicesTopology( Topology topology ) { if( topology != null ) { if( topology.getServices() != null && !topology.getServices().isEmpty() ) { List<Application> dups = findApplicationsByUrl( topology, "/" ); if( dups != null && !dups.isEmpty() ) { throw new DeploymentException( "Topology " + topology.getName() + " contains both services and an application " + dups.get( 0 ).getName() + " with a root url." ); } } } }
static void validateNoAppsWithRootUrlsInServicesTopology( Topology topology ) { if( topology != null ) { if( topology.getServices() != null && !topology.getServices().isEmpty() ) { List<Application> dups = findApplicationsByUrl( topology, "/" ); if( dups != null && !dups.isEmpty() ) { throw new DeploymentException( "Topology " + topology.getName() + " contains both services and an application " + dups.get( 0 ).getName() + " with a root url." ); } } } }
private static Map<String,List<ServiceDeploymentContributor>> selectContextServices( Topology topology ) { Map<String,List<ServiceDeploymentContributor>> defaults = new HashMap<>(); for( Service service : topology.getServices() ) { String role = service.getRole(); ServiceDeploymentContributor contributor = getServiceContributor( role, service.getName(), service.getVersion() ); if( contributor != null ) { List<ServiceDeploymentContributor> list = defaults.get( role ); if( list == null ) { list = new ArrayList<>( 1 ); defaults.put( role, list ); } if( !list.contains( contributor ) ) { list.add( contributor ); } } } return defaults; }
private static Map<String,List<ServiceDeploymentContributor>> selectContextServices( Topology topology ) { Map<String,List<ServiceDeploymentContributor>> defaults = new HashMap<>(); for( Service service : topology.getServices() ) { String role = service.getRole(); ServiceDeploymentContributor contributor = getServiceContributor( role, service.getName(), service.getVersion() ); if( contributor != null ) { List<ServiceDeploymentContributor> list = defaults.get( role ); if( list == null ) { list = new ArrayList<>( 1 ); defaults.put( role, list ); } if( !list.contains( contributor ) ) { list.add( contributor ); } } } return defaults; }
private static Map<String,ServiceDeploymentContributor> selectContextApplications( GatewayConfig config, Topology topology ) { Map<String,ServiceDeploymentContributor> contributors = new HashMap<>(); if( topology != null ) { for( Application application : topology.getApplications() ) { String name = application.getName(); if( name == null || name.isEmpty() ) { throw new DeploymentException( "Topologies cannot contain an application without a name." ); } ApplicationDeploymentContributor contributor = new ApplicationDeploymentContributor( config, application ); List<String> urls = application.getUrls(); if( urls == null || urls.isEmpty() ) { urls = new ArrayList<>( 1 ); urls.add( "/" + name ); } for( String url : urls ) { if( url == null || url.isEmpty() || url.equals( "/" ) ) { if( !topology.getServices().isEmpty() ) { throw new DeploymentException( String.format(Locale.ROOT, "Topologies with services cannot contain an application (%s) with a root url.", name ) ); } } contributors.put( url, contributor ); } } } return contributors; }
private static Map<String,ServiceDeploymentContributor> selectContextApplications( GatewayConfig config, Topology topology ) { Map<String,ServiceDeploymentContributor> contributors = new HashMap<>(); if( topology != null ) { for( Application application : topology.getApplications() ) { String name = application.getName(); if( name == null || name.isEmpty() ) { throw new DeploymentException( "Topologies cannot contain an application without a name." ); } ApplicationDeploymentContributor contributor = new ApplicationDeploymentContributor( config, application ); List<String> urls = application.getUrls(); if( urls == null || urls.isEmpty() ) { urls = new ArrayList<>( 1 ); urls.add( "/" + name ); } for( String url : urls ) { if( url == null || url.isEmpty() || "/".equals(url) ) { if( !topology.getServices().isEmpty() ) { throw new DeploymentException( String.format(Locale.ROOT, "Topologies with services cannot contain an application (%s) with a root url.", name ) ); } } contributors.put( url, contributor ); } } } return contributors; }
for (Service s : topology.getServices()) { List<String> urls = getServiceTestURLs(config, s.getRole(), topology);
for (Service s : topology.getServices()) { if (s.getRole().equals(role)) { serviceLevelParams = s.getParams();
for (Service s : topology.getServices()) { if (s.getRole().equals(role)) { serviceLevelParams = s.getParams();
public static Topology getTopology( org.apache.knox.gateway.topology.Topology topology) { Topology topologyResource = new Topology(); topologyResource.setName(topology.getName()); topologyResource.setTimestamp(topology.getTimestamp()); topologyResource.setPath(topology.getDefaultServicePath()); topologyResource.setUri(topology.getUri()); topologyResource.setGenerated(topology.isGenerated()); for ( org.apache.knox.gateway.topology.Provider provider : topology.getProviders() ) { topologyResource.getProviders().add( getProvider(provider) ); } for ( org.apache.knox.gateway.topology.Service service : topology.getServices() ) { topologyResource.getServices().add( getService(service) ); } for ( org.apache.knox.gateway.topology.Application application : topology.getApplications() ) { topologyResource.getApplications().add( getApplication(application) ); } return topologyResource; }
private static void contributeServices( DeploymentContext context, Topology topology, Map<String, List<ServiceDeploymentContributor>> services ) { if( services != null ) { for( Service service : topology.getServices() ) { ServiceDeploymentContributor contributor = getServiceContributor( service.getRole(), service.getName(), service.getVersion() ); if( contributor != null ) { try { log.contributeService( service.getName(), service.getRole() ); contributor.contributeService( context, service ); if( gatewayServices != null ) { ServiceRegistry sr = gatewayServices.getService( GatewayServices.SERVICE_REGISTRY_SERVICE ); if( sr != null ) { String regCode = sr.getRegistrationCode( topology.getName() ); sr.registerService( regCode, topology.getName(), service.getRole(), service.getUrls() ); } } } catch( Exception e ) { // Maybe it makes sense to throw exception log.failedToContributeService( service.getName(), service.getRole(), e ); throw new DeploymentException( "Failed to contribute service.", e ); } } } } }
private static void contributeServices( DeploymentContext context, Topology topology, Map<String, List<ServiceDeploymentContributor>> services ) { if( services != null ) { for( Service service : topology.getServices() ) { ServiceDeploymentContributor contributor = getServiceContributor( service.getRole(), service.getName(), service.getVersion() ); if( contributor != null ) { try { log.contributeService( service.getName(), service.getRole() ); contributor.contributeService( context, service ); if( gatewayServices != null ) { ServiceRegistry sr = gatewayServices.getService( GatewayServices.SERVICE_REGISTRY_SERVICE ); if( sr != null ) { String regCode = sr.getRegistrationCode( topology.getName() ); sr.registerService( regCode, topology.getName(), service.getRole(), service.getUrls() ); } } } catch( Exception e ) { // Maybe it makes sense to throw exception log.failedToContributeService( service.getName(), service.getRole(), e ); throw new DeploymentException( "Failed to contribute service.", e ); } } } } }