@Override public void delete(TableReference tableRef, Multimap<Cell, Long> keys) { if (keys.isEmpty()) { return; } delegate.delete(tableRef, keys); }
@Override public void delete(TableReference tableRef, Multimap<Cell, Long> keys) { try { delegate().delete(tableMapper.getMappedTableName(tableRef), keys); } catch (TableMappingNotFoundException e) { throw new IllegalArgumentException(e); } }
@Override public void removeTable(TableReference tableRef) { Cell key = Cell.create(getBytesForTableRef(tableRef), AtlasDbConstants.NAMESPACE_SHORT_COLUMN_BYTES); if (kv.getAllTableNames().contains(AtlasDbConstants.NAMESPACE_TABLE)) { kv.delete(AtlasDbConstants.NAMESPACE_TABLE, ImmutableMultimap.of(key, 0L)); } // Need to invalidate the table ref in case we end up re-creating the same table // again. Frequently when we drop one table we end up dropping a bunch of tables, // so just invalidate everything. tableMap.set(HashBiMap.<TableReference, TableReference>create()); }
@Override public void delete(TableReference tableRef, Multimap<Cell, Long> keys) { maybeLog(() -> delegate.delete(tableRef, keys), logCellsAndSize("delete", tableRef, keys.keySet().size(), byteSize(keys))); }
@Override public void delete(TableReference tableRef, Multimap<Cell, Long> keys) { //noinspection unused - try-with-resources closes trace try (CloseableTrace trace = startLocalTrace("delete({}, {} keys)", LoggingArgs.safeTableOrPlaceholder(tableRef), keys.size())) { delegate().delete(tableRef, keys); } }
protected void retryWriteToKvs(Map<Cell, byte[]> writeMap) { Multimap<Cell, Long> keys = Multimaps.forMap(Maps2.createConstantValueMap( writeMap.keySet(), migrationTimestamp)); writeKvs.delete(destTable, keys); writeKvs.put(destTable, writeMap, migrationTimestamp); }
private void assertDeletedNumber(TableReference tableRef, int expectedDeleted) { ArgumentCaptor<Multimap> argumentCaptor = ArgumentCaptor.forClass(Multimap.class); verify(spiedKvs).delete(eq(tableRef), argumentCaptor.capture()); Multimap<Cell, Long> actual = argumentCaptor.getValue(); assertThat(actual.size()).isEqualTo(expectedDeleted); } }
private void assertDeleted(TableReference tableRef, Multimap<Cell, Long> expectedDeletes) { ArgumentCaptor<Multimap> argumentCaptor = ArgumentCaptor.forClass(Multimap.class); verify(spiedKvs).delete(eq(tableRef), argumentCaptor.capture()); Multimap<Cell, Long> actual = argumentCaptor.getValue(); assertThat(actual.keySet()).containsExactlyElementsOf(expectedDeletes.keySet()); actual.keySet().forEach(key -> assertThat(actual.get(key)).containsExactlyElementsOf(expectedDeletes.get(key))); }
@Test public void ensureNoActionTakenIfNoCellsToSweep() { sweeper.sweepCells(TABLE_REFERENCE, ImmutableMultimap.of(), ImmutableSet.of()); verify(mockKvs, never()).delete(any(), any()); verify(mockKvs, never()).addGarbageCollectionSentinelValues(any(), any()); verify(mockPlm, never()).acquirePersistentLockWithRetry(); }
private Object doDelete(RegeneratingTable<Multimap<Cell, Long>> table) { table.getKvs().delete(table.getTableRef(), table.getTableCells()); return table.getTableCells(); }
@Test public void acquireTheBackupLockBeforeDeletingButAfterAddingSentinels() { sweeper.sweepCells(TABLE_REFERENCE, SINGLE_CELL_TS_PAIR, SINGLE_CELL_SET); InOrder ordering = inOrder(mockPlm, mockKvs); ordering.verify(mockKvs, atLeastOnce()).addGarbageCollectionSentinelValues(TABLE_REFERENCE, SINGLE_CELL_SET); ordering.verify(mockPlm, times(1)).acquirePersistentLockWithRetry(); ordering.verify(mockKvs, atLeastOnce()).delete(TABLE_REFERENCE, SINGLE_CELL_TS_PAIR); }
@Test public void releaseTheBackupLockAfterDeleteAndAddingSentinels() { sweeper.sweepCells(TABLE_REFERENCE, SINGLE_CELL_TS_PAIR, SINGLE_CELL_SET); InOrder ordering = inOrder(mockPlm, mockKvs); ordering.verify(mockKvs, atLeastOnce()).addGarbageCollectionSentinelValues(TABLE_REFERENCE, SINGLE_CELL_SET); ordering.verify(mockKvs, atLeastOnce()).delete(TABLE_REFERENCE, SINGLE_CELL_TS_PAIR); ordering.verify(mockPlm, times(1)).releasePersistentLock(); }
@Test public void releaseTheBackupLockIfDeleteFails() { doThrow(new RuntimeException("something bad happened")) .when(mockKvs).delete(TABLE_REFERENCE, SINGLE_CELL_TS_PAIR); assertThatExceptionOfType(RuntimeException.class) .isThrownBy(() -> sweeper.sweepCells(TABLE_REFERENCE, SINGLE_CELL_TS_PAIR, ImmutableSet.of())) .withMessage("something bad happened"); verify(mockPlm, times(1)).releasePersistentLock(); } }
@Test public void testKeyValueDelete7() { putDirect("row1", "col1", "v2", 2); Pair<String, Long> pair = getDirect("row1", "col1", 3); assertEquals(2L, (long)pair.getRhSide()); assertEquals("v2", pair.getLhSide()); keyValueService.delete(TEST_TABLE, Multimaps.forMap(ImmutableMap.of(createCell("row1", "col1"), 1L))); keyValueService.delete(TEST_TABLE, Multimaps.forMap(ImmutableMap.of(createCell("row1", "col1"), 3L))); pair = getDirect("row1", "col1", 3); assertEquals(2L, (long)pair.getRhSide()); assertEquals("v2", pair.getLhSide()); }
@Test public void testKeyValueDelete() { putDirect("row1", "col1", "v1", 0); Pair<String, Long> pair = getDirect("row1", "col1", 2); assertEquals(0L, (long)pair.getRhSide()); assertEquals("v1", pair.getLhSide()); keyValueService.delete(TEST_TABLE, Multimaps.forMap(ImmutableMap.of(createCell("row1", "col1"), 0L))); pair = getDirect("row1", "col1", 2); assertNull(pair); }
@Test public void testKeyValueDelete3() { putDirect("row1", "col1", "v0", 0); putDirect("row1", "col1", "v1", 1); Pair<String, Long> pair = getDirect("row1", "col1", 2); assertEquals(1L, (long)pair.getRhSide()); assertEquals("v1", pair.getLhSide()); keyValueService.delete(TEST_TABLE, Multimaps.forMap(ImmutableMap.of(createCell("row1", "col1"), 1L))); pair = getDirect("row1", "col1", 2); assertEquals(0L, (long)pair.getRhSide()); assertEquals("v0", pair.getLhSide()); }
@Test public void testKeyValueDelete2() { putDirect("row1", "col1", "v1", 1); putDirect("row1", "col1", "v2", 2); Pair<String, Long> pair = getDirect("row1", "col1", 3); assertEquals(2L, (long)pair.getRhSide()); assertEquals("v2", pair.getLhSide()); keyValueService.delete(TEST_TABLE, Multimaps.forMap(ImmutableMap.of(createCell("row1", "col1"), 2L))); pair = getDirect("row1", "col1", 3); assertEquals(1L, (long)pair.getRhSide()); assertEquals("v1", pair.getLhSide()); }
@Test public void testKeyValueDelete6() { putDirect("row1", "col1", "v1", 1); putDirect("row1", "col1", "v2", 2); Pair<String, Long> pair = getDirect("row1", "col1", 3); assertEquals(2L, (long)pair.getRhSide()); assertEquals("v2", pair.getLhSide()); keyValueService.delete(TEST_TABLE, Multimaps.forMap(ImmutableMap.of(createCell("row1", "col1"), 1L))); pair = getDirect("row1", "col1", 3); assertEquals(2L, (long)pair.getRhSide()); assertEquals("v2", pair.getLhSide()); }