private synchronized void updateSchema(Watcher<Schema> watcher) throws Exception { Schema schema = assembleSchema(currentAddressSpacePlans, currentAddressPlans, currentStandardInfraConfigs, currentBrokeredInfraConfigs); if (schema != null) { watcher.onUpdate(Collections.singletonList(schema)); } }
createEndpointSpec("messaging", "messaging", "amqps", TlsTermination.passthrough), createEndpointSpec("messaging-wss", "messaging", "https", TlsTermination.reencrypt), createEndpointSpec("mqtt", "mqtt", "secure-mqtt", TlsTermination.passthrough), createEndpointSpec("console", "console", "https", TlsTermination.reencrypt))); createAddressType( "anycast", "A direct messaging address type. Messages sent to an anycast address are not " + "stored but forwarded directly to a consumer.", filteredAddressPlans), createAddressType( "multicast", "A direct messaging address type. Messages sent to a multicast address are not " + "stored but forwarded directly to multiple consumers.", filteredAddressPlans), createAddressType( "queue", "A store-and-forward queue. A queue may be sharded across multiple storage units, " + "in which case message ordering is no longer guaranteed.", filteredAddressPlans), createAddressType( "topic", "A topic address for store-and-forward publish-subscribe messaging. Each message published " + "to a topic address is forwarded to all subscribes on that address.", filteredAddressPlans), createAddressType( "subscription", "A subscription on a topic",
try { AddressPlan addressPlan = addressPlanByName.get(addressPlanName); validateAddressPlan(addressSpacePlan.getAddressSpaceType(), addressPlan); plansForAddressSpacePlan.add(addressPlan); } catch (SchemaValidationException e) { validateAddressSpacePlan(addressSpacePlan, plansForAddressSpacePlan, brokeredInfraConfigs.stream().map(t -> t.getMetadata().getName()).collect(Collectors.toList())); } else { validateAddressSpacePlan(addressSpacePlan, plansForAddressSpacePlan, standardInfraConfigs.stream().map(t -> t.getMetadata().getName()).collect(Collectors.toList())); types.add(createBrokeredType(validAddressSpacePlans, validAddressPlans, new ArrayList<>(brokeredInfraConfigs))); types.add(createStandardType(validAddressSpacePlans, validAddressPlans, new ArrayList<>(standardInfraConfigs))); return new SchemaBuilder() .withAddressSpaceTypes(types)
@Override public void start(Future<Void> startPromise) throws Exception { SchemaApi schemaApi = KubeSchemaApi.create(client, client.getNamespace(), true); CachingSchemaProvider schemaProvider = new CachingSchemaProvider(); schemaApi.watchSchema(schemaProvider, options.getResyncInterval()); ensureRouteExists(client, options); ensureCredentialsExist(client, options); AddressSpaceApi addressSpaceApi = new ConfigMapAddressSpaceApi(client); AuthApi authApi = new KubeAuthApi(client, client.getConfiguration().getOauthToken()); UserApi userApi = createUserApi(options); ConsoleProxy consoleProxy = addressSpace -> { Route route = client.routes().withName(options.getConsoleProxyRouteName()).get(); if (route == null) { return null; } return String.format("https://%s/console/%s", route.getSpec().getHost(), addressSpace.getMetadata().getName()); }; vertx.deployVerticle(new HTTPServer(addressSpaceApi, schemaProvider, authApi, options.getCertDir(), options.getEnableRbac(), userApi, options.getListenPort(), consoleProxy), result -> { if (result.succeeded()) { log.info("EnMasse Service Broker started"); startPromise.complete(); } else { startPromise.fail(result.cause()); } }); }
public void start() throws Exception { boolean isOpenShift = isOpenShift(controllerClient); KubeSchemaApi schemaApi = KubeSchemaApi.create(controllerClient, controllerClient.getNamespace(), isOpenShift); schemaApi.watchSchema(schemaProvider, options.getResyncInterval()); Kubernetes kubernetes = new KubernetesHelper(controllerClient.getNamespace(), controllerClient, controllerClient.getConfiguration().getOauthToken(), options.getTemplateDir(), isOpenShift);
public static KubeSchemaApi create(NamespacedOpenShiftClient openShiftClient, String namespace, boolean isOpenShift) { AddressSpacePlanApi addressSpacePlanApi = new KubeAddressSpacePlanApi(openShiftClient, namespace, AdminCrd.addressSpacePlans()); AddressPlanApi addressPlanApi = new KubeAddressPlanApi(openShiftClient, namespace, AdminCrd.addressPlans()); BrokeredInfraConfigApi brokeredInfraConfigApi = new KubeBrokeredInfraConfigApi(openShiftClient, namespace, AdminCrd.brokeredInfraConfigs()); StandardInfraConfigApi standardInfraConfigApi = new KubeStandardInfraConfigApi(openShiftClient, namespace, AdminCrd.standardInfraConfigs()); Clock clock = Clock.systemUTC(); return new KubeSchemaApi(addressSpacePlanApi, addressPlanApi, brokeredInfraConfigApi, standardInfraConfigApi, clock, isOpenShift); }
@Override public void start(Future<Void> startPromise) throws Exception { boolean isOpenShift = isOpenShift(client); SchemaApi schemaApi = KubeSchemaApi.create(client, client.getNamespace(), isOpenShift); CachingSchemaProvider schemaProvider = new CachingSchemaProvider(); schemaApi.watchSchema(schemaProvider, options.getResyncInterval());
public void start() throws Exception { SchemaApi schemaApi = KubeSchemaApi.create(openShiftClient, openShiftClient.getNamespace(), isOpenShift(openShiftClient)); CachingSchemaProvider schemaProvider = new CachingSchemaProvider(); schemaApi.watchSchema(schemaProvider, options.getResyncInterval()); Kubernetes kubernetes = new KubernetesHelper(openShiftClient, options.getTemplateDir(), options.getInfraUuid()); BrokerSetGenerator clusterGenerator = new TemplateBrokerSetGenerator(kubernetes, options); EventLogger eventLogger = options.isEnableEventLogger() ? new KubeEventLogger(openShiftClient, openShiftClient.getNamespace(), Clock.systemUTC(), "standard-controller") : new LogEventLogger(); Metrics metrics = new Metrics(); Vertx vertx = Vertx.vertx(); BrokerClientFactory brokerClientFactory = new MutualTlsBrokerClientFactory(vertx, options.getCertDir()); addressController = new AddressController( options, new ConfigMapAddressApi(openShiftClient, options.getInfraUuid()), kubernetes, clusterGenerator, eventLogger, schemaProvider, vertx, metrics, new RandomBrokerIdGenerator(), brokerClientFactory); log.info("Starting standard controller for " + options.getAddressSpace()); addressController.start(); httpServer = new HTTPServer( 8889, metrics); httpServer.start(); }
private AddressSpaceType createBrokeredType(List<AddressSpacePlan> addressSpacePlans, Collection<AddressPlan> addressPlans, List<InfraConfig> brokeredInfraConfigs) { AddressSpaceTypeBuilder builder = new AddressSpaceTypeBuilder(); builder.withName("brokered"); builder.withDescription("A brokered address space consists of a broker combined with a console for managing addresses."); builder.withAvailableEndpoints(Arrays.asList( createEndpointSpec("messaging", "messaging", "amqps", TlsTermination.passthrough), createEndpointSpec("messaging-wss", "messaging", "amqps", TlsTermination.reencrypt), createEndpointSpec("console", "console", "https", TlsTermination.reencrypt))); List<AddressSpacePlan> filteredAddressSpaceplans = addressSpacePlans.stream() .filter(plan -> "brokered".equals(plan.getAddressSpaceType())) .collect(Collectors.toList()); builder.withPlans(filteredAddressSpaceplans); List<AddressPlan> filteredAddressPlans = addressPlans.stream() .filter(plan -> filteredAddressSpaceplans.stream() .filter(aPlan -> aPlan.getAddressPlans().contains(plan.getMetadata().getName())) .count() > 0) .collect(Collectors.toList()); builder.withInfraConfigs(brokeredInfraConfigs); builder.withAddressTypes(Arrays.asList( createAddressType( "queue", "A queue that supports selectors, message grouping and transactions", filteredAddressPlans), createAddressType( "topic", "A topic supports pub-sub semantics. Messages sent to a topic address is forwarded to all subscribes on that address.", filteredAddressPlans))); return builder.build(); }