Skip to content

Commit

Permalink
Close mutation sender after completing import (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
aymkhalil authored Apr 11, 2023
1 parent cdeda9c commit 1b37ff8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,13 @@ public ExitStatus importTable() {
LOGGER.warn("Error while closing CVS connector", e);
}
}
if (mutationSender != null) {
try {
mutationSender.close();
} catch (Exception e) {
LOGGER.warn("Error while closing Pulsar mutation sender", e);
}
}
printSummary(recordsCount);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public void testImportPartitionKeyOnly() {
// then
assertEquals(ExitStatus.STATUS_OK, status);
Mockito.verify(sender, Mockito.times(2)).sendMutationAsync(abstractMutationCaptor.capture());
Mockito.verify(sender, Mockito.times(1)).close();
List<AbstractMutation<TableMetadata>> pkValues = abstractMutationCaptor.getAllValues();
assertEquals(2, pkValues.size());
List<Object> allPkValues = pkValues.stream().flatMap(v-> Arrays.stream(v.getPkValues())).collect(Collectors.toList());
Expand Down Expand Up @@ -203,6 +204,7 @@ public void testImportPartitionAndClusteringKeys() {
// then
assertEquals(ExitStatus.STATUS_OK, status);
Mockito.verify(sender, Mockito.times(2)).sendMutationAsync(abstractMutationCaptor.capture());
Mockito.verify(sender, Mockito.times(1)).close();
List<AbstractMutation<TableMetadata>> pkValues = abstractMutationCaptor.getAllValues();
assertEquals(2, pkValues.size());
List<Object>[] allPkValues = pkValues.stream().map(v-> v.getPkValues()).map(Arrays::asList).toArray(List[]::new);
Expand Down Expand Up @@ -285,6 +287,7 @@ public void testImportInflightMessagesBound() throws URISyntaxException, IOExcep
// verify that no more interactions with sender because no new records should've been sent.
assertTrue(importFuture.isDone());
assertThat(importFuture.get(), is(ExitStatus.STATUS_OK));
Mockito.verify(sender, Mockito.times(1)).close();
Mockito.verifyNoMoreInteractions(sender);
}

Expand Down Expand Up @@ -330,6 +333,7 @@ public void testImportFailsFast() throws URISyntaxException, IOException, Execut

// then
assertTrue(importFuture.isDone());
Mockito.verify(sender, Mockito.times(1)).close();
assertThat(importFuture.get(), is(ExitStatus.STATUS_ABORTED_FATAL_ERROR));
}

Expand Down

0 comments on commit 1b37ff8

Please sign in to comment.