Jason918 commented on code in PR #17078:
URL: https://github.com/apache/pulsar/pull/17078#discussion_r945057496
##########
pulsar-metadata/src/main/java/org/apache/pulsar/metadata/impl/RocksdbMetadataStore.java:
##########
@@ -233,12 +240,15 @@ private RocksdbMetadataStore(String metadataURL,
MetadataStoreConfig metadataSto
throw new MetadataStoreException("Fail to create RocksDB file
directory", e);
}
+ readonly = "true".equalsIgnoreCase(
Review Comment:
I am not sure if it's a good idea to use system property to set up this
config. It's not easy for user to know this config.
##########
pulsar-metadata/src/test/java/org/apache/pulsar/metadata/impl/RocksdbMetadataStoreTest.java:
##########
@@ -35,11 +35,64 @@
import org.apache.pulsar.metadata.api.MetadataStoreFactory;
import org.apache.pulsar.metadata.api.Stat;
import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.testng.annotations.*;
+
+import static org.testng.Assert.assertEquals;
@Slf4j
public class RocksdbMetadataStoreTest {
+ MetadataStore store;
+
+ Path readonlyDataDir;
+ @BeforeClass
+ public void setup() throws Exception {
Review Comment:
This method does not apply to other old test method. Please use a new test
class or call it manually in the new tests.
##########
pulsar-metadata/src/main/java/org/apache/pulsar/metadata/impl/RocksdbMetadataStore.java:
##########
@@ -233,12 +240,15 @@ private RocksdbMetadataStore(String metadataURL,
MetadataStoreConfig metadataSto
throw new MetadataStoreException("Fail to create RocksDB file
directory", e);
}
+ readonly = "true".equalsIgnoreCase(
+ System.getProperty(ROCKSDB_READONLY, "false"));
db = openDB(dataPath.toString(),
metadataStoreConfig.getConfigFilePath());
this.optionSync = new WriteOptions().setSync(true);
this.optionDontSync = new WriteOptions().setSync(false);
this.optionCache = new ReadOptions().setFillCache(true);
this.optionDontCache = new ReadOptions().setFillCache(false);
+ dbStateLock = new ReentrantReadWriteLock();
Review Comment:
Any reason to move this here?
##########
pulsar-metadata/src/test/java/org/apache/pulsar/metadata/impl/RocksdbMetadataStoreTest.java:
##########
@@ -35,11 +35,64 @@
import org.apache.pulsar.metadata.api.MetadataStoreFactory;
import org.apache.pulsar.metadata.api.Stat;
import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.testng.annotations.*;
+
+import static org.testng.Assert.assertEquals;
@Slf4j
public class RocksdbMetadataStoreTest {
+ MetadataStore store;
+
+ Path readonlyDataDir;
+ @BeforeClass
+ public void setup() throws Exception {
+ readonlyDataDir =
Files.createTempDirectory("RocksDBMetadataReadOnlyTest");
+
+ store = MetadataStoreFactory.create("rocksdb:"+readonlyDataDir,
MetadataStoreConfig.builder().build());
+ // put init data to rocksdb
+ store.put("/test","hello".getBytes(), Optional.of(-1L)).get();
+ store.close();
Review Comment:
Can we use readonly mode when normal store is not closed?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]