test_class.declarator: logger = LoggerFactory.getLogger(MemoryStatusCheckerTest.class)
test_class.modifier: private static final
test_class.original_string: private static final Logger logger = LoggerFactory.getLogger(MemoryStatusCheckerTest.class);
test_class.type: Logger
test_class.var_name: logger
test_class.file: dubbo-common/src/test/java/org/apache/dubbo/common/status/support/MemoryStatusCheckerTest.java
test_class.identifier: MemoryStatusCheckerTest
test_case.body: @Test
      public void test() throws Exception {
          MemoryStatusChecker statusChecker = new MemoryStatusChecker();
          Status status = statusChecker.check();
          assertThat(status.getLevel(), anyOf(is(OK), is(WARN)));
          logger.info("memory status level: " + status.getLevel());
          logger.info("memory status message: " + status.getMessage());
      }
test_case.class_method_signature: MemoryStatusCheckerTest.test()
test_case.full_signature: @Test public void test()
test_case.identifier: test
test_case.invocations: check assertThat getLevel anyOf is is info getLevel info getMessage
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void test()
focal_class.file: dubbo-common/src/main/java/org/apache/dubbo/common/status/support/MemoryStatusChecker.java
focal_class.identifier: MemoryStatusChecker
focal_class.interfaces: implements StatusChecker
focal_class.class_method_signature: MemoryStatusChecker.check()
focal_class.full_signature: @Override public Status check()
focal_class.identifier: check
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: Status
focal_class.signature: Status check()
focal_method.body: @Override
      public Status check() {
          Runtime runtime = Runtime.getRuntime();
          long freeMemory = runtime.freeMemory();
          long totalMemory = runtime.totalMemory();
          long maxMemory = runtime.maxMemory();
          boolean ok = (maxMemory - (totalMemory - freeMemory) > 2048); // Alarm when spare memory < 2M
          String msg = "max:" + (maxMemory / 1024 / 1024) + "M,total:"
                  + (totalMemory / 1024 / 1024) + "M,used:" + ((totalMemory / 1024 / 1024) - (freeMemory / 1024 / 1024)) + "M,free:" + (freeMemory / 1024 / 1024) + "M";
          return new Status(ok ? Status.Level.OK : Status.Level.WARN, msg);
      }
focal_method.class_method_signature: MemoryStatusChecker.check()
focal_method.full_signature: @Override public Status check()
focal_method.identifier: check
focal_method.invocations: getRuntime freeMemory totalMemory maxMemory
focal_method.modifiers: @Override public
focal_method.parameters: ()
focal_method.return: Status
focal_method.signature: Status check()