@Override public void start() throws Exception { service.scheduleWithFixedDelay(new Runnable() { public void run() { long freeSpace; try { freeSpace = FileSystemUtils.freeSpaceKb(path); if (freeSpace <= diskFullKBActivation) { // run disk full action collectorAction.exec(); } } catch (Throwable t) { LOG.error(t.toString(), t); } } }, initialDelay, frequency, TimeUnit.MILLISECONDS); }
/*** * Determines if the target directory for extraction has sufficient space to store the output of data extraction * @param serverInfoMap * @param targetDirectory * @return True if sufficient space , false otherwise * @throws IOException */ public static boolean checkDiskSpaceInTargetDirectory(Map<String, ServerInfo> serverInfoMap, String targetDirectory) throws IOException { long totalDiskDirSize = getTotalSize(serverInfoMap); long totalSpaceAvailable = FileSystemUtils.freeSpaceKb(targetDirectory); GemFireXDDataExtractorImpl.logInfo("Total size of data to be extracted : " + (double)totalDiskDirSize/1024d + "MB"); GemFireXDDataExtractorImpl.logInfo("Disk space available in the output directory : " + (double)totalSpaceAvailable/1024d + "MB"); if (totalSpaceAvailable < totalDiskDirSize) { if ("n".equalsIgnoreCase(getUserInput())) { return false; } } else { GemFireXDDataExtractorImpl.logInfo("Sufficient disk space to carry out data extraction"); } return true; }
public DiskUsage getFreeDiskspace() { long freeSpace = -1L; try { freeSpace = FileSystemUtils.freeSpaceKb("/"); } catch (IOException e) { models.utils.LogUtils.printLogError("Error in getFreeDiskspace() " + e.getLocalizedMessage()); //e.printStackTrace(); } int gb = 1024*1024; DiskUsage usage = new DiskUsage(); usage.freeSpaceGb = (double)freeSpace/ (double)gb; if(VarUtils.IN_DETAIL_DEBUG){ models.utils.LogUtils.printLogNormal("Free Space:" + usage.freeSpaceGb + " GB"); } currentDiskUsage = usage; return usage; }
public Long getFreeDiskSpace() throws SecurityException, IOException, SearchLibException { try { long l = ClientFactory.INSTANCE.properties.getMaxStorage(); if (l > 0) { l -= ClientCatalog.getInstanceSize(); if (l < 0) l = 0; return l; } if (StartStopListener.OPENSEARCHSERVER_DATA_FILE.getClass() .getDeclaredMethod("getFreeSpace") != null) return StartStopListener.OPENSEARCHSERVER_DATA_FILE .getFreeSpace(); } catch (NoSuchMethodException e) { } return FileSystemUtils .freeSpaceKb(StartStopListener.OPENSEARCHSERVER_DATA_FILE .getAbsolutePath()) * 1000; }
private long getDiskSpace() { try { return FileSystemUtils.freeSpaceKb("/"); } catch (IOException e) { LOG.error(e.toString(), e); return -1L; } }
private String getDiskSpace() { try { return String.valueOf(FileSystemUtils.freeSpaceKb("/")); } catch (IOException e) { LOG.error(e.toString(), e); return "-1"; } }
private long getDiskSpace() { try { return FileSystemUtils.freeSpaceKb(dataDir); } catch (IOException e) { LOG.error(e.toString(), e); return -1L; } }
private String getDiskSpace() { try { return String.valueOf(FileSystemUtils.freeSpaceKb(dataDir)); } catch (IOException e) { LOG.error(e.toString(), e); return "-1"; } }
protected static boolean checkDiskSpaceInTargetDirectory(String targetDirectory) throws IOException { long totalDiskDirSize = getTotalSize(targetDirectory); long totalSpaceAvailable = FileSystemUtils.freeSpaceKb(targetDirectory); GemFireXDDataExtractorImpl.logInfo("Estimated data to be extracted : " + (double)totalDiskDirSize/1024d + "MB"); GemFireXDDataExtractorImpl.logInfo ("Disk space available in the output directory : " + (double)totalSpaceAvailable/1024d + "MB"); if (totalSpaceAvailable < totalDiskDirSize) { if ("n".equalsIgnoreCase(getUserInput())) { return false; } } else { GemFireXDDataExtractorImpl.logInfo("Sufficient disk space to carry out data extraction"); } return true; }
/** * 파일시스템의 크기를 조회한다. * * @param fileSysMntrngVO */ public int selectFileSysMg(FileSysMntrngVO fileSysMntrngVO) { try { FileSystemUtils.freeSpaceKb(""); } catch (IOException e) { throw new RuntimeException(e); } return 0; }
public Long getTotalDiskSpace() throws SecurityException, IOException { try { long l = ClientFactory.INSTANCE.properties.getMaxStorage(); if (l > 0) return l; if (StartStopListener.OPENSEARCHSERVER_DATA_FILE.getClass() .getDeclaredMethod("getTotalSpace") != null) return StartStopListener.OPENSEARCHSERVER_DATA_FILE .getTotalSpace(); } catch (NoSuchMethodException e) { } return FileSystemUtils .freeSpaceKb(StartStopListener.OPENSEARCHSERVER_DATA_FILE .getAbsolutePath()) * 1000; }
/** * @throws Exception */ @SuppressWarnings("deprecation") @Test public void testFileSystemUtils() throws Exception { try { long freeSpace = FileSystemUtils.freeSpace("C:/"); assertTrue(freeSpace > 0); } catch (Exception e) { log.error(e.getCause()); } }
public ModelAndView home(HttpServletRequest request, HttpServletResponse httpServletResponse) { String tenantId = ServletUtils.getSafeParameter(request, "tenantId", ""); String operatorId = ServletUtils.getSafeParameter(request, "operatorId", ""); ModelAndView mav = new ModelAndView("page"); mav.addObject("title", "easyrec :: administration"); mav.addObject("operatorId", operatorId); mav.addObject("tenantId", tenantId); if (Security.isDeveloper(request)) { mav.setViewName("dev/page"); mav.addObject("page", "home"); mav.addObject("operatorCount", operatorDAO.count()); mav.addObject("tenantCount", remoteTenantDAO.count()); mav.addObject("dbName", operatorDAO.getDbName()); mav.addObject("dbUserName", operatorDAO.getDbUserName()); mav.addObject("signedinOperatorId", Security.signedInOperatorId(request)); mav.addObject("heapsize", ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getMax() / (1000000)); mav.addObject("usedmemory", ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getUsed() / (1000000)); int computationTimeInMilliseconds = logEntryDAO.getComputationDurationForDate() * 1000; String computationTime = HumanTime.approximately(computationTimeInMilliseconds); computationTime = computationTime.replaceAll("ms", "@1"); computationTime = computationTime.replaceAll("s", "@2"); computationTime = computationTime.replaceAll("m", "@3"); computationTime = computationTime.replaceAll("h", "@4"); computationTime = computationTime.replaceAll("d", "@5"); computationTime = computationTime.replaceAll("@1", "milliseconds"); computationTime = computationTime.replaceAll("@2", "seconds"); computationTime = computationTime.replaceAll("@3", "minutes"); computationTime = computationTime.replaceAll("@4", "hours"); computationTime = computationTime.replaceAll("@5", "days"); mav.addObject("dailyComputationTime", computationTime); long freeSpace = 0L; try { freeSpace = FileSystemUtils.freeSpaceKb(System.getProperties().getProperty("user.dir")); } catch (IOException e) { logger.error("Could not check free Free Disc Space :" + e.getMessage()); } mav.addObject("freespace", freeSpace / 1048576); return mav; } else { return MessageBlock.createSingle(mav, MSG.NOT_SIGNED_IN, HOME, MSG.ERROR); } }
@Test public void get_available_space_apache_commons () throws IOException { long freeSpace = FileSystemUtils.freeSpaceKb("/"); assertTrue(freeSpace > 0); }