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"); + replacedFileGroups.size() + " replaced file groups");
} }
@Override
public void close() {
try {
writeLock.lock();
clear();
} finally {
writeLock.unlock();
}
}
/** /**
* Clears the partition Map and reset view states. * Clears the partition Map and reset view states.
*/ */
@@ -250,12 +260,7 @@ public abstract class AbstractTableFileSystemView implements SyncableFileSystemV
public final void reset() { public final void reset() {
try { try {
writeLock.lock(); writeLock.lock();
clear();
addedPartitions.clear();
resetViewState();
bootstrapIndex = null;
// Initialize with new Hoodie timeline. // Initialize with new Hoodie timeline.
init(metaClient, getTimeline()); init(metaClient, getTimeline());
} finally { } 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. * 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 @Override
public void close() { public void close() {
closed = true; super.close();
super.reset();
partitionToFileGroupsMap = null; partitionToFileGroupsMap = null;
fgIdToPendingCompaction = null; fgIdToPendingCompaction = null;
fgIdToBootstrapBaseFile = null; fgIdToBootstrapBaseFile = null;
fgIdToReplaceInstants = null; fgIdToReplaceInstants = null;
closed = true;
} }
@Override @Override

View File

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

View File

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