public void testAppendTransientBookieFailure() throws Exception { TreeMap<LogAddress, byte[]> writeData = new TreeMap<>(Comparator.comparingLong(LogAddress::getSequence)); try (DurableDataLog log = createDurableDataLog()) { log.initialize(TIMEOUT); stopFirstBookie(); int writeCount = getWriteCount(); for (int i = 0; i < writeCount; i++) { byte[] data = getWriteData(); futures.add(log.append(new ByteArraySegment(data), TIMEOUT)); dataList.add(data); restartFirstBookie(); try (DurableDataLog log = createDurableDataLog()) { log.initialize(TIMEOUT); verifyReads(log, writeData);
try (DurableDataLog log = createDurableDataLog()) { log.initialize(TIMEOUT); stopFirstBookie(); () -> log.append(new ByteArraySegment(getWriteData()), TIMEOUT), ex -> ex instanceof RetriesExhaustedException && (ex.getCause() instanceof DataLogNotAvailableException || isLedgerClosedException(ex.getCause())) || ex instanceof ObjectClosedException || ex instanceof CancellationException); () -> log.append(new ByteArraySegment(getWriteData()), TIMEOUT), ex -> ex instanceof ObjectClosedException || ex instanceof CancellationException); } finally { restartFirstBookie();
try (BookKeeperLog log = (BookKeeperLog) createDurableDataLog()) { log.initialize(TIMEOUT); log.append(new ByteArraySegment(getWriteData()), TIMEOUT).get(TIMEOUT.toMillis(), TimeUnit.MILLISECONDS);
.with(BookKeeperConfig.BK_WRITE_QUORUM_SIZE, BOOKIE_COUNT) .with(BookKeeperConfig.BK_ACK_QUORUM_SIZE, BOOKIE_COUNT) .with(BookKeeperConfig.BK_TLS_ENABLED, isSecure()) .with(BookKeeperConfig.BK_WRITE_TIMEOUT, 1000) // This is the minimum we can set anyway. .build()); val factory = new BookKeeperLogFactory(this.config.get(), this.zkClient.get(), executorService()); factory.initialize(); this.factory.set(factory);
@Override protected DurableDataLog createDurableDataLog(Object sharedContext) { return createDurableDataLog(); // Nothing different for shared context. }
/** * Tests the BookKeeperLogFactory and its initialization. */ @Test public void testFactoryInitialize() { BookKeeperConfig bkConfig = BookKeeperConfig .builder() .with(BookKeeperConfig.ZK_ADDRESS, "localhost:" + BK_PORT.get()) .with(BookKeeperConfig.BK_LEDGER_MAX_SIZE, WRITE_MAX_LENGTH * 10) // Very frequent rollovers. .with(BookKeeperConfig.ZK_METADATA_PATH, this.zkClient.get().getNamespace()) .build(); @Cleanup val factory = new BookKeeperLogFactory(bkConfig, this.zkClient.get(), executorService()); AssertExtensions.assertThrows("", factory::initialize, ex -> ex instanceof DataLogNotAvailableException && ex.getCause() instanceof BKException.ZKException ); }
/** * Start BookKeeper once for the duration of this class. This is pretty strenuous, so in the interest of running time * we only do it once. */ public static void setUpBookKeeper(boolean secure) throws Exception { // Pick a random port to reduce chances of collisions during concurrent test executions. SECURE_BK.set(secure); BK_PORT.set(TestUtils.getAvailableListenPort()); val bookiePorts = new ArrayList<Integer>(); for (int i = 0; i < BOOKIE_COUNT; i++) { bookiePorts.add(TestUtils.getAvailableListenPort()); } val runner = BookKeeperServiceRunner.builder() .startZk(true) .zkPort(BK_PORT.get()) .ledgersPath("/pravega/bookkeeper/ledgers") .secureBK(isSecure()) .secureZK(isSecure()) .tlsTrustStore("../../../config/bookie.truststore.jks") .tLSKeyStore("../../../config/bookie.keystore.jks") .tLSKeyStorePasswordPath("../../../config/bookie.keystore.jks.passwd") .bookiePorts(bookiePorts) .build(); runner.startAll(); BK_SERVICE.set(runner); }
try (DurableDataLog log = createDurableDataLog()) { log.initialize(TIMEOUT); try { stopFirstBookie(); int writeCount = getWriteCount(); for (int i = 0; i < writeCount; i++) { appendFutures.add(log.append(new ByteArraySegment(getWriteData()), TIMEOUT)); restartFirstBookie();