Java Code Examples for org.apache.ratis.util.FileUtils#createDirectories()
The following examples show how to use
org.apache.ratis.util.FileUtils#createDirectories() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FileStoreStateMachine.java From incubator-ratis with Apache License 2.0 | 5 votes |
@Override public void initialize(RaftServer server, RaftGroupId groupId, RaftStorage raftStorage) throws IOException { super.initialize(server, groupId, raftStorage); this.storage.init(raftStorage); FileUtils.createDirectories(files.getRoot()); }
Example 2
Source File: RaftStorageDirectory.java From incubator-ratis with Apache License 2.0 | 5 votes |
private static void clearDirectory(File dir) throws IOException { if (dir.exists()) { LOG.info(dir + " already exists. Deleting it ..."); FileUtils.deleteFully(dir); } FileUtils.createDirectories(dir); }
Example 3
Source File: RaftStorageDirectory.java From incubator-ratis with Apache License 2.0 | 5 votes |
/** * Check consistency of the storage directory. * * @return state {@link StorageState} of the storage directory */ StorageState analyzeStorage(boolean toLock) throws IOException { Objects.requireNonNull(root, "root directory is null"); String rootPath = root.getCanonicalPath(); try { // check that storage exists if (!root.exists()) { LOG.info("The storage directory " + rootPath + " does not exist. Creating ..."); FileUtils.createDirectories(root); } // or is inaccessible if (!root.isDirectory()) { LOG.warn(rootPath + " is not a directory"); return StorageState.NON_EXISTENT; } if (!Files.isWritable(root.toPath())) { LOG.warn("The storage directory " + rootPath + " is not writable."); return StorageState.NON_EXISTENT; } } catch(SecurityException ex) { LOG.warn("Cannot access storage directory " + rootPath, ex); return StorageState.NON_EXISTENT; } if (toLock) { this.lock(); // lock storage if it exists } // check whether current directory is valid if (hasMetaFile()) { return StorageState.NORMAL; } else { return StorageState.NOT_FORMATTED; } }
Example 4
Source File: FileStoreStateMachine.java From ratis with Apache License 2.0 | 5 votes |
@Override public void initialize(RaftServer server, RaftGroupId groupId, RaftStorage raftStorage) throws IOException { super.initialize(server, groupId, raftStorage); this.storage.init(raftStorage); FileUtils.createDirectories(files.getRoot()); }
Example 5
Source File: RaftStorageDirectory.java From ratis with Apache License 2.0 | 5 votes |
private static void clearDirectory(File dir) throws IOException { if (dir.exists()) { LOG.info(dir + " already exists. Deleting it ..."); FileUtils.deleteFully(dir); } FileUtils.createDirectories(dir); }
Example 6
Source File: RaftStorageDirectory.java From ratis with Apache License 2.0 | 5 votes |
/** * Check consistency of the storage directory. * * @return state {@link StorageState} of the storage directory */ StorageState analyzeStorage(boolean toLock) throws IOException { Objects.requireNonNull(root, "root directory is null"); String rootPath = root.getCanonicalPath(); try { // check that storage exists if (!root.exists()) { LOG.info("The storage directory " + rootPath + " does not exist. Creating ..."); FileUtils.createDirectories(root); } // or is inaccessible if (!root.isDirectory()) { LOG.warn(rootPath + " is not a directory"); return StorageState.NON_EXISTENT; } if (!Files.isWritable(root.toPath())) { LOG.warn("The storage directory " + rootPath + " is not writable."); return StorageState.NON_EXISTENT; } } catch(SecurityException ex) { LOG.warn("Cannot access storage directory " + rootPath, ex); return StorageState.NON_EXISTENT; } if (toLock) { this.lock(); // lock storage if it exists } // check whether current directory is valid if (hasMetaFile()) { return StorageState.NORMAL; } else { return StorageState.NOT_FORMATTED; } }