Skip to content
Merged
Show file tree
Hide file tree
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 @@ -25,7 +25,6 @@
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -294,7 +293,8 @@ public ReentrantReadWriteLock getTableLock(String tableName) {
private final long omEpoch;

private Map<String, Table> tableMap = new HashMap<>();
private List<TableCacheMetrics> tableCacheMetrics = new LinkedList<>();
private final Map<String, TableCacheMetrics> tableCacheMetricsMap =
new HashMap<>();
private SnapshotChainManager snapshotChainManager;

public OmMetadataManagerImpl(OzoneConfiguration conf) throws IOException {
Expand Down Expand Up @@ -463,7 +463,10 @@ private void checkTableStatus(Table table, String name,
}
this.tableMap.put(name, table);
if (addCacheMetrics) {
tableCacheMetrics.add(table.createCacheMetrics());
if (tableCacheMetricsMap.containsKey(name)) {
tableCacheMetricsMap.get(name).unregister();
}
tableCacheMetricsMap.put(name, table.createCacheMetrics());
}
}

Expand Down Expand Up @@ -713,9 +716,7 @@ public void stop() throws IOException {
store.close();
store = null;
}
for (TableCacheMetrics metrics : tableCacheMetrics) {
metrics.unregister();
}
tableCacheMetricsMap.values().forEach(TableCacheMetrics::unregister);
// OzoneManagerLock cleanup
lock.cleanup();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,48 @@ public void testUpdateReconOmDBWithNewSnapshot() throws Exception {
.get("/sampleVol/bucketOne/key_two"));
}

@Test
public void testReconOmDBCloseAndOpenNewSnapshotDb() throws Exception {
OMMetadataManager omMetadataManager =
initializeNewOmMetadataManager(temporaryFolder.newFolder());
ReconOMMetadataManager reconOMMetadataManager =
getTestReconOmMetadataManager(omMetadataManager,
temporaryFolder.newFolder());

writeDataToOm(omMetadataManager, "key_one");
writeDataToOm(omMetadataManager, "key_two");

DBCheckpoint checkpoint = omMetadataManager.getStore()
.getCheckpoint(true);
File tarFile1 = createTarFile(checkpoint.getCheckpointLocation());
File tarFile2 = createTarFile(checkpoint.getCheckpointLocation());
InputStream inputStream1 = new FileInputStream(tarFile1);
InputStream inputStream2 = new FileInputStream(tarFile2);
ReconUtils reconUtilsMock = getMockReconUtils();
HttpURLConnection httpURLConnectionMock1 = mock(HttpURLConnection.class);
when(httpURLConnectionMock1.getInputStream()).thenReturn(inputStream1);
when(reconUtilsMock.makeHttpCall(any(), anyString(), anyBoolean()))
.thenReturn(httpURLConnectionMock1);

ReconTaskController reconTaskController = getMockTaskController();

OzoneManagerServiceProviderImpl ozoneManagerServiceProvider1 =
new OzoneManagerServiceProviderImpl(configuration,
reconOMMetadataManager, reconTaskController, reconUtilsMock,
ozoneManagerProtocol);
assertTrue(ozoneManagerServiceProvider1.updateReconOmDBWithNewSnapshot());

HttpURLConnection httpURLConnectionMock2 = mock(HttpURLConnection.class);
when(httpURLConnectionMock2.getInputStream()).thenReturn(inputStream2);
when(reconUtilsMock.makeHttpCall(any(), anyString(), anyBoolean()))
.thenReturn(httpURLConnectionMock2);
OzoneManagerServiceProviderImpl ozoneManagerServiceProvider2 =
new OzoneManagerServiceProviderImpl(configuration,
reconOMMetadataManager, reconTaskController, reconUtilsMock,
ozoneManagerProtocol);
assertTrue(ozoneManagerServiceProvider2.updateReconOmDBWithNewSnapshot());
}

@Test
public void testGetOzoneManagerDBSnapshot() throws Exception {

Expand Down