public static void start(AccumuloConfiguration conf, Property prop) { if (conf.getBoolean(prop)) { if (new File(PROC_MOUNTS).exists()) { try { new FileSystemMonitor(PROC_MOUNTS, 60000); log.info("Filesystem monitor started"); } catch (IOException e) { log.error("Failed to initialize file system monitor", e); } } else { log.info("Not monitoring filesystems, " + PROC_MOUNTS + " does not exists"); } } } }
@Override public void run() { try { checkMounts(procFile); } catch (final Exception e) { Halt.halt(-42, new Runnable() { @Override public void run() { log.error("Exception while checking mount points, halting process", e); } }); } } };
protected void checkMounts(String procFile) throws Exception { List<Mount> mounts = parse(procFile); for (Mount mount : mounts) { if (!readWriteFilesystems.containsKey(mount.mountPoint)) if (mount.options.contains("rw")) readWriteFilesystems.put(mount.mountPoint, true); else if (mount.options.contains("ro")) readWriteFilesystems.put(mount.mountPoint, false); else throw new Exception("Filesystem " + mount + " does not have ro or rw option"); else if (mount.options.contains("ro") && readWriteFilesystems.get(mount.mountPoint)) throw new Exception("Filesystem " + mount.mountPoint + " switched to read only"); } }
SimpleTimer.getInstance(aconf).schedule(contextCleaner, 60000, 60000); FileSystemMonitor.start(aconf, Property.TSERV_MONITOR_FS);
@SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "procFile path not from user input") static List<Mount> parse(String procFile) throws IOException { FileReader fr = new FileReader(procFile); try (BufferedReader br = new BufferedReader(fr)) { return getMountsFromFile(br); } }
FileSystemMonitor.start(getSystemConfiguration(), Property.TSERV_MONITOR_FS);
static List<Mount> parse(String procFile) throws IOException { FileReader fr = new FileReader(procFile); BufferedReader br = new BufferedReader(fr); try { return getMountsFromFile(br); } finally { br.close(); } }
public FileSystemMonitor(final String procFile, long period) throws IOException { List<Mount> mounts = parse(procFile);
@Override public void run() { try { checkMounts(procFile); } catch (final Exception e) { Halt.halt(-42, new Runnable() { public void run() { log.fatal("Exception while checking mount points, halting process", e); } }); } } };
public static void start(AccumuloConfiguration conf, Property prop) { if (conf.getBoolean(prop)) { if (new File(PROC_MOUNTS).exists()) { try { new FileSystemMonitor(PROC_MOUNTS, 60000); log.info("Filesystem monitor started"); } catch (IOException e) { log.error("Failed to initialize file system monitor", e); } } else { log.info("Not monitoring filesystems, " + PROC_MOUNTS + " does not exists"); } } } }
SimpleTimer.getInstance(aconf).schedule(contextCleaner, 60000, 60000); FileSystemMonitor.start(aconf, Property.TSERV_MONITOR_FS);
protected void checkMounts(String procFile) throws Exception { List<Mount> mounts = parse(procFile); for (Mount mount : mounts) { if (!readWriteFilesystems.containsKey(mount.mountPoint)) if (mount.options.contains("rw")) readWriteFilesystems.put(mount.mountPoint, true); else if (mount.options.contains("ro")) readWriteFilesystems.put(mount.mountPoint, false); else throw new Exception("Filesystem " + mount + " does not have ro or rw option"); else if (mount.options.contains("ro") && readWriteFilesystems.get(mount.mountPoint)) throw new Exception("Filesystem " + mount.mountPoint + " switched to read only"); } }
@Override public void run() { try { checkMounts(procFile); } catch (final Exception e) { Halt.halt(-42, new Runnable() { @Override public void run() { log.error("Exception while checking mount points, halting process", e); } }); } } };
public static void start(AccumuloConfiguration conf, Property prop) { if (conf.getBoolean(prop)) { if (new File(PROC_MOUNTS).exists()) { try { new FileSystemMonitor(PROC_MOUNTS, 60000); log.info("Filesystem monitor started"); } catch (IOException e) { log.error("Failed to initialize file system monitor", e); } } else { log.info("Not monitoring filesystems, " + PROC_MOUNTS + " does not exists"); } } } }
protected void checkMounts(String procFile) throws Exception { List<Mount> mounts = parse(procFile); for (Mount mount : mounts) { if (!readWriteFilesystems.containsKey(mount.mountPoint)) if (mount.options.contains("rw")) readWriteFilesystems.put(mount.mountPoint, true); else if (mount.options.contains("ro")) readWriteFilesystems.put(mount.mountPoint, false); else throw new Exception("Filesystem " + mount + " does not have ro or rw option"); else if (mount.options.contains("ro") && readWriteFilesystems.get(mount.mountPoint)) throw new Exception("Filesystem " + mount.mountPoint + " switched to read only"); } }
public FileSystemMonitor(final String procFile, long period) throws IOException { List<Mount> mounts = parse(procFile);
public FileSystemMonitor(final String procFile, long period) throws IOException { List<Mount> mounts = parse(procFile);