sijie commented on a change in pull request #948: ISSUE #947: ZK configs for 
LocalBookkeeper
URL: https://github.com/apache/bookkeeper/pull/948#discussion_r159957539
 
 

 ##########
 File path: 
bookkeeper-server/src/main/java/org/apache/bookkeeper/util/LocalBookKeeper.java
 ##########
 @@ -280,11 +291,19 @@ static void 
startLocalBookiesInternal(ServerConfiguration conf,
         List<File> bkTmpDirs = null;
         try {
             if (shouldStartZK) {
-                zkTmpDir = IOUtils.createTempDir("zookeeper", dirSuffix);
+                if (null == zkDataDir) {
+                    zkTmpDir = IOUtils.createTempDir("zookeeper", dirSuffix);
 
 Review comment:
   IOUtils.createTempDir is using File.createTempFile(...), which create a temp 
dir under default temporary-file directory.
   
   You can use [`File.createTempFile(prefix, suffix, 
directory)`](https://docs.oracle.com/javase/7/docs/api/java/io/File.html#createTempFile(java.lang.String,%20java.lang.String,%20java.io.File))
 to create temp dir at a given directory.
   
   I think the question I am having here: we are having two different classes 
for creating temp directory. It is better to add `createTempDir(prefix, suffix, 
directory)` in IOUtils and use this method here, to make things consistent and 
easier to maintain.
   
   ```
   class IOUtils {
   
           public static File createTempDir(String prefix, String suffix) {
                return createTempDir(prefix, suffix, null);
           }
   
            public static File createTempDir(String prefix, String suffix, File 
dir)
               throws IOException {
           File tmpDir = File.createTempFile(prefix, suffixi, dir);
           if (!tmpDir.delete()) {
               throw new IOException("Couldn't delete directory " + tmpDir);
           }
           if (!tmpDir.mkdir()) {
               throw new IOException("Couldn't create directory " + tmpDir);
           }
           return tmpDir;
       }
   
   }
   ```
   
   then you can use it here:
   
   ```
   zkTempDir = IOUtils.createTempDir("zookeeper", "dirSuffix", zkDataDir);
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to