test_class.declarator: _minFileSize = 10485760L
test_class.modifier: final
test_class.original_string: final long _minFileSize = 10485760L;
test_class.type: long
test_class.var_name: _minFileSize
test_class.file: utils/src/test/java/org/apache/cloudstack/utils/hypervisor/HypervisorUtilsTest.java
test_class.identifier: HypervisorUtilsTest
test_case.body: @Test
      public void checkVolumeFileForActivitySmallFileTest() throws IOException {
          System.out.print("Testing don't block on newly created clones - ");
          String filePath = "./testsmallfileinactive";
          int timeoutSeconds = 5;
          long thresholdMilliseconds = 2000;
          File file = new File(filePath);
  
          long startTime = setupcheckVolumeFileForActivityFile(file, 0);
          HypervisorUtils.checkVolumeFileForActivity(filePath, timeoutSeconds, thresholdMilliseconds, _minFileSize);
          long endTime = System.currentTimeMillis();
  
          Assert.assertEquals(startTime, endTime, 1000L);
          System.out.println("pass");
  
          file.delete();
      }
test_case.class_method_signature: HypervisorUtilsTest.checkVolumeFileForActivitySmallFileTest()
test_case.full_signature: @Test public void checkVolumeFileForActivitySmallFileTest()
test_case.identifier: checkVolumeFileForActivitySmallFileTest
test_case.invocations: print setupcheckVolumeFileForActivityFile checkVolumeFileForActivity currentTimeMillis assertEquals println delete
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void checkVolumeFileForActivitySmallFileTest()
focal_class.declarator: s_logger = LoggerFactory.getLogger(HypervisorUtils.class)
focal_class.modifier: public static final
focal_class.original_string: public static final Logger s_logger = LoggerFactory.getLogger(HypervisorUtils.class);
focal_class.type: Logger
focal_class.var_name: s_logger
focal_class.file: utils/src/main/java/org/apache/cloudstack/utils/hypervisor/HypervisorUtils.java
focal_class.identifier: HypervisorUtils
focal_class.class_method_signature: HypervisorUtils.checkVolumeFileForActivity(final String filePath, int timeoutSeconds, long inactiveThresholdMilliseconds, long minimumFileSize)
focal_class.full_signature: public static void checkVolumeFileForActivity(final String filePath, int timeoutSeconds, long inactiveThresholdMilliseconds, long minimumFileSize)
focal_class.identifier: checkVolumeFileForActivity
focal_class.modifiers: public static
focal_class.parameters: (final String filePath, int timeoutSeconds, long inactiveThresholdMilliseconds, long minimumFileSize)
focal_class.return: void
focal_class.signature: void checkVolumeFileForActivity(final String filePath, int timeoutSeconds, long inactiveThresholdMilliseconds, long minimumFileSize)
focal_method.body: public static void checkVolumeFileForActivity(final String filePath, int timeoutSeconds, long inactiveThresholdMilliseconds, long minimumFileSize) throws IOException {
          File file = new File(filePath);
          if (!file.exists()) {
              throw new CloudRuntimeException("File " + file.getAbsolutePath() + " not found");
          }
          if (file.length() < minimumFileSize) {
              s_logger.debug("VM disk file too small, fresh clone? skipping modify check");
              return;
          }
          int waitedSeconds = 0;
          int intervalSeconds = 1;
          while (true) {
              BasicFileAttributes attrs = Files.readAttributes(file.toPath(), BasicFileAttributes.class);
              long modifyIdle = System.currentTimeMillis() - attrs.lastModifiedTime().toMillis();
              long accessIdle = System.currentTimeMillis() - attrs.lastAccessTime().toMillis();
              if (modifyIdle > inactiveThresholdMilliseconds && accessIdle > inactiveThresholdMilliseconds) {
                  s_logger.debug("File " + filePath + " has not been accessed or modified for at least " + inactiveThresholdMilliseconds + " ms");
                  return;
              } else {
                  s_logger.debug("File was modified " + modifyIdle + "ms ago, accessed " + accessIdle + "ms ago, waiting for inactivity threshold of "
                          + inactiveThresholdMilliseconds + "ms or timeout of " + timeoutSeconds + "s (waited " + waitedSeconds + "s)");
              }
              try {
                  TimeUnit.SECONDS.sleep(intervalSeconds);
              } catch (InterruptedException ex) {
                  throw new CloudRuntimeException("Interrupted while waiting for activity on " + filePath + " to subside", ex);
              }
              waitedSeconds += intervalSeconds;
              if (waitedSeconds >= timeoutSeconds) {
                  throw new CloudRuntimeException("Reached timeout while waiting for activity on " + filePath + " to subside");
              }
          }
      }
focal_method.class_method_signature: HypervisorUtils.checkVolumeFileForActivity(final String filePath, int timeoutSeconds, long inactiveThresholdMilliseconds, long minimumFileSize)
focal_method.full_signature: public static void checkVolumeFileForActivity(final String filePath, int timeoutSeconds, long inactiveThresholdMilliseconds, long minimumFileSize)
focal_method.identifier: checkVolumeFileForActivity
focal_method.invocations: exists getAbsolutePath length debug readAttributes toPath currentTimeMillis toMillis lastModifiedTime currentTimeMillis toMillis lastAccessTime debug debug sleep
focal_method.modifiers: public static
focal_method.parameters: (final String filePath, int timeoutSeconds, long inactiveThresholdMilliseconds, long minimumFileSize)
focal_method.return: void
focal_method.signature: void checkVolumeFileForActivity(final String filePath, int timeoutSeconds, long inactiveThresholdMilliseconds, long minimumFileSize)