@Override public void initialize() { writeBatcher = this.dataMovementManager.newWriteBatcher(); writeBatcher.withThreadCount(threadCount); writeBatcher.withBatchSize(batchSize); jobTicket = dataMovementManager.startJob(writeBatcher); }
@Test public void testZeros() throws Exception { try { WriteBatcher batcher = moveMgr.newWriteBatcher() .withBatchSize(0); fail("should have thrown IllegalArgumentException because batchSize must be > 1"); } catch(IllegalArgumentException e) {} try { WriteBatcher batcher = moveMgr.newWriteBatcher() .withThreadCount(0); fail("should have thrown IllegalArgumentException because threadCount must be > 1"); } catch(IllegalArgumentException e) {} }
AtomicReference<Throwable> unexpectedError = new AtomicReference<>(); WriteBatcher ihbMT = moveMgr.newWriteBatcher(); ihbMT.withBatchSize(7).withThreadCount(60);
WriteBatcher batcher = moveMgr.newWriteBatcher() .withBatchSize(batchSize) .withThreadCount(batcherThreadCount) .onBatchSuccess( batch -> {
.withThreadCount(8) .onBatchSuccess(batch -> installDocsFinished = true) .onBatchFailure((batch, failure) -> {
.withThreadCount(4) .onBatchSuccess(batch -> installDocsFinished = true) .onBatchFailure((batch, failure) -> {
batcher .withBatchSize(10) .withThreadCount(4) .withTransform(runFlow) .onBatchFailure((batch, failure) -> {
.withThreadCount(4) .onBatchSuccess(batch -> installDocsFinished = true) .onBatchFailure((batch, failure) -> {
@Test public void testWriteBatcher() { assertEquals(null, client.newDocumentManager().exists("doc1.txt")); assertEquals(null, client.newDocumentManager().exists("doc2.txt")); // begin copy from "Using WriteBatcher" in src/main/java/com/marklogic/datamovement/package-info.java WriteBatcher whb = dataMovementManager.newWriteBatcher() .withBatchSize(100) .withThreadCount(20) .onBatchSuccess(batch -> { logger.debug("batch # {}, so far: {}", batch.getJobBatchNumber(), batch.getJobWritesSoFar()); }) .onBatchFailure((batch,throwable) -> throwable.printStackTrace() ); JobTicket ticket = dataMovementManager.startJob(whb); // the add or addAs methods could be called in separate threads on the // single whb instance whb.add ("doc1.txt", new StringHandle("doc1 contents")); whb.addAs("doc2.txt", "doc2 contents"); whb.flushAndWait(); // send the two docs even though they're not a full batch dataMovementManager.stopJob(ticket); // end copy from "Using WriteBatcher" in src/main/java/com/marklogic/datamovement/package-info.java assertTrue(null != client.newDocumentManager().exists("doc1.txt")); assertTrue(null != client.newDocumentManager().exists("doc2.txt")); } }