Skip to content

Commit 67a6ac2

Browse files
committed
address comment
1 parent 3e60a8d commit 67a6ac2

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/EntryLocationIndex.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
import java.io.IOException;
2626
import java.util.Map.Entry;
2727
import java.util.Set;
28-
import java.util.concurrent.atomic.AtomicBoolean;
2928
import java.util.concurrent.TimeUnit;
29+
import java.util.concurrent.atomic.AtomicBoolean;
3030
import org.apache.bookkeeper.bookie.Bookie;
3131
import org.apache.bookkeeper.bookie.EntryLocation;
3232
import org.apache.bookkeeper.bookie.storage.ldb.KeyValueStorage.Batch;
@@ -68,6 +68,15 @@ public EntryLocationIndex(ServerConfiguration conf, KeyValueStorageFactory stora
6868

6969
@Override
7070
public void close() throws IOException {
71+
while (!compacting.compareAndSet(false, true)) {
72+
// Wait till the locationsDb stops compacting
73+
try {
74+
Thread.sleep(100);
75+
} catch (InterruptedException e) {
76+
Thread.currentThread().interrupt();
77+
throw new IOException(e);
78+
}
79+
}
7180
locationsDb.close();
7281
}
7382

@@ -217,10 +226,6 @@ public boolean isCompacting() {
217226
return compacting.get();
218227
}
219228

220-
public boolean compareAndSetCompacting(boolean expectedValue, boolean newValue) {
221-
return compacting.compareAndSet(expectedValue, newValue);
222-
}
223-
224229
public void removeOffsetFromDeletedLedgers() throws IOException {
225230
Set<Long> ledgersToDelete = deletedLedgers.items();
226231

bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/SingleDirectoryDbLedgerStorage.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,6 @@ public void shutdown() throws InterruptedException {
347347
try {
348348
flush();
349349

350-
while (!entryLocationIndex.compareAndSetCompacting(false, true)) {
351-
Thread.sleep(100);
352-
}
353350
gcThread.shutdown();
354351
entryLogger.close();
355352

0 commit comments

Comments
 (0)