[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-1161?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13222724#comment-13222724
 ] 

Henry Robinson commented on ZOOKEEPER-1161:
-------------------------------------------

+1, looks good to me. A couple of nits:

{code}
+    
+    public static final String ZOOKEEPER_DATADIR_AUTOCREATE =
+            "zookeeper.datadir.autocreate";
{code}

Can you add {{public static final String ZOOKEEPER_DATADIR_AUTOCREATE_DEFAULT = 
"true"}} and use that where you've used the raw string? In case we change the 
default in 4.0, this makes it so that, for example, the test will restore the 
default correctly. 

{code}
+            if (!enableAutocreate) {
+                throw new DatadirException("Missing data directory "
+                        + this.dataDir + ", please create this directory.");
+            }
{code}

Might be nice to explain to the user why we're not creating the directory. 
Perhaps {{"Missing data directory " + this.dataDir + ", automatic data 
directory creation is disabled (zookeeper.datadir.autocreate is false). Please 
create this directory manually."}}

{code}

+        try {
+            tmpDir = ClientBase.createTmpDir();
+            zks = new ZooKeeperServer(tmpDir, tmpDir, 3000);
+            f = ServerCnxnFactory.createFactory(PORT, -1);
+            f.startup(zks);
+            Assert.assertTrue("waiting for server being up ", ClientBase
+                    .waitForServerUp(HOSTPORT, CONNECTION_TIMEOUT));
+
+            Assert.fail("Server should not have started without datadir");
+        } catch (IOException e) {
+            LOG.info("Server failed to start - correct behavior " + e);
+        }
+
+        System.setProperty(FileTxnSnapLog.ZOOKEEPER_DATADIR_AUTOCREATE, 
"true");
+    }
{code}

Can you put the final setProperty in a final block, in case a runtime exception 
throws and the property setting leaks?
                
> Provide an option for disabling auto-creation of the data directory
> -------------------------------------------------------------------
>
>                 Key: ZOOKEEPER-1161
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-1161
>             Project: ZooKeeper
>          Issue Type: New Feature
>          Components: scripts, server
>            Reporter: Roman Shaposhnik
>            Assignee: Patrick Hunt
>             Fix For: 3.5.0
>
>         Attachments: ZOOKEEPER-1161.patch
>
>
> Currently if ZK starts and doesn't see and existing dataDir it tries to 
> create it. There should be an option to tweak this behavior. As for default, 
> my personal opinion is to NOW allow autocreate.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to