private ExporterIntegrationRule configure(List<ExporterCfg> exporters) { getBrokerConfig().getExporters().addAll(exporters); return this; }
private ExporterIntegrationRule configure(List<ExporterCfg> exporters) { getBrokerConfig().getExporters().addAll(exporters); return this; }
/** @return the currently configured exporters */ public List<ExporterCfg> getConfiguredExporters() { return getBrokerConfig().getExporters().stream() .filter(cfg -> !cfg.getId().equals(TEST_RECORD_EXPORTER_ID)) .collect(Collectors.toList()); }
/** @return the currently configured exporters */ public List<ExporterCfg> getConfiguredExporters() { return getBrokerConfig().getExporters().stream() .filter(cfg -> !cfg.getId().equals(TEST_RECORD_EXPORTER_ID)) .collect(Collectors.toList()); }
private void configure(String id, BrokerCfg brokerCfg) { final Optional<ExporterCfg> config = brokerCfg.getExporters().stream().filter(c -> c.getId().equals(id)).findFirst(); if (config.isPresent()) { final MockConfiguration<Object> configuration = new MockConfiguration<>(); configuration.setId(id); configuration.setArguments(config.get().getArgs()); exporter.configure(newContext(configuration)); } else { throw new IllegalArgumentException(String.format("No exporter with ID %s found", id)); } }
private void configure(String id, BrokerCfg brokerCfg) { final Optional<ExporterCfg> config = brokerCfg.getExporters().stream().filter(c -> c.getId().equals(id)).findFirst(); if (config.isPresent()) { final MockConfiguration<Object> configuration = new MockConfiguration<>(); configuration.setId(id); configuration.setArguments(config.get().getArgs()); exporter.configure(newContext(configuration)); } else { throw new IllegalArgumentException(String.format("No exporter with ID %s found", id)); } }
public void configureBroker(final BrokerCfg brokerCfg) { // build-in exporters final ExporterCfg exporterCfg = new ExporterCfg(); exporterCfg.setId(TEST_RECORD_EXPORTER_ID); exporterCfg.setClassName(RecordingExporter.class.getName()); brokerCfg.getExporters().add(exporterCfg); // custom configurators for (Consumer<BrokerCfg> configurator : configurators) { configurator.accept(brokerCfg); } // set random port numbers assignSocketAddresses(brokerCfg); }
public void configureBroker(final BrokerCfg brokerCfg) { // build-in exporters final ExporterCfg exporterCfg = new ExporterCfg(); exporterCfg.setId(TEST_RECORD_EXPORTER_ID); exporterCfg.setClassName(RecordingExporter.class.getName()); brokerCfg.getExporters().add(exporterCfg); // custom configurators for (Consumer<BrokerCfg> configurator : configurators) { configurator.accept(brokerCfg); } // set random port numbers assignSocketAddresses(brokerCfg); }
/** * Configures the broker to add whatever exporters are defined in the TOML represented by the * input stream. * * @param toml input stream wrapping a TOML document */ public ExporterIntegrationRule configure(InputStream toml) { final BrokerCfg config = new Toml().read(toml).to(BrokerCfg.class); return configure(config.getExporters()); }
/** * Configures the broker to add whatever exporters are defined in the TOML represented by the * input stream. * * @param toml input stream wrapping a TOML document */ public ExporterIntegrationRule configure(InputStream toml) { final BrokerCfg config = new Toml().read(toml).to(BrokerCfg.class); return configure(config.getExporters()); }
@Test public void shouldExpandExporterJarPathRelativeToBrokerBaseIffPresent() { // given final InputStream input = new ByteArrayInputStream( ("[[exporters]]\n" + "id=\"external\"\n" + "jarPath=\"exporters/exporter.jar\"\n" + "[[exporters]]\n" + "id=\"internal-1\"\n" + "jarPath=\"\"\n" + "[[exporters]]\n" + "id=\"internal-2\"") .getBytes()); final BrokerCfg config = TomlConfigurationReader.read(input, BrokerCfg.class); final String base = temporaryFolder.getRoot().getAbsolutePath(); final String jarFile = Paths.get(base, "exporters", "exporter.jar").toAbsolutePath().toString(); // when config.init(base); // then assertThat(config.getExporters()).hasSize(3); assertThat(config.getExporters().get(0)) .hasFieldOrPropertyWithValue("jarPath", jarFile) .is(new Condition<>(ExporterCfg::isExternal, "is external")); assertThat(config.getExporters().get(1).isExternal()).isFalse(); assertThat(config.getExporters().get(2).isExternal()).isFalse(); }
@Test public void shouldExpandExporterJarPathRelativeToBrokerBaseIffPresent() { // given final InputStream input = new ByteArrayInputStream( ("[[exporters]]\n" + "id=\"external\"\n" + "jarPath=\"exporters/exporter.jar\"\n" + "[[exporters]]\n" + "id=\"internal-1\"\n" + "jarPath=\"\"\n" + "[[exporters]]\n" + "id=\"internal-2\"") .getBytes()); final BrokerCfg config = TomlConfigurationReader.read(input, BrokerCfg.class); final String base = temporaryFolder.getRoot().getAbsolutePath(); final String jarFile = Paths.get(base, "exporters", "exporter.jar").toAbsolutePath().toString(); // when config.init(base); // then assertThat(config.getExporters()).hasSize(3); assertThat(config.getExporters().get(0)) .hasFieldOrPropertyWithValue("jarPath", jarFile) .is(new Condition<>(ExporterCfg::isExternal, "is external")); assertThat(config.getExporters().get(1).isExternal()).isFalse(); assertThat(config.getExporters().get(2).isExternal()).isFalse(); }
@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(); } } }
@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(); } } }