1
0

[HUDI-2984] Implement #close for AbstractTableFileSystemView (#4285)

This commit is contained in:
Danny Chan
2021-12-11 16:19:10 +08:00
committed by GitHub
parent b5f05fd153
commit 8dd0444ef9
4 changed files with 25 additions and 10 deletions

View File

@@ -243,6 +243,16 @@ public abstract class AbstractTableFileSystemView implements SyncableFileSystemV
+ replacedFileGroups.size() + " replaced file groups");
}
@Override
public void close() {
try {
writeLock.lock();
clear();
} finally {
writeLock.unlock();
}
}
/**
* Clears the partition Map and reset view states.
*/
@@ -250,12 +260,7 @@ public abstract class AbstractTableFileSystemView implements SyncableFileSystemV
public final void reset() {
try {
writeLock.lock();
addedPartitions.clear();
resetViewState();
bootstrapIndex = null;
clear();
// Initialize with new Hoodie timeline.
init(metaClient, getTimeline());
} finally {
@@ -263,6 +268,15 @@ public abstract class AbstractTableFileSystemView implements SyncableFileSystemV
}
}
/**
* Clear the resource.
*/
private void clear() {
addedPartitions.clear();
resetViewState();
bootstrapIndex = null;
}
/**
* Allows all view metadata in file system view storage to be reset by subclasses.
*/

View File

@@ -349,12 +349,12 @@ public class HoodieTableFileSystemView extends IncrementalTimelineSyncFileSystem
@Override
public void close() {
closed = true;
super.reset();
super.close();
partitionToFileGroupsMap = null;
fgIdToPendingCompaction = null;
fgIdToBootstrapBaseFile = null;
fgIdToReplaceInstants = null;
closed = true;
}
@Override

View File

@@ -126,7 +126,7 @@ public class RemoteHoodieTableFileSystemView implements SyncableFileSystemView,
private final int serverPort;
private final String basePath;
private final HoodieTableMetaClient metaClient;
private final HoodieTimeline timeline;
private HoodieTimeline timeline;
private final ObjectMapper mapper;
private final int timeoutSecs;
@@ -450,6 +450,7 @@ public class RemoteHoodieTableFileSystemView implements SyncableFileSystemView,
@Override
public void reset() {
timeline = metaClient.reloadActiveTimeline().filterCompletedAndCompactionInstants();
refresh();
}

View File

@@ -249,7 +249,7 @@ public class WriteProfile {
return;
}
this.metaClient.reloadActiveTimeline();
this.fsView = getFileSystemView();
this.fsView.sync();
recordProfile();
cleanMetadataCache(this.metaClient.getCommitsTimeline().filterCompletedInstants().getInstants());
this.smallFilesMap.clear();