public CompositeServiceBuilder( ServiceName<Void> name, ServiceContainer container, ServiceName<?>... additionalDependencies) { this.compositeServiceName = name; this.container = (ServiceContainerImpl) container; final ServiceBuilder<Void> installServiceBuilder = container.createService(compositeServiceName, new CompositeService()); for (ServiceName<?> serviceName : additionalDependencies) { installServiceBuilder.dependency(serviceName); } installFutures.put(compositeServiceName, (ActorFuture) installServiceBuilder.install()); }
public ActorFuture<Void> closeAsync() { return serviceContainer.removeService(serviceName); }
public ActorFuture<LogStream> build() { Objects.requireNonNull(serviceContainer, "serviceContainer"); validate(); final CompositeServiceBuilder installOperation = serviceContainer.createComposite(logStreamRootServiceName(logName)); final ServiceName<LogStream> logStreamServiceName = addServices(installOperation); return installOperation.installAndReturn(logStreamServiceName); }
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(); }
@Test public void shouldNotStartExporterServiceIfNoExportersAreConfigured() { // given brokerConfig.setExporters(new ArrayList<>()); // when component.init(context); actorSchedulerRule.workUntilDone(); // then assertThat(context.getServiceContainer().hasService(EXPORTER_MANAGER)).isFalse(); }
public void init() { serviceContainer.start(); for (final Component brokerComponent : components) { try { brokerComponent.init(this); } catch (final RuntimeException e) { close(); throw e; } } try { for (final ActorFuture<?> requiredStartAction : requiredStartActions) { requiredStartAction.get(20, TimeUnit.SECONDS); } } catch (final Exception e) { LOG.error("Could not start broker", e); close(); throw new RuntimeException(e); } }
serviceContainer.close(getCloseTimeout().toMillis(), TimeUnit.MILLISECONDS); } catch (final TimeoutException e) { LOG.error("Failed to close broker within {} seconds.", CLOSE_TIMEOUT, e);
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(); }
@Test public void shouldNotStartExporterServiceIfNoExportersAreConfigured() { // given brokerConfig.setExporters(new ArrayList<>()); // when component.init(context); actorSchedulerRule.workUntilDone(); // then assertThat(context.getServiceContainer().hasService(EXPORTER_MANAGER)).isFalse(); }
public void init() { serviceContainer.start(); for (final Component brokerComponent : components) { try { brokerComponent.init(this); } catch (final RuntimeException e) { close(); throw e; } } try { for (final ActorFuture<?> requiredStartAction : requiredStartActions) { requiredStartAction.get(20, TimeUnit.SECONDS); } } catch (final Exception e) { LOG.error("Could not start broker", e); close(); throw new RuntimeException(e); } }
serviceContainer.close(getCloseTimeout().toMillis(), TimeUnit.MILLISECONDS); } catch (final TimeoutException e) { LOG.error("Failed to close broker within {} seconds.", CLOSE_TIMEOUT, e);
public CompositeServiceBuilder( ServiceName<Void> name, ServiceContainer container, ServiceName<?>... additionalDependencies) { this.compositeServiceName = name; this.container = (ServiceContainerImpl) container; final ServiceBuilder<Void> installServiceBuilder = container.createService(compositeServiceName, new CompositeService()); for (ServiceName<?> serviceName : additionalDependencies) { installServiceBuilder.dependency(serviceName); } installFutures.put(compositeServiceName, (ActorFuture) installServiceBuilder.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 ActorFuture<Void> closeAsync() { return serviceContainer.removeService(serviceName); }
public ActorFuture<LogStream> build() { Objects.requireNonNull(serviceContainer, "serviceContainer"); validate(); final CompositeServiceBuilder installOperation = serviceContainer.createComposite(logStreamRootServiceName(logName)); final ServiceName<LogStream> logStreamServiceName = addServices(installOperation); return installOperation.installAndReturn(logStreamServiceName); }
@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(); } }
protected ActorFuture<ClientTransport> createClientTransport( final ServiceContainer serviceContainer, final String name, final ByteValue sendBufferSize, final Collection<IntTuple<SocketAddress>> defaultEndpoints) { final ClientTransportService service = new ClientTransportService(name, defaultEndpoints, sendBufferSize); return serviceContainer .createService(TransportServiceNames.clientTransport(name), service) .install(); } }
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); } }
@Override public ActorFuture<Void> closeAsync() { return serviceContainer.removeService(logStreamRootServiceName(logName)); }
final NetworkCfg networkCfg = brokerConfig.getNetwork(); final CompositeServiceBuilder baseLayerInstall = serviceContainer.createComposite(CLUSTERING_BASE_LAYER);