keith-turner commented on a change in pull request #2213:
URL: https://github.com/apache/accumulo/pull/2213#discussion_r676845400
##########
File path:
server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/CompactableImpl.java
##########
@@ -239,63 +230,53 @@ private void sanityCheckExternalCompactions(
}
+ private synchronized boolean addJob(CompactionJob job) {
+ if (runningJobs.add(job)) {
+ compactionRunning = true;
+ return true;
+ }
+
+ return false;
+ }
+
+ private synchronized boolean removeJob(CompactionJob job) {
+ var removed = runningJobs.remove(job);
+ compactionRunning = !runningJobs.isEmpty();
+ return removed;
+ }
+
void initiateChop() {
Set<StoredTabletFile> allFiles = tablet.getDatafiles().keySet();
- Set<StoredTabletFile> filesToExamine = new HashSet<>(allFiles);
+ ChopSelector chopSelector;
synchronized (this) {
- if (chopStatus == FileSelectionStatus.NOT_ACTIVE) {
- chopStatus = FileSelectionStatus.SELECTING;
- filesToExamine.removeAll(choppedFiles);
- filesToExamine.removeAll(allCompactingFiles);
+ if (fileMgr.getChopStatus() == FileSelectionStatus.NOT_ACTIVE) {
+ chopSelector = fileMgr.initiateChop(allFiles);
} else {
return;
}
}
- Set<StoredTabletFile> unchoppedFiles = selectChopFiles(filesToExamine);
+ Set<StoredTabletFile> unchoppedFiles =
selectChopFiles(chopSelector.getFilesToExamine());
synchronized (this) {
- Preconditions.checkState(chopStatus == FileSelectionStatus.SELECTING);
- choppedFiles.addAll(Sets.difference(filesToExamine, unchoppedFiles));
- chopStatus = FileSelectionStatus.SELECTED;
- this.allFilesWhenChopStarted.clear();
- this.allFilesWhenChopStarted.addAll(allFiles);
-
- var filesToChop = getFilesToChop(allFiles);
- if (!filesToChop.isEmpty()) {
- TabletLogger.selected(getExtent(), CompactionKind.CHOP, filesToChop);
- }
+ chopSelector.selectChopFiles(unchoppedFiles);
}
checkifChopComplete(tablet.getDatafiles().keySet());
}
- private synchronized Set<StoredTabletFile>
getFilesToChop(Set<StoredTabletFile> allFiles) {
- Preconditions.checkState(chopStatus == FileSelectionStatus.SELECTED);
- var copy = new HashSet<>(allFilesWhenChopStarted);
- copy.retainAll(allFiles);
- copy.removeAll(choppedFiles);
- return copy;
- }
-
private void checkifChopComplete(Set<StoredTabletFile> allFiles) {
boolean completed = false;
synchronized (this) {
- if (chopStatus == FileSelectionStatus.SELECTED) {
- if (getFilesToChop(allFiles).isEmpty()) {
- chopStatus = FileSelectionStatus.NOT_ACTIVE;
- completed = true;
- }
- }
-
- choppedFiles.retainAll(allFiles);
+ completed = fileMgr.finishChop(allFiles);
}
if (completed) {
+ // TODO could be closed
Review comment:
I will open an issue and remove the TODO before merging this.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]