feat: 大规模扩充至212个模块/175K行代码 — 覆盖android/java/javax/org/dalvik全包
- android/ 167个模块 (app/content/os/view/widget/graphics/media/hardware/net/telephony/provider等) - java/ 35个模块 (lang/io/util/net/nio/security/crypto/sql/beans/rmi/awt等) - javax/ 4个模块 (net/crypto/security/sql) - org/ 5个模块 (json/w3c_dom/xml_sax/xml_pull/apache_http) - dalvik/ 1个模块 (system) - ~3053个类/接口,方法签名完全对齐Android SDK - 桌面跨平台运行 (Windows/macOS/Linux) - 修复所有导入错误和Python关键字冲突
This commit is contained in:
1 parent
506f9ac725
commit
a51854455b
128 files changed
+100571
-3
No files matched your search
@@ -0,0 +1,830 @@
|
||||
"""
|
||||
Java java.lang.management standard library APIs implemented in Python.
|
||||
java.lang.management package - ManagementFactory, MXBeans, ThreadInfo, etc.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from .._core import Stub
|
||||
from ..java.lang import RuntimeException, StackTraceElement
|
||||
import typing as _typing
|
||||
import time as _time
|
||||
import os as _os
|
||||
import sys as _sys
|
||||
import threading as _threading
|
||||
import platform as _platform
|
||||
|
||||
__all__ = [
|
||||
"ManagementFactory", "MemoryMXBean", "MemoryUsage", "MemoryType",
|
||||
"MemoryPoolMXBean", "MemoryManagerMXBean", "GarbageCollectorMXBean",
|
||||
"ThreadMXBean", "RuntimeMXBean", "ClassLoadingMXBean",
|
||||
"OperatingSystemMXBean", "CompilationMXBean",
|
||||
"PlatformLoggingMXBean", "PlatformManagedObject",
|
||||
"ManagementPermission", "LockInfo", "MonitorInfo", "ThreadInfo",
|
||||
]
|
||||
|
||||
|
||||
# ============================================================
|
||||
# ManagementPermission
|
||||
# ============================================================
|
||||
|
||||
class ManagementPermission(Stub):
|
||||
"""java.lang.management.ManagementPermission"""
|
||||
def __init__(self, name, actions=None):
|
||||
super().__init__()
|
||||
self._name = name
|
||||
self._actions = actions
|
||||
|
||||
def getName(self):
|
||||
return self._name
|
||||
|
||||
def getActions(self):
|
||||
return self._actions or ""
|
||||
|
||||
def implies(self, permission):
|
||||
return True
|
||||
|
||||
|
||||
# ============================================================
|
||||
# MemoryType
|
||||
# ============================================================
|
||||
|
||||
class MemoryType(Stub):
|
||||
"""java.lang.management.MemoryType"""
|
||||
def __init__(self, name):
|
||||
super().__init__()
|
||||
self._name = name
|
||||
|
||||
def toString(self):
|
||||
return self._name
|
||||
|
||||
HEAP = None
|
||||
NON_HEAP = None
|
||||
|
||||
|
||||
MemoryType.HEAP = MemoryType("HEAP")
|
||||
MemoryType.NON_HEAP = MemoryType("NON_HEAP")
|
||||
|
||||
|
||||
# ============================================================
|
||||
# MemoryUsage
|
||||
# ============================================================
|
||||
|
||||
class MemoryUsage(Stub):
|
||||
"""java.lang.management.MemoryUsage"""
|
||||
def __init__(self, init, used, committed, max_val):
|
||||
super().__init__()
|
||||
self._init = init
|
||||
self._used = used
|
||||
self._committed = committed
|
||||
self._max = max_val
|
||||
|
||||
def getInit(self):
|
||||
return self._init
|
||||
|
||||
def getUsed(self):
|
||||
return self._used
|
||||
|
||||
def getCommitted(self):
|
||||
return self._committed
|
||||
|
||||
def getMax(self):
|
||||
return self._max
|
||||
|
||||
def toString(self):
|
||||
return (f"init={self._init} used={self._used} "
|
||||
f"committed={self._committed} max={self._max}")
|
||||
|
||||
|
||||
# ============================================================
|
||||
# LockInfo
|
||||
# ============================================================
|
||||
|
||||
class LockInfo(Stub):
|
||||
"""java.lang.management.LockInfo"""
|
||||
def __init__(self, class_name, identity_hash_code):
|
||||
super().__init__()
|
||||
self._class_name = class_name
|
||||
self._identity_hash_code = identity_hash_code
|
||||
|
||||
def getClassName(self):
|
||||
return self._class_name
|
||||
|
||||
def getIdentityHashCode(self):
|
||||
return self._identity_hash_code
|
||||
|
||||
def toString(self):
|
||||
return f"{self._class_name}@{self._identity_hash_code:x}"
|
||||
|
||||
|
||||
# ============================================================
|
||||
# MonitorInfo
|
||||
# ============================================================
|
||||
|
||||
class MonitorInfo(LockInfo):
|
||||
"""java.lang.management.MonitorInfo"""
|
||||
def __init__(self, class_name, identity_hash_code,
|
||||
locked_stack_depth, locked_stack_frame):
|
||||
super().__init__(class_name, identity_hash_code)
|
||||
self._locked_stack_depth = locked_stack_depth
|
||||
self._locked_stack_frame = locked_stack_frame
|
||||
|
||||
def getLockedStackDepth(self):
|
||||
return self._locked_stack_depth
|
||||
|
||||
def getLockedStackFrame(self):
|
||||
return self._locked_stack_frame
|
||||
|
||||
def toString(self):
|
||||
return (f"MonitorInfo[{self._class_name}@{self._identity_hash_code:x}, "
|
||||
f"depth={self._locked_stack_depth}]")
|
||||
|
||||
|
||||
# ============================================================
|
||||
# ThreadInfo
|
||||
# ============================================================
|
||||
|
||||
class ThreadInfo(Stub):
|
||||
"""java.lang.management.ThreadInfo"""
|
||||
def __init__(self, thread_id=0, thread_name="", thread_state="RUNNABLE",
|
||||
blocked_count=0, blocked_time=-1, waited_count=0, waited_time=-1,
|
||||
lock_name=None, lock_owner_id=-1, lock_owner_name=None,
|
||||
in_native=False, suspended=False, stack_trace=None,
|
||||
locked_monitors=None, locked_synchronizers=None,
|
||||
daemon=False, priority=5):
|
||||
super().__init__()
|
||||
self._thread_id = thread_id
|
||||
self._thread_name = thread_name
|
||||
self._thread_state = thread_state
|
||||
self._blocked_count = blocked_count
|
||||
self._blocked_time = blocked_time
|
||||
self._waited_count = waited_count
|
||||
self._waited_time = waited_time
|
||||
self._lock_name = lock_name
|
||||
self._lock_owner_id = lock_owner_id
|
||||
self._lock_owner_name = lock_owner_name
|
||||
self._in_native = in_native
|
||||
self._suspended = suspended
|
||||
self._stack_trace = stack_trace or []
|
||||
self._locked_monitors = locked_monitors or []
|
||||
self._locked_synchronizers = locked_synchronizers or []
|
||||
self._daemon = daemon
|
||||
self._priority = priority
|
||||
|
||||
def getThreadId(self):
|
||||
return self._thread_id
|
||||
|
||||
def getThreadName(self):
|
||||
return self._thread_name
|
||||
|
||||
def getThreadState(self):
|
||||
return self._thread_state
|
||||
|
||||
def getBlockedCount(self):
|
||||
return self._blocked_count
|
||||
|
||||
def getBlockedTime(self):
|
||||
return self._blocked_time
|
||||
|
||||
def getWaitedCount(self):
|
||||
return self._waited_count
|
||||
|
||||
def getWaitedTime(self):
|
||||
return self._waited_time
|
||||
|
||||
def getLockName(self):
|
||||
return self._lock_name
|
||||
|
||||
def getLockOwnerId(self):
|
||||
return self._lock_owner_id
|
||||
|
||||
def getLockOwnerName(self):
|
||||
return self._lock_owner_name
|
||||
|
||||
def isInNative(self):
|
||||
return self._in_native
|
||||
|
||||
def isSuspended(self):
|
||||
return self._suspended
|
||||
|
||||
def getStackTrace(self):
|
||||
return self._stack_trace
|
||||
|
||||
def getLockedMonitors(self):
|
||||
return self._locked_monitors
|
||||
|
||||
def getLockedSynchronizers(self):
|
||||
return self._locked_synchronizers
|
||||
|
||||
def isDaemon(self):
|
||||
return self._daemon
|
||||
|
||||
def getPriority(self):
|
||||
return self._priority
|
||||
|
||||
def toString(self):
|
||||
return (f"ThreadInfo[id={self._thread_id}, name={self._thread_name}, "
|
||||
f"state={self._thread_state}]")
|
||||
|
||||
|
||||
# ============================================================
|
||||
# PlatformManagedObject
|
||||
# ============================================================
|
||||
|
||||
class PlatformManagedObject(Stub):
|
||||
"""java.lang.management.PlatformManagedObject"""
|
||||
def getObjectName(self):
|
||||
return None
|
||||
|
||||
|
||||
# ============================================================
|
||||
# MemoryMXBean
|
||||
# ============================================================
|
||||
|
||||
class MemoryMXBean(PlatformManagedObject):
|
||||
"""java.lang.management.MemoryMXBean"""
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
import psutil as _psutil
|
||||
self._psutil_available = False
|
||||
try:
|
||||
import psutil
|
||||
self._psutil = psutil
|
||||
self._psutil_available = True
|
||||
except ImportError:
|
||||
self._psutil_available = False
|
||||
|
||||
def getHeapMemoryUsage(self):
|
||||
if self._psutil_available:
|
||||
mem = self._psutil.virtual_memory()
|
||||
return MemoryUsage(mem.total, mem.used, mem.available, mem.total)
|
||||
return MemoryUsage(0, 0, 0, 0)
|
||||
|
||||
def getNonHeapMemoryUsage(self):
|
||||
return MemoryUsage(0, 0, 0, 0)
|
||||
|
||||
def getObjectPendingFinalizationCount(self):
|
||||
return 0
|
||||
|
||||
def isVerbose(self):
|
||||
return False
|
||||
|
||||
def setVerbose(self, value):
|
||||
pass
|
||||
|
||||
def gc(self):
|
||||
import gc
|
||||
gc.collect()
|
||||
|
||||
|
||||
# ============================================================
|
||||
# MemoryPoolMXBean
|
||||
# ============================================================
|
||||
|
||||
class MemoryPoolMXBean(PlatformManagedObject):
|
||||
"""java.lang.management.MemoryPoolMXBean"""
|
||||
def __init__(self, name="", pool_type=MemoryType.HEAP):
|
||||
super().__init__()
|
||||
self._name = name
|
||||
self._type = pool_type
|
||||
self._usage = MemoryUsage(0, 0, 0, 0)
|
||||
self._peak_usage = MemoryUsage(0, 0, 0, 0)
|
||||
self._collection_usage = None
|
||||
self._valid = True
|
||||
self._threshold = 0
|
||||
self._collection_threshold = 0
|
||||
self._threshold_supported = False
|
||||
self._collection_threshold_supported = False
|
||||
|
||||
def getName(self):
|
||||
return self._name
|
||||
|
||||
def getType(self):
|
||||
return self._type
|
||||
|
||||
def getUsage(self):
|
||||
import psutil
|
||||
try:
|
||||
mem = psutil.virtual_memory()
|
||||
self._usage = MemoryUsage(mem.total, mem.used, mem.available, mem.total)
|
||||
except ImportError:
|
||||
pass
|
||||
return self._usage
|
||||
|
||||
def getPeakUsage(self):
|
||||
return self._peak_usage
|
||||
|
||||
def resetPeakUsage(self):
|
||||
self._peak_usage = MemoryUsage(0, 0, 0, 0)
|
||||
|
||||
def isValid(self):
|
||||
return self._valid
|
||||
|
||||
def getCollectionUsage(self):
|
||||
return self._collection_usage
|
||||
|
||||
def getUsageThreshold(self):
|
||||
return self._threshold
|
||||
|
||||
def setUsageThreshold(self, threshold):
|
||||
self._threshold = threshold
|
||||
self._threshold_supported = True
|
||||
|
||||
def isUsageThresholdSupported(self):
|
||||
return self._threshold_supported
|
||||
|
||||
def isUsageThresholdExceeded(self):
|
||||
return self._usage.getUsed() > self._threshold if self._threshold > 0 else False
|
||||
|
||||
def getUsageThresholdCount(self):
|
||||
return 0
|
||||
|
||||
def getCollectionUsageThreshold(self):
|
||||
return self._collection_threshold
|
||||
|
||||
def setCollectionUsageThreshold(self, threshold):
|
||||
self._collection_threshold = threshold
|
||||
self._collection_threshold_supported = True
|
||||
|
||||
def isCollectionUsageThresholdSupported(self):
|
||||
return self._collection_threshold_supported
|
||||
|
||||
def isCollectionUsageThresholdExceeded(self):
|
||||
return False
|
||||
|
||||
def getCollectionUsageThresholdCount(self):
|
||||
return 0
|
||||
|
||||
def getMemoryManagerNames(self):
|
||||
return []
|
||||
|
||||
def toString(self):
|
||||
return f"MemoryPoolMXBean[name={self._name}, type={self._type}]"
|
||||
|
||||
|
||||
# ============================================================
|
||||
# MemoryManagerMXBean
|
||||
# ============================================================
|
||||
|
||||
class MemoryManagerMXBean(PlatformManagedObject):
|
||||
"""java.lang.management.MemoryManagerMXBean"""
|
||||
def __init__(self, name=""):
|
||||
super().__init__()
|
||||
self._name = name
|
||||
self._valid = True
|
||||
self._pool_names = []
|
||||
|
||||
def getName(self):
|
||||
return self._name
|
||||
|
||||
def isValid(self):
|
||||
return self._valid
|
||||
|
||||
def getMemoryPoolNames(self):
|
||||
return self._pool_names
|
||||
|
||||
def toString(self):
|
||||
return f"MemoryManagerMXBean[name={self._name}]"
|
||||
|
||||
|
||||
# ============================================================
|
||||
# GarbageCollectorMXBean
|
||||
# ============================================================
|
||||
|
||||
class GarbageCollectorMXBean(MemoryManagerMXBean):
|
||||
"""java.lang.management.GarbageCollectorMXBean"""
|
||||
def __init__(self, name=""):
|
||||
super().__init__(name)
|
||||
self._collection_count = 0
|
||||
self._collection_time = 0
|
||||
|
||||
def getCollectionCount(self):
|
||||
return self._collection_count
|
||||
|
||||
def getCollectionTime(self):
|
||||
return self._collection_time
|
||||
|
||||
def toString(self):
|
||||
return (f"GarbageCollectorMXBean[name={self._name}, "
|
||||
f"collections={self._collection_count}, "
|
||||
f"time={self._collection_time}ms]")
|
||||
|
||||
|
||||
# ============================================================
|
||||
# ThreadMXBean
|
||||
# ============================================================
|
||||
|
||||
class ThreadMXBean(PlatformManagedObject):
|
||||
"""java.lang.management.ThreadMXBean"""
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self._thread_contention_monitoring_enabled = False
|
||||
self._thread_cpu_time_enabled = False
|
||||
self._thread_allocated_memory_enabled = False
|
||||
|
||||
def getThreadCount(self):
|
||||
return _threading.active_count()
|
||||
|
||||
def getPeakThreadCount(self):
|
||||
return _threading.active_count()
|
||||
|
||||
def getTotalStartedThreadCount(self):
|
||||
return _threading.active_count()
|
||||
|
||||
def getDaemonThreadCount(self):
|
||||
return 0
|
||||
|
||||
def getAllThreadIds(self):
|
||||
return [t.ident for t in _threading.enumerate() if t.ident is not None]
|
||||
|
||||
def getThreadInfo(self, thread_id_or_ids, max_depth=None):
|
||||
if isinstance(thread_id_or_ids, (list, tuple)):
|
||||
return [self._build_thread_info(tid) for tid in thread_id_or_ids]
|
||||
return self._build_thread_info(thread_id_or_ids)
|
||||
|
||||
def _build_thread_info(self, thread_id):
|
||||
for t in _threading.enumerate():
|
||||
if t.ident == thread_id:
|
||||
return ThreadInfo(
|
||||
thread_id=thread_id,
|
||||
thread_name=t.name or "",
|
||||
thread_state=t.name or "RUNNABLE",
|
||||
)
|
||||
return ThreadInfo(thread_id=thread_id, thread_name="")
|
||||
|
||||
def isThreadContentionMonitoringSupported(self):
|
||||
return True
|
||||
|
||||
def isThreadContentionMonitoringEnabled(self):
|
||||
return self._thread_contention_monitoring_enabled
|
||||
|
||||
def setThreadContentionMonitoringEnabled(self, enable):
|
||||
self._thread_contention_monitoring_enabled = enable
|
||||
|
||||
def isCurrentThreadCpuTimeSupported(self):
|
||||
return True
|
||||
|
||||
def isThreadCpuTimeEnabled(self):
|
||||
return self._thread_cpu_time_enabled
|
||||
|
||||
def setThreadCpuTimeEnabled(self, enable):
|
||||
self._thread_cpu_time_enabled = enable
|
||||
|
||||
def getCurrentThreadCpuTime(self):
|
||||
return 0
|
||||
|
||||
def getCurrentThreadUserTime(self):
|
||||
return 0
|
||||
|
||||
def getThreadCpuTime(self, thread_id):
|
||||
return 0
|
||||
|
||||
def getThreadUserTime(self, thread_id):
|
||||
return 0
|
||||
|
||||
def isObjectMonitorUsageSupported(self):
|
||||
return True
|
||||
|
||||
def isSynchronizerUsageSupported(self):
|
||||
return True
|
||||
|
||||
def findMonitorDeadlockedThreads(self):
|
||||
return None
|
||||
|
||||
def findDeadlockedThreads(self):
|
||||
return None
|
||||
|
||||
def resetPeakThreadCount(self):
|
||||
pass
|
||||
|
||||
def getThreadAllocatedBytes(self, thread_id_or_ids):
|
||||
if isinstance(thread_id_or_ids, (list, tuple)):
|
||||
return [0] * len(thread_id_or_ids)
|
||||
return 0
|
||||
|
||||
def isThreadAllocatedMemorySupported(self):
|
||||
return True
|
||||
|
||||
def isThreadAllocatedMemoryEnabled(self):
|
||||
return self._thread_allocated_memory_enabled
|
||||
|
||||
def setThreadAllocatedMemoryEnabled(self, enable):
|
||||
self._thread_allocated_memory_enabled = enable
|
||||
|
||||
def getTotalThreadAllocatedBytes(self):
|
||||
return 0
|
||||
|
||||
|
||||
# ============================================================
|
||||
# RuntimeMXBean
|
||||
# ============================================================
|
||||
|
||||
class RuntimeMXBean(PlatformManagedObject):
|
||||
"""java.lang.management.RuntimeMXBean"""
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self._start_time = _time.time() * 1000
|
||||
|
||||
def getName(self):
|
||||
return f"{_os.getpid()}@{_platform.node()}"
|
||||
|
||||
getVmName = lambda self: _platform.python_implementation()
|
||||
getVmVersion = lambda self: _platform.python_version()
|
||||
getVmVendor = lambda self: "Python Software Foundation"
|
||||
getSpecName = lambda self: "Python Virtual Machine Specification"
|
||||
getSpecVersion = lambda self: _sys.version
|
||||
getSpecVendor = lambda self: "Python Software Foundation"
|
||||
|
||||
def getManagementSpecVersion(self):
|
||||
return "1.0"
|
||||
|
||||
def getStartTime(self):
|
||||
return self._start_time
|
||||
|
||||
def getUptime(self):
|
||||
return (_time.time() * 1000) - self._start_time
|
||||
|
||||
def getInputArguments(self):
|
||||
return _sys.argv[1:]
|
||||
|
||||
def getClassPath(self):
|
||||
return _sys.path
|
||||
|
||||
def getBootClassPath(self):
|
||||
return ""
|
||||
|
||||
def getLibraryPath(self):
|
||||
return _os.environ.get("PATH", "")
|
||||
|
||||
def getSystemProperties(self):
|
||||
return {
|
||||
"java.version": _platform.python_version(),
|
||||
"java.vendor": "Python",
|
||||
"java.vm.version": _platform.python_version(),
|
||||
"os.name": _platform.system(),
|
||||
"os.arch": _platform.machine(),
|
||||
"os.version": _platform.release(),
|
||||
"user.dir": _os.getcwd(),
|
||||
"user.home": _os.path.expanduser("~"),
|
||||
"user.name": _os.environ.get("USER", ""),
|
||||
"line.separator": "\n",
|
||||
"file.separator": _os.sep,
|
||||
"path.separator": _os.pathsep,
|
||||
}
|
||||
|
||||
def isBootClassPathSupported(self):
|
||||
return False
|
||||
|
||||
|
||||
# ============================================================
|
||||
# ClassLoadingMXBean
|
||||
# ============================================================
|
||||
|
||||
class ClassLoadingMXBean(PlatformManagedObject):
|
||||
"""java.lang.management.ClassLoadingMXBean"""
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self._verbose = False
|
||||
|
||||
def getTotalLoadedClassCount(self):
|
||||
return 0
|
||||
|
||||
def getLoadedClassCount(self):
|
||||
return 0
|
||||
|
||||
def getUnloadedClassCount(self):
|
||||
return 0
|
||||
|
||||
def isVerbose(self):
|
||||
return self._verbose
|
||||
|
||||
def setVerbose(self, value):
|
||||
self._verbose = value
|
||||
|
||||
|
||||
# ============================================================
|
||||
# OperatingSystemMXBean
|
||||
# ============================================================
|
||||
|
||||
class OperatingSystemMXBean(PlatformManagedObject):
|
||||
"""java.lang.management.OperatingSystemMXBean"""
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self._available = False
|
||||
try:
|
||||
import psutil
|
||||
self._psutil = psutil
|
||||
self._available = True
|
||||
except ImportError:
|
||||
self._available = False
|
||||
|
||||
def getArch(self):
|
||||
return _platform.machine()
|
||||
|
||||
def getAvailableProcessors(self):
|
||||
return _os.cpu_count() or 1
|
||||
|
||||
def getSystemLoadAverage(self):
|
||||
if self._available:
|
||||
return self._psutil.getloadavg()[0]
|
||||
return -1.0
|
||||
|
||||
def getName(self):
|
||||
return _platform.system()
|
||||
|
||||
def getVersion(self):
|
||||
return _platform.release()
|
||||
|
||||
def getProcessCpuTime(self):
|
||||
return 0
|
||||
|
||||
def getCommittedVirtualMemorySize(self):
|
||||
return 0
|
||||
|
||||
def getTotalSwapSpaceSize(self):
|
||||
if self._available:
|
||||
return self._psutil.swap_memory().total
|
||||
return 0
|
||||
|
||||
def getFreeSwapSpaceSize(self):
|
||||
if self._available:
|
||||
return self._psutil.swap_memory().free
|
||||
return 0
|
||||
|
||||
def getProcessCpuLoad(self):
|
||||
return 0.0
|
||||
|
||||
def getSystemCpuLoad(self):
|
||||
if self._available:
|
||||
return self._psutil.cpu_percent(interval=0) / 100.0
|
||||
return 0.0
|
||||
|
||||
def getTotalPhysicalMemorySize(self):
|
||||
if self._available:
|
||||
return self._psutil.virtual_memory().total
|
||||
return 0
|
||||
|
||||
def getFreePhysicalMemorySize(self):
|
||||
if self._available:
|
||||
return self._psutil.virtual_memory().available
|
||||
return 0
|
||||
|
||||
def getTotalDiskSpace(self):
|
||||
return 0
|
||||
|
||||
def getFreeDiskSpace(self):
|
||||
return 0
|
||||
|
||||
def getSystemUptime(self):
|
||||
return _time.time() - _time.monotonic() + _time.monotonic()
|
||||
|
||||
|
||||
# ============================================================
|
||||
# CompilationMXBean
|
||||
# ============================================================
|
||||
|
||||
class CompilationMXBean(PlatformManagedObject):
|
||||
"""java.lang.management.CompilationMXBean"""
|
||||
def getName(self):
|
||||
return "CPython"
|
||||
|
||||
def isCompilationTimeMonitoringSupported(self):
|
||||
return False
|
||||
|
||||
def getTotalCompilationTime(self):
|
||||
return 0
|
||||
|
||||
|
||||
# ============================================================
|
||||
# PlatformLoggingMXBean
|
||||
# ============================================================
|
||||
|
||||
class PlatformLoggingMXBean(PlatformManagedObject):
|
||||
"""java.lang.management.PlatformLoggingMXBean"""
|
||||
def getLoggerLevel(self, logger_name):
|
||||
return ""
|
||||
|
||||
def setLoggerLevel(self, logger_name, level_name):
|
||||
pass
|
||||
|
||||
def getParentLogger(self, logger_name):
|
||||
return ""
|
||||
|
||||
def getLoggerNames(self):
|
||||
return []
|
||||
|
||||
|
||||
# ============================================================
|
||||
# ManagementFactory
|
||||
# ============================================================
|
||||
|
||||
class ManagementFactory(Stub):
|
||||
"""java.lang.management.ManagementFactory"""
|
||||
CLASS_LOADING_MXBEAN_NAME = "java.lang:type=ClassLoading"
|
||||
COMPILATION_MXBEAN_NAME = "java.lang:type=Compilation"
|
||||
GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE = "java.lang:type=GarbageCollector"
|
||||
MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE = "java.lang:type=MemoryManager"
|
||||
MEMORY_MXBEAN_NAME = "java.lang:type=Memory"
|
||||
MEMORY_POOL_MXBEAN_DOMAIN_TYPE = "java.lang:type=MemoryPool"
|
||||
OPERATING_SYSTEM_MXBEAN_NAME = "java.lang:type=OperatingSystem"
|
||||
RUNTIME_MXBEAN_NAME = "java.lang:type=Runtime"
|
||||
THREAD_MXBEAN_NAME = "java.lang:type=Threading"
|
||||
LOGGING_MXBEAN_NAME = "java.util.logging:type=Logging"
|
||||
|
||||
_memory_mxbean = None
|
||||
_runtime_mxbean = None
|
||||
_thread_mxbean = None
|
||||
_class_loading_mxbean = None
|
||||
_os_mxbean = None
|
||||
_compilation_mxbean = None
|
||||
_platform_logging_mxbean = None
|
||||
_memory_pools = None
|
||||
_memory_managers = None
|
||||
_gc_mxbeans = None
|
||||
|
||||
@staticmethod
|
||||
def getMemoryMXBean():
|
||||
if ManagementFactory._memory_mxbean is None:
|
||||
ManagementFactory._memory_mxbean = MemoryMXBean()
|
||||
return ManagementFactory._memory_mxbean
|
||||
|
||||
@staticmethod
|
||||
def getRuntimeMXBean():
|
||||
if ManagementFactory._runtime_mxbean is None:
|
||||
ManagementFactory._runtime_mxbean = RuntimeMXBean()
|
||||
return ManagementFactory._runtime_mxbean
|
||||
|
||||
@staticmethod
|
||||
def getThreadMXBean():
|
||||
if ManagementFactory._thread_mxbean is None:
|
||||
ManagementFactory._thread_mxbean = ThreadMXBean()
|
||||
return ManagementFactory._thread_mxbean
|
||||
|
||||
@staticmethod
|
||||
def getClassLoadingMXBean():
|
||||
if ManagementFactory._class_loading_mxbean is None:
|
||||
ManagementFactory._class_loading_mxbean = ClassLoadingMXBean()
|
||||
return ManagementFactory._class_loading_mxbean
|
||||
|
||||
@staticmethod
|
||||
def getOperatingSystemMXBean():
|
||||
if ManagementFactory._os_mxbean is None:
|
||||
ManagementFactory._os_mxbean = OperatingSystemMXBean()
|
||||
return ManagementFactory._os_mxbean
|
||||
|
||||
@staticmethod
|
||||
def getCompilationMXBean():
|
||||
if ManagementFactory._compilation_mxbean is None:
|
||||
ManagementFactory._compilation_mxbean = CompilationMXBean()
|
||||
return ManagementFactory._compilation_mxbean
|
||||
|
||||
@staticmethod
|
||||
def getPlatformLoggingMXBean():
|
||||
if ManagementFactory._platform_logging_mxbean is None:
|
||||
ManagementFactory._platform_logging_mxbean = PlatformLoggingMXBean()
|
||||
return ManagementFactory._platform_logging_mxbean
|
||||
|
||||
@staticmethod
|
||||
def getMemoryPoolMXBeans():
|
||||
if ManagementFactory._memory_pools is None:
|
||||
ManagementFactory._memory_pools = [
|
||||
MemoryPoolMXBean("Code Cache", MemoryType.NON_HEAP),
|
||||
MemoryPoolMXBean("Metaspace", MemoryType.NON_HEAP),
|
||||
MemoryPoolMXBean("Compressed Class Space", MemoryType.NON_HEAP),
|
||||
MemoryPoolMXBean("PS Eden Space", MemoryType.HEAP),
|
||||
MemoryPoolMXBean("PS Survivor Space", MemoryType.HEAP),
|
||||
MemoryPoolMXBean("PS Old Gen", MemoryType.HEAP),
|
||||
]
|
||||
return ManagementFactory._memory_pools
|
||||
|
||||
@staticmethod
|
||||
def getMemoryManagerMXBeans():
|
||||
if ManagementFactory._memory_managers is None:
|
||||
ManagementFactory._memory_managers = [
|
||||
MemoryManagerMXBean("CodeCacheManager"),
|
||||
MemoryManagerMXBean("Metaspace Manager"),
|
||||
MemoryManagerMXBean("PS Scavenge"),
|
||||
MemoryManagerMXBean("PS MarkSweep"),
|
||||
]
|
||||
return ManagementFactory._memory_managers
|
||||
|
||||
@staticmethod
|
||||
def getGarbageCollectorMXBeans():
|
||||
if ManagementFactory._gc_mxbeans is None:
|
||||
ManagementFactory._gc_mxbeans = [
|
||||
GarbageCollectorMXBean("PS Scavenge"),
|
||||
GarbageCollectorMXBean("PS MarkSweep"),
|
||||
]
|
||||
return ManagementFactory._gc_mxbeans
|
||||
|
||||
@staticmethod
|
||||
def getPlatformMXBeans(interface_class):
|
||||
return []
|
||||
|
||||
@staticmethod
|
||||
def newPlatformMXBeanProxy(server_connection, mxbean_name, interface_class):
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def getPlatformManagedObject(object_name):
|
||||
return None
|
||||
Reference in new issue
Block a user