@@ -242,39 +242,31 @@ public NodeEnvironment(Settings settings, Environment environment) throws IOExce
242242 return ;
243243 }
244244 boolean success = false ;
245- NodeLock nodeLock = null ;
246245
247246 try {
248247 sharedDataPath = environment .sharedDataFile ();
249- IOException exception = null ;
250248
251- try {
252- nodeLock = new NodeLock (logger , environment ,
253- dir -> {
254- Files .createDirectories (dir );
255- return true ;
256- });
257- } catch (LockObtainFailedException e ) {
258- // ignore any LockObtainFailedException
259- } catch (IOException e ) {
260- exception = e ;
249+ for (Path path : environment .dataFiles ()) {
250+ Files .createDirectories (resolveNodePath (path ));
261251 }
262252
263- if (nodeLock == null ) {
253+ final NodeLock nodeLock ;
254+ try {
255+ nodeLock = new NodeLock (logger , environment , dir -> true );
256+ } catch (IOException e ) {
264257 final String message = String .format (
265258 Locale .ROOT ,
266- "failed to obtain node locks, tried [%s] with lock id [0] ;" +
259+ "failed to obtain node locks, tried %s ;" +
267260 " maybe these locations are not writable or multiple nodes were started on the same data path?" ,
268261 Arrays .toString (environment .dataFiles ()));
269- throw new IllegalStateException (message , exception );
262+ throw new IllegalStateException (message , e );
270263 }
264+
271265 this .locks = nodeLock .locks ;
272266 this .nodePaths = nodeLock .nodePaths ;
273267 this .nodeMetaData = loadOrCreateNodeMetaData (settings , logger , nodePaths );
274268
275- if (logger .isDebugEnabled ()) {
276- logger .debug ("using node location {}" , Arrays .toString (nodePaths ));
277- }
269+ logger .debug ("using node location {}" , Arrays .toString (nodePaths ));
278270
279271 maybeLogPathDetails ();
280272 maybeLogHeapDetails ();
0 commit comments