@Inject
    public RecordingHiveMetastore(@ForRecordingHiveMetastore ExtendedHiveMetastore delegate, MetastoreClientConfig metastoreClientConfig)
            throws IOException
    {
        this.delegate = requireNonNull(delegate, "delegate is null");
        requireNonNull(metastoreClientConfig, "hiveClientConfig is null");
        this.recordingPath = requireNonNull(metastoreClientConfig.getRecordingPath(), "recordingPath is null");
        this.replay = metastoreClientConfig.isReplay();

        databaseCache = createCache(metastoreClientConfig);
        tableCache = createCache(metastoreClientConfig);
        tableConstraintsCache = createCache(metastoreClientConfig);
        supportedColumnStatisticsCache = createCache(metastoreClientConfig);
        tableStatisticsCache = createCache(metastoreClientConfig);
        partitionStatisticsCache = createCache(metastoreClientConfig);
        allTablesCache = createCache(metastoreClientConfig);
        allViewsCache = createCache(metastoreClientConfig);
        partitionCache = createCache(metastoreClientConfig);
        partitionNamesCache = createCache(metastoreClientConfig);
        partitionNamesByFilterCache = createCache(metastoreClientConfig);
        partitionsByNamesCache = createCache(metastoreClientConfig);
        tablePrivilegesCache = createCache(metastoreClientConfig);
        roleGrantsCache = createCache(metastoreClientConfig);

        if (replay) {
            loadRecording();
        }
    }
@Test
    public void testRecordingHiveMetastore()
            throws IOException
    {
        MetastoreClientConfig recordingHiveClientConfig = new MetastoreClientConfig()
                .setRecordingPath(File.createTempFile("recording_test", "json").getAbsolutePath())
                .setRecordingDuration(new Duration(10, TimeUnit.MINUTES));

        RecordingHiveMetastore recordingHiveMetastore = new RecordingHiveMetastore(new TestingHiveMetastore(), recordingHiveClientConfig);
        validateMetadata(recordingHiveMetastore);
        recordingHiveMetastore.dropDatabase(TEST_METASTORE_CONTEXT, "other_database");
        recordingHiveMetastore.writeRecording();

        MetastoreClientConfig replayingHiveClientConfig = recordingHiveClientConfig
                .setReplay(true);

        recordingHiveMetastore = new RecordingHiveMetastore(new UnimplementedHiveMetastore(), replayingHiveClientConfig);
        recordingHiveMetastore.loadRecording();
        validateMetadata(recordingHiveMetastore);
    }