private static Broker startDefaultBrokerInTempDirectory() { Loggers.SYSTEM_LOGGER.info("No configuration file specified. Using default configuration."); try { tempFolder = Files.createTempDirectory("zeebe").toAbsolutePath().normalize().toString(); final BrokerCfg cfg = new BrokerCfg(); return new Broker(cfg, tempFolder, null); } catch (final IOException e) { throw new RuntimeException("Could not start broker", e); } }
@SafeVarargs public EmbeddedBrokerRule( final Supplier<InputStream> configSupplier, int timeout, final Consumer<BrokerCfg>... configurators) { this.configSupplier = configSupplier; this.configurators = configurators; this.timeout = timeout; newTemporaryFolder = Files.newTemporaryFolder(); try (InputStream configStream = configSupplier.get()) { if (configStream == null) { brokerCfg = new BrokerCfg(); } else { brokerCfg = TomlConfigurationReader.read(configStream, BrokerCfg.class); } configureBroker(brokerCfg); } catch (final IOException e) { throw new RuntimeException("Unable to open configuration", e); } }
@SafeVarargs public EmbeddedBrokerRule( final Supplier<InputStream> configSupplier, int timeout, final Consumer<BrokerCfg>... configurators) { this.configSupplier = configSupplier; this.configurators = configurators; this.timeout = timeout; newTemporaryFolder = Files.newTemporaryFolder(); try (InputStream configStream = configSupplier.get()) { if (configStream == null) { brokerCfg = new BrokerCfg(); } else { brokerCfg = TomlConfigurationReader.read(configStream, BrokerCfg.class); } configureBroker(brokerCfg); } catch (final IOException e) { throw new RuntimeException("Unable to open configuration", e); } }
@Test public void shouldThrowExceptionIfReplicationFactorIsLargerThenClusterSize() { // given final BrokerCfg brokerCfg = new BrokerCfg(); brokerCfg.getCluster().setReplicationFactor(2); // expect expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage( "Replication factor 2 needs to be larger then zero and not larger then cluster size 1."); initSystemContext(brokerCfg); }
@Test public void shouldThrowExceptionIfPartitionsCountIsNegative() { // given final BrokerCfg brokerCfg = new BrokerCfg(); brokerCfg.getCluster().setPartitionsCount(-1); // expect expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("Partition count must not be smaller then 1."); initSystemContext(brokerCfg); }
@Test public void shouldThrowExceptionIfReplicationFactorIsNegative() { // given final BrokerCfg brokerCfg = new BrokerCfg(); brokerCfg.getCluster().setReplicationFactor(-1); // expect expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage( "Replication factor -1 needs to be larger then zero and not larger then cluster size 1."); initSystemContext(brokerCfg); }
@Test public void shouldThrowExceptionIfPartitionsCountIsNegative() { // given final BrokerCfg brokerCfg = new BrokerCfg(); brokerCfg.getCluster().setPartitionsCount(-1); // expect expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("Partition count must not be smaller then 1."); initSystemContext(brokerCfg); }
@Test public void shouldThrowExceptionIfNodeIdIsNegative() { // given final BrokerCfg brokerCfg = new BrokerCfg(); brokerCfg.getCluster().setNodeId(-1); // expect expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage( "Node id -1 needs to be non negative and smaller then cluster size 1."); initSystemContext(brokerCfg); }
@Test public void shouldThrowExceptionIfNodeIdIsLargerThenClusterSize() { // given final BrokerCfg brokerCfg = new BrokerCfg(); brokerCfg.getCluster().setNodeId(2); // expect expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage( "Node id 2 needs to be non negative and smaller then cluster size 1."); initSystemContext(brokerCfg); }
@Test public void shouldThrowExceptionIfReplicationFactorIsNegative() { // given final BrokerCfg brokerCfg = new BrokerCfg(); brokerCfg.getCluster().setReplicationFactor(-1); // expect expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage( "Replication factor -1 needs to be larger then zero and not larger then cluster size 1."); initSystemContext(brokerCfg); }
@Test public void shouldThrowExceptionIfNodeIdIsLargerThenClusterSize() { // given final BrokerCfg brokerCfg = new BrokerCfg(); brokerCfg.getCluster().setNodeId(2); // expect expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage( "Node id 2 needs to be non negative and smaller then cluster size 1."); initSystemContext(brokerCfg); }
@Test public void shouldThrowExceptionIfReplicationFactorIsLargerThenClusterSize() { // given final BrokerCfg brokerCfg = new BrokerCfg(); brokerCfg.getCluster().setReplicationFactor(2); // expect expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage( "Replication factor 2 needs to be larger then zero and not larger then cluster size 1."); initSystemContext(brokerCfg); }
@Test public void shouldThrowExceptionIfNodeIdIsNegative() { // given final BrokerCfg brokerCfg = new BrokerCfg(); brokerCfg.getCluster().setNodeId(-1); // expect expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage( "Node id -1 needs to be non negative and smaller then cluster size 1."); initSystemContext(brokerCfg); }
try (InputStream configStream = configSupplier.get()) { if (configStream == null) { brokerCfg = new BrokerCfg(); } else { brokerCfg = TomlConfigurationReader.read(configStream, BrokerCfg.class);
try (InputStream configStream = configSupplier.get()) { if (configStream == null) { brokerCfg = new BrokerCfg(); } else { brokerCfg = TomlConfigurationReader.read(configStream, BrokerCfg.class);