Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ public class CatalogMgr implements Writable, GsonPostProcessable {
private final MonitoredReentrantReadWriteLock lock = new MonitoredReentrantReadWriteLock(true);

@SerializedName(value = "idToCatalog")
private final Map<Long, CatalogIf<? extends DatabaseIf<? extends TableIf>>> idToCatalog = Maps.newConcurrentMap();
private Map<Long, CatalogIf<? extends DatabaseIf<? extends TableIf>>> idToCatalog = Maps.newConcurrentMap();
// this map will be regenerated from idToCatalog, so not need to persist.
private final Map<String, CatalogIf> nameToCatalog = Maps.newConcurrentMap();
private Map<String, CatalogIf> nameToCatalog = Maps.newConcurrentMap();

// Use a separate instance to facilitate access.
// internalDataSource still exists in idToCatalog and nameToCatalog
Expand Down Expand Up @@ -817,10 +817,17 @@ public void write(DataOutput out) throws IOException {

@Override
public void gsonPostProcess() throws IOException {
// After deserializing from Gson, the concurrent map may become a normal map.
// So here we reconstruct the concurrent map.
Map<Long, CatalogIf<? extends DatabaseIf<? extends TableIf>>> newIdToCatalog = Maps.newConcurrentMap();
Map<String, CatalogIf> newNameToCatalog = Maps.newConcurrentMap();
for (CatalogIf catalog : idToCatalog.values()) {
nameToCatalog.put(catalog.getName(), catalog);
newNameToCatalog.put(catalog.getName(), catalog);
newIdToCatalog.put(catalog.getId(), catalog);
// ATTN: can not call catalog.getProperties() here, because ResourceMgr is not replayed yet.
}
this.idToCatalog = newIdToCatalog;
this.nameToCatalog = newNameToCatalog;
internalCatalog = (InternalCatalog) idToCatalog.get(InternalCatalog.INTERNAL_CATALOG_ID);
}

Expand Down