@Override public void init(final SystemContext context) { final ServiceContainer serviceContainer = context.getServiceContainer(); initClusterBaseLayer(context, serviceContainer); }
@Override public void init(final SystemContext context) { final ServiceContainer serviceContainer = context.getServiceContainer(); initClusterBaseLayer(context, serviceContainer); }
public <T> void removeService(final ServiceName<T> name) { try { broker.getBrokerContext().getServiceContainer().removeService(name).get(10, TimeUnit.SECONDS); } catch (final InterruptedException | ExecutionException | TimeoutException e) { throw new RuntimeException("Could not remove service " + name.getName() + " in 10 seconds."); } }
public <T> void removeService(final ServiceName<T> name) { try { broker.getBrokerContext().getServiceContainer().removeService(name).get(10, TimeUnit.SECONDS); } catch (final InterruptedException | ExecutionException | TimeoutException e) { throw new RuntimeException("Could not remove service " + name.getName() + " in 10 seconds."); } }
public <T> void installService( Function<ServiceContainer, ServiceBuilder<T>> serviceBuilderFactory) { final ServiceContainer serviceContainer = broker.getBrokerContext().getServiceContainer(); final ServiceBuilder<T> serviceBuilder = serviceBuilderFactory.apply(serviceContainer); try { serviceBuilder.install().get(10, TimeUnit.SECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { throw new RuntimeException("Could not install service: " + serviceBuilder.getName(), e); } }
@Test public void shouldNotStartExporterServiceIfNoExportersAreConfigured() { // given brokerConfig.setExporters(new ArrayList<>()); // when component.init(context); actorSchedulerRule.workUntilDone(); // then assertThat(context.getServiceContainer().hasService(EXPORTER_MANAGER)).isFalse(); }
@Before public void setup() { context = spy( new SystemContext( brokerConfig, temporaryFolder.getRoot().getAbsolutePath(), new DefaultActorClock())); doAnswer(i -> serviceContainerRule.get()).when(context).getServiceContainer(); }
public <T> void installService( Function<ServiceContainer, ServiceBuilder<T>> serviceBuilderFactory) { final ServiceContainer serviceContainer = broker.getBrokerContext().getServiceContainer(); final ServiceBuilder<T> serviceBuilder = serviceBuilderFactory.apply(serviceContainer); try { serviceBuilder.install().get(10, TimeUnit.SECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { throw new RuntimeException("Could not install service: " + serviceBuilder.getName(), e); } }
@Before public void setup() { context = spy( new SystemContext( brokerConfig, temporaryFolder.getRoot().getAbsolutePath(), new DefaultActorClock())); doAnswer(i -> serviceContainerRule.get()).when(context).getServiceContainer(); }
@Test public void shouldNotStartExporterServiceIfNoExportersAreConfigured() { // given brokerConfig.setExporters(new ArrayList<>()); // when component.init(context); actorSchedulerRule.workUntilDone(); // then assertThat(context.getServiceContainer().hasService(EXPORTER_MANAGER)).isFalse(); }
@Test public void shouldStartExporterServiceIfAtLeastOneExporterIsConfigured() { // given brokerConfig.setExporters(Arrays.asList(new ExporterCfg())); // when component.init(context); actorSchedulerRule.workUntilDone(); // then assertThat(context.getServiceContainer().hasService(EXPORTER_MANAGER)).isTrue(); } }
public <T> void removeService(final ServiceName<T> name) { try { broker.getBrokerContext().getServiceContainer().removeService(name).get(10, TimeUnit.SECONDS); } catch (final InterruptedException | ExecutionException | TimeoutException e) { throw new RuntimeException("Could not remove service " + name.getName() + " in 10 seconds."); } }
public <T> void removeService(final ServiceName<T> name) { try { broker.getBrokerContext().getServiceContainer().removeService(name).get(10, TimeUnit.SECONDS); } catch (final InterruptedException | ExecutionException | TimeoutException e) { throw new RuntimeException("Could not remove service " + name.getName() + " in 10 seconds."); } }
@Test public void shouldStartExporterServiceIfAtLeastOneExporterIsConfigured() { // given brokerConfig.setExporters(Arrays.asList(new ExporterCfg())); // when component.init(context); actorSchedulerRule.workUntilDone(); // then assertThat(context.getServiceContainer().hasService(EXPORTER_MANAGER)).isTrue(); } }
@Override public void init(SystemContext context) { final ServiceContainer serviceContainer = context.getServiceContainer(); final List<ExporterCfg> exporters = context.getBrokerConfiguration().getExporters(); if (!exporters.isEmpty()) { final ExporterManagerService exporterManagerService = new ExporterManagerService(exporters); serviceContainer .createService(EXPORTER_MANAGER, exporterManagerService) .dependency( STREAM_PROCESSOR_SERVICE_FACTORY, exporterManagerService.getStreamProcessorServiceFactoryInjector()) .groupReference( LEADER_PARTITION_GROUP_NAME, exporterManagerService.getPartitionsGroupReference()) .install(); } } }
public <S> S getService(final ServiceName<S> serviceName) { final ServiceContainer serviceContainer = broker.getBrokerContext().getServiceContainer(); final Injector<S> injector = new Injector<>(); final ServiceName<TestService> accessorServiceName = ServiceName.newServiceName("serviceAccess" + serviceName.getName(), TestService.class); try { serviceContainer .createService(accessorServiceName, new TestService()) .dependency(serviceName, injector) .install() .get(); } catch (final InterruptedException | ExecutionException e) { throw new RuntimeException(e); } serviceContainer.removeService(accessorServiceName); return injector.getValue(); }
@Override public void init(final SystemContext context) { final ServiceContainer serviceContainer = context.getServiceContainer(); final SubscriptionApiCommandMessageHandlerService messageHandlerService = new SubscriptionApiCommandMessageHandlerService(); serviceContainer .createService(SUBSCRIPTION_API_MESSAGE_HANDLER_SERVICE_NAME, messageHandlerService) .dependency( bufferingServerTransport(SUBSCRIPTION_API_SERVER_NAME), messageHandlerService.getServerTransportInjector()) .groupReference( LEADER_PARTITION_GROUP_NAME, messageHandlerService.getLeaderParitionsGroupReference()) .install(); } }
@Override public void init(final SystemContext context) { final ServiceContainer serviceContainer = context.getServiceContainer(); final SubscriptionApiCommandMessageHandlerService messageHandlerService = new SubscriptionApiCommandMessageHandlerService(); serviceContainer .createService(SUBSCRIPTION_API_MESSAGE_HANDLER_SERVICE_NAME, messageHandlerService) .dependency( bufferingServerTransport(SUBSCRIPTION_API_SERVER_NAME), messageHandlerService.getServerTransportInjector()) .groupReference( LEADER_PARTITION_GROUP_NAME, messageHandlerService.getLeaderParitionsGroupReference()) .install(); } }
public <S> S getService(final ServiceName<S> serviceName) { final ServiceContainer serviceContainer = broker.getBrokerContext().getServiceContainer(); final Injector<S> injector = new Injector<>(); final ServiceName<TestService> accessorServiceName = ServiceName.newServiceName("serviceAccess" + serviceName.getName(), TestService.class); try { serviceContainer .createService(accessorServiceName, new TestService()) .dependency(serviceName, injector) .install() .get(); } catch (final InterruptedException | ExecutionException e) { throw new RuntimeException(e); } serviceContainer.removeService(accessorServiceName); return injector.getValue(); }
public static void printRecords(final Broker broker, final int partitionId) { try { final ServiceContainer serviceContainer = broker.getBrokerContext().getServiceContainer(); final ServiceName<LogStream> logStreamServiceName = LogStreamServiceNames.logStreamServiceName(Partition.getPartitionName(partitionId)); final PrinterService printerService = new PrinterService(); serviceContainer .createService(PRINTER_SERVICE_NAME, printerService) .dependency(logStreamServiceName, printerService.getLogStreamInjector()) .install() .join(); serviceContainer.removeService(PRINTER_SERVICE_NAME).join(); } catch (final Exception e) { LOGGER.error( "Could not print log entries. This exception is not propagated to avoid interference with the test.", e); } }