public AbstractFailStore(File dbPath, boolean needLock) { try { this.dbPath = dbPath; String path = dbPath.getPath(); this.home = path.substring(0, path.indexOf(getName())).concat(getName()); if (needLock) { getLock(dbPath.getPath()); } init(); } catch (Exception e) { throw new RuntimeException(e); } }
public List<FailStore> getDeadFailStores() { File homeDir = new File(home); File[] subFiles = homeDir.listFiles(); List<FailStore> deadFailStores = new ArrayList<FailStore>(); if (subFiles != null && subFiles.length != 0) { for (File subFile : subFiles) { try { if (subFile.isDirectory()) { FileLock tmpLock = new FileLock(subFile.getPath().concat("/").concat(dbLockName)); boolean locked = tmpLock.tryLock(); if (locked) { // 能获得锁,说明这个目录锁对应的节点已经down了 FailStore failStore = getFailStore(subFile); if (failStore != null) { deadFailStores.add(failStore); } tmpLock.release(); } } } catch (Exception e) { // ignore LOGGER.error(e.getMessage(), e); } } } return deadFailStores; }
public List<FailStore> getDeadFailStores() { File homeDir = new File(home); File[] subFiles = homeDir.listFiles(); List<FailStore> deadFailStores = new ArrayList<FailStore>(); if (subFiles != null && subFiles.length != 0) { for (File subFile : subFiles) { try { if (subFile.isDirectory()) { FileLock tmpLock = new FileLock(subFile.getPath().concat("/").concat(dbLockName)); boolean locked = tmpLock.tryLock(); if (locked) { // 能获得锁,说明这个目录锁对应的节点已经down了 FailStore failStore = getFailStore(subFile); if (failStore != null) { deadFailStores.add(failStore); } tmpLock.release(); } } } catch (Exception e) { // ignore LOGGER.error(e.getMessage(), e); } } } return deadFailStores; }
public AbstractFailStore(File dbPath, boolean needLock) { try { this.dbPath = dbPath; String path = dbPath.getPath(); this.home = path.substring(0, path.indexOf(getName())).concat(getName()); if (needLock) { getLock(dbPath.getPath()); } init(); } catch (Exception e) { throw new RuntimeException(e); } }
public List<FailStore> getDeadFailStores() { File homeDir = new File(home); File[] subFiles = homeDir.listFiles(); List<FailStore> deadFailStores = new ArrayList<FailStore>(); if (subFiles != null && subFiles.length != 0) { for (File subFile : subFiles) { try { if (subFile.isDirectory()) { FileLock tmpLock = new FileLock(subFile.getPath().concat("/").concat(dbLockName)); boolean locked = tmpLock.tryLock(); if (locked) { // 能获得锁,说明这个目录锁对应的节点已经down了 FailStore failStore = getFailStore(subFile); if (failStore != null) { deadFailStores.add(failStore); } tmpLock.release(); } } } catch (Exception e) { // ignore LOGGER.error(e.getMessage(), e); } } } return deadFailStores; }
public AbstractFailStore(File dbPath, boolean needLock) { try { this.dbPath = dbPath; String path = dbPath.getPath(); this.home = path.substring(0, path.indexOf(getName())).concat(getName()); if (needLock) { getLock(dbPath.getPath()); } init(); } catch (Exception e) { throw new RuntimeException(e); } }