org.apache.kafka.common.utils.Utils.formatBytes()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(1.6k)|赞(0)|评价(0)|浏览(106)

本文整理了Java中org.apache.kafka.common.utils.Utils.formatBytes()方法的一些代码示例,展示了Utils.formatBytes()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.formatBytes()方法的具体详情如下:
包路径:org.apache.kafka.common.utils.Utils
类名称:Utils
方法名:formatBytes

Utils.formatBytes介绍

[英]Formats a byte number as a human readable String ("3.2 MB")
[中]将字节数格式化为人类可读的字符串(“3.2MB”)

代码示例

代码示例来源:origin: apache/kafka

@Override
public String toString() {
  long allocated = sizeBytes - availableMemory.get();
  return "SimpleMemoryPool{" + Utils.formatBytes(allocated) + "/" + Utils.formatBytes(sizeBytes) + " used}";
}

代码示例来源:origin: apache/kafka

@Override
  public String toString() {
    long allocated = sizeBytes - availableMemory.get();
    return "GarbageCollectedMemoryPool{" + Utils.formatBytes(allocated) + "/" + Utils.formatBytes(sizeBytes) + " used in " + buffersInFlight.size() + " buffers}";
  }
}

代码示例来源:origin: apache/kafka

@Test
public void testFormatBytes() {
  assertEquals("-1", formatBytes(-1));
  assertEquals("1023 B", formatBytes(1023));
  assertEquals("1 KB", formatBytes(1024));
  assertEquals("1024 KB", formatBytes((1024 * 1024) - 1));
  assertEquals("1 MB", formatBytes(1024 * 1024));
  assertEquals("1.1 MB", formatBytes((long) (1.1 * 1024 * 1024)));
  assertEquals("10 MB", formatBytes(10 * 1024 * 1024));
}

代码示例来源:origin: apache/kafka

+ " buffers allocated: " + buffersAllocated + " heap " + Utils.formatBytes(maxHeap)
+ " pool " + Utils.formatBytes(maxPool) + " single allocation "
+ Utils.formatBytes(maxSingleAllocation), success);

相关文章