diff options
author | Diego <diegolparra@gmail.com> | 2014-07-23 21:01:27 -0300 |
---|---|---|
committer | Diego <diegolparra@gmail.com> | 2014-07-23 21:01:27 -0300 |
commit | c7a6d66636518a73cae4b79f20e1737f3f02e2ec (patch) | |
tree | 1d64840a058f9f3510e23e5c1530f50272b31461 /kamon-system-metrics/src/main/scala/kamon | |
parent | c1157ec8812d8ac7522910df105400050d521000 (diff) | |
download | Kamon-c7a6d66636518a73cae4b79f20e1737f3f02e2ec.tar.gz Kamon-c7a6d66636518a73cae4b79f20e1737f3f02e2ec.tar.bz2 Kamon-c7a6d66636518a73cae4b79f20e1737f3f02e2ec.zip |
= kamon-system-metrics: Initialization-on-demand holder idiom in order to load one instance of Sigar
Diffstat (limited to 'kamon-system-metrics/src/main/scala/kamon')
-rw-r--r-- | kamon-system-metrics/src/main/scala/kamon/metrics/CPUMetrics.scala | 2 | ||||
-rw-r--r-- | kamon-system-metrics/src/main/scala/kamon/system/SystemMetrics.scala | 4 | ||||
-rw-r--r-- | kamon-system-metrics/src/main/scala/kamon/system/sigar/SigarLoader.scala (renamed from kamon-system-metrics/src/main/scala/kamon/system/native/SigarLoader.scala) | 26 | ||||
-rw-r--r-- | kamon-system-metrics/src/main/scala/kamon/system/sigar/index (renamed from kamon-system-metrics/src/main/scala/kamon/system/native/index) | 0 | ||||
-rw-r--r-- | kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-amd64-freebsd-6.so (renamed from kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-amd64-freebsd-6.so) | bin | 210641 -> 210641 bytes | |||
-rw-r--r-- | kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-amd64-linux.so (renamed from kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-amd64-linux.so) | bin | 246605 -> 246605 bytes | |||
-rw-r--r-- | kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-amd64-solaris.so (renamed from kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-amd64-solaris.so) | bin | 251360 -> 251360 bytes | |||
-rw-r--r-- | kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-ia64-hpux-11.sl (renamed from kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-ia64-hpux-11.sl) | bin | 577452 -> 577452 bytes | |||
-rw-r--r-- | kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-ia64-linux.so (renamed from kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-ia64-linux.so) | bin | 494929 -> 494929 bytes | |||
-rw-r--r-- | kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-pa-hpux-11.sl (renamed from kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-pa-hpux-11.sl) | bin | 516096 -> 516096 bytes | |||
-rw-r--r-- | kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-ppc-aix-5.so (renamed from kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-ppc-aix-5.so) | bin | 400925 -> 400925 bytes | |||
-rw-r--r-- | kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-ppc-linux.so (renamed from kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-ppc-linux.so) | bin | 258547 -> 258547 bytes | |||
-rw-r--r-- | kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-ppc64-aix-5.so (renamed from kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-ppc64-aix-5.so) | bin | 425077 -> 425077 bytes | |||
-rw-r--r-- | kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-ppc64-linux.so (renamed from kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-ppc64-linux.so) | bin | 330767 -> 330767 bytes | |||
-rw-r--r-- | kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-s390x-linux.so (renamed from kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-s390x-linux.so) | bin | 269932 -> 269932 bytes | |||
-rw-r--r-- | kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-sparc-solaris.so (renamed from kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-sparc-solaris.so) | bin | 285004 -> 285004 bytes | |||
-rw-r--r-- | kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-sparc64-solaris.so (renamed from kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-sparc64-solaris.so) | bin | 261896 -> 261896 bytes | |||
-rw-r--r-- | kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-universal-macosx.dylib (renamed from kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-universal-macosx.dylib) | bin | 377668 -> 377668 bytes | |||
-rw-r--r-- | kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-universal64-macosx.dylib (renamed from kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-universal64-macosx.dylib) | bin | 397440 -> 397440 bytes | |||
-rw-r--r-- | kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-x86-freebsd-5.so (renamed from kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-x86-freebsd-5.so) | bin | 179751 -> 179751 bytes | |||
-rw-r--r-- | kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-x86-freebsd-6.so (renamed from kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-x86-freebsd-6.so) | bin | 179379 -> 179379 bytes | |||
-rw-r--r-- | kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-x86-linux.so (renamed from kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-x86-linux.so) | bin | 233385 -> 233385 bytes | |||
-rw-r--r-- | kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-x86-solaris.so (renamed from kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-x86-solaris.so) | bin | 242880 -> 242880 bytes | |||
-rw-r--r-- | kamon-system-metrics/src/main/scala/kamon/system/sigar/sigar-amd64-winnt.dll (renamed from kamon-system-metrics/src/main/scala/kamon/system/native/sigar-amd64-winnt.dll) | bin | 402432 -> 402432 bytes | |||
-rw-r--r-- | kamon-system-metrics/src/main/scala/kamon/system/sigar/sigar-x86-winnt.dll (renamed from kamon-system-metrics/src/main/scala/kamon/system/native/sigar-x86-winnt.dll) | bin | 266240 -> 266240 bytes |
25 files changed, 16 insertions, 16 deletions
diff --git a/kamon-system-metrics/src/main/scala/kamon/metrics/CPUMetrics.scala b/kamon-system-metrics/src/main/scala/kamon/metrics/CPUMetrics.scala index a45896ac..89ec5729 100644 --- a/kamon-system-metrics/src/main/scala/kamon/metrics/CPUMetrics.scala +++ b/kamon-system-metrics/src/main/scala/kamon/metrics/CPUMetrics.scala @@ -18,7 +18,7 @@ package kamon.metrics import akka.actor.ActorSystem import com.typesafe.config.Config import kamon.metric._ -import kamon.metric.instrument.{Gauge, Histogram} +import kamon.metric.instrument.{ Gauge, Histogram } import kamon.system.SigarExtensionProvider case class CPUMetrics(name: String) extends MetricGroupIdentity { diff --git a/kamon-system-metrics/src/main/scala/kamon/system/SystemMetrics.scala b/kamon-system-metrics/src/main/scala/kamon/system/SystemMetrics.scala index a46d8e1f..bd156c2a 100644 --- a/kamon-system-metrics/src/main/scala/kamon/system/SystemMetrics.scala +++ b/kamon-system-metrics/src/main/scala/kamon/system/SystemMetrics.scala @@ -22,7 +22,7 @@ import akka.event.Logging import kamon.Kamon import kamon.metric.Metrics import kamon.metrics._ -import kamon.system.native.SigarLoader + import scala.collection.JavaConverters._ object SystemMetrics extends ExtensionId[SystemMetricsExtension] with ExtensionIdProvider { @@ -60,6 +60,6 @@ object SystemMetricsExtension { } trait SigarExtensionProvider { - lazy val sigar = SigarLoader.sigarProxy + lazy val sigar = SigarHolder.instance() } diff --git a/kamon-system-metrics/src/main/scala/kamon/system/native/SigarLoader.scala b/kamon-system-metrics/src/main/scala/kamon/system/sigar/SigarLoader.scala index f1072f56..0c78504e 100644 --- a/kamon-system-metrics/src/main/scala/kamon/system/native/SigarLoader.scala +++ b/kamon-system-metrics/src/main/scala/kamon/system/sigar/SigarLoader.scala @@ -14,7 +14,7 @@ * ========================================================================================= */ -package kamon.system.native +package kamon.system.sigar import java.io._ import java.util @@ -33,14 +33,14 @@ object SigarLoader { val Version = "1.6.4" val JavaLibraryPath = "java.library.path" val TmpDir = "java.io.tmpdir" - val IndexFile = "/kamon/system/native/index" + val IndexFile = "/kamon/system/sigar/index" val UsrPathField = "usr_paths" private val log = Logger.getLogger("SigarLoader") - lazy val sigarProxy = init(new File(System.getProperty(TmpDir))) + def sigarProxy = init(new File(System.getProperty(TmpDir))) - private[native] def init(baseTmp: File): SigarProxy = { + private[sigar] def init(baseTmp: File): SigarProxy = { val tmpDir = createTmpDir(baseTmp) for (lib ← loadIndex) copy(lib, tmpDir) @@ -58,13 +58,13 @@ object SigarLoader { } } - private[native] val usrPathField = { + private[sigar] val usrPathField = { val usrPathField = classOf[ClassLoader].getDeclaredField(UsrPathField) usrPathField.setAccessible(true) usrPathField } - private[native] def attachToLibraryPath(dir: File): Unit = { + private[sigar] def attachToLibraryPath(dir: File): Unit = { val dirAbsolute = dir.getAbsolutePath System.setProperty(JavaLibraryPath, newLibraryPath(dirAbsolute)) var paths = usrPathField.get(null).asInstanceOf[Array[String]] @@ -75,17 +75,17 @@ object SigarLoader { usrPathField.set(null, newPaths) } - private[native] def newLibraryPath(dirAbsolutePath: String): String = { + private[sigar] def newLibraryPath(dirAbsolutePath: String): String = { Option(System.getProperty(JavaLibraryPath)).fold(dirAbsolutePath)(oldValue ⇒ s"$dirAbsolutePath${File.pathSeparator}$oldValue") } - private[native] def copy(lib: String, tmpDir: File) { + private[sigar] def copy(lib: String, tmpDir: File) { val target = new File(tmpDir, lib) if (target.exists()) return write(classOf[Loader].getResourceAsStream(lib), target) } - private[native] def createTmpDir(baseTmp: File): File = { + private[sigar] def createTmpDir(baseTmp: File): File = { val tmpDir = new File(baseTmp, s"sigar-$Version") if (!tmpDir.exists()) { if (!tmpDir.mkdirs()) throw new RuntimeException(s"Could not create temp sigar directory: ${tmpDir.getAbsolutePath}") @@ -95,7 +95,7 @@ object SigarLoader { tmpDir } - private[native] def loadIndex(): List[String] = { + private[sigar] def loadIndex(): List[String] = { val libs = new ArrayList[String]() val is = classOf[Loader].getResourceAsStream(IndexFile) @@ -106,7 +106,7 @@ object SigarLoader { libs } - private[native] def write(input: InputStream, to: File) { + private[sigar] def write(input: InputStream, to: File) { val out = new FileOutputStream(to) try { transfer(input, out) @@ -115,7 +115,7 @@ object SigarLoader { } } - private[native] def transfer(input: InputStream, out: OutputStream) { + private[sigar] def transfer(input: InputStream, out: OutputStream) { val buffer = new Array[Byte](8192) @tailrec def transfer() { @@ -128,5 +128,5 @@ object SigarLoader { transfer() } - class Loader private[native] + class Loader private[sigar] } diff --git a/kamon-system-metrics/src/main/scala/kamon/system/native/index b/kamon-system-metrics/src/main/scala/kamon/system/sigar/index index ebc7f952..ebc7f952 100644 --- a/kamon-system-metrics/src/main/scala/kamon/system/native/index +++ b/kamon-system-metrics/src/main/scala/kamon/system/sigar/index diff --git a/kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-amd64-freebsd-6.so b/kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-amd64-freebsd-6.so Binary files differindex 3e94f0d2..3e94f0d2 100644 --- a/kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-amd64-freebsd-6.so +++ b/kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-amd64-freebsd-6.so diff --git a/kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-amd64-linux.so b/kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-amd64-linux.so Binary files differindex 5a2e4c24..5a2e4c24 100644 --- a/kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-amd64-linux.so +++ b/kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-amd64-linux.so diff --git a/kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-amd64-solaris.so b/kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-amd64-solaris.so Binary files differindex 6396482a..6396482a 100644 --- a/kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-amd64-solaris.so +++ b/kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-amd64-solaris.so diff --git a/kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-ia64-hpux-11.sl b/kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-ia64-hpux-11.sl Binary files differindex d92ea4a9..d92ea4a9 100644 --- a/kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-ia64-hpux-11.sl +++ b/kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-ia64-hpux-11.sl diff --git a/kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-ia64-linux.so b/kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-ia64-linux.so Binary files differindex 2bd2fc8e..2bd2fc8e 100644 --- a/kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-ia64-linux.so +++ b/kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-ia64-linux.so diff --git a/kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-pa-hpux-11.sl b/kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-pa-hpux-11.sl Binary files differindex 0dfd8a11..0dfd8a11 100644 --- a/kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-pa-hpux-11.sl +++ b/kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-pa-hpux-11.sl diff --git a/kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-ppc-aix-5.so b/kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-ppc-aix-5.so Binary files differindex 7d4b5199..7d4b5199 100644 --- a/kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-ppc-aix-5.so +++ b/kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-ppc-aix-5.so diff --git a/kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-ppc-linux.so b/kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-ppc-linux.so Binary files differindex 4394b1b0..4394b1b0 100644 --- a/kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-ppc-linux.so +++ b/kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-ppc-linux.so diff --git a/kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-ppc64-aix-5.so b/kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-ppc64-aix-5.so Binary files differindex 35fd8288..35fd8288 100644 --- a/kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-ppc64-aix-5.so +++ b/kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-ppc64-aix-5.so diff --git a/kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-ppc64-linux.so b/kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-ppc64-linux.so Binary files differindex a1ba2529..a1ba2529 100644 --- a/kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-ppc64-linux.so +++ b/kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-ppc64-linux.so diff --git a/kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-s390x-linux.so b/kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-s390x-linux.so Binary files differindex c275f4ac..c275f4ac 100644 --- a/kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-s390x-linux.so +++ b/kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-s390x-linux.so diff --git a/kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-sparc-solaris.so b/kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-sparc-solaris.so Binary files differindex aa847d2b..aa847d2b 100644 --- a/kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-sparc-solaris.so +++ b/kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-sparc-solaris.so diff --git a/kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-sparc64-solaris.so b/kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-sparc64-solaris.so Binary files differindex 6c4fe809..6c4fe809 100644 --- a/kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-sparc64-solaris.so +++ b/kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-sparc64-solaris.so diff --git a/kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-universal-macosx.dylib b/kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-universal-macosx.dylib Binary files differindex 27ab1071..27ab1071 100644 --- a/kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-universal-macosx.dylib +++ b/kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-universal-macosx.dylib diff --git a/kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-universal64-macosx.dylib b/kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-universal64-macosx.dylib Binary files differindex 0c721fec..0c721fec 100644 --- a/kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-universal64-macosx.dylib +++ b/kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-universal64-macosx.dylib diff --git a/kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-x86-freebsd-5.so b/kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-x86-freebsd-5.so Binary files differindex 8c50c611..8c50c611 100644 --- a/kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-x86-freebsd-5.so +++ b/kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-x86-freebsd-5.so diff --git a/kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-x86-freebsd-6.so b/kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-x86-freebsd-6.so Binary files differindex f0800274..f0800274 100644 --- a/kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-x86-freebsd-6.so +++ b/kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-x86-freebsd-6.so diff --git a/kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-x86-linux.so b/kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-x86-linux.so Binary files differindex a0b64edd..a0b64edd 100644 --- a/kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-x86-linux.so +++ b/kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-x86-linux.so diff --git a/kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-x86-solaris.so b/kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-x86-solaris.so Binary files differindex c6452e56..c6452e56 100644 --- a/kamon-system-metrics/src/main/scala/kamon/system/native/libsigar-x86-solaris.so +++ b/kamon-system-metrics/src/main/scala/kamon/system/sigar/libsigar-x86-solaris.so diff --git a/kamon-system-metrics/src/main/scala/kamon/system/native/sigar-amd64-winnt.dll b/kamon-system-metrics/src/main/scala/kamon/system/sigar/sigar-amd64-winnt.dll Binary files differindex 1ec8a035..1ec8a035 100644 --- a/kamon-system-metrics/src/main/scala/kamon/system/native/sigar-amd64-winnt.dll +++ b/kamon-system-metrics/src/main/scala/kamon/system/sigar/sigar-amd64-winnt.dll diff --git a/kamon-system-metrics/src/main/scala/kamon/system/native/sigar-x86-winnt.dll b/kamon-system-metrics/src/main/scala/kamon/system/sigar/sigar-x86-winnt.dll Binary files differindex 6afdc016..6afdc016 100644 --- a/kamon-system-metrics/src/main/scala/kamon/system/native/sigar-x86-winnt.dll +++ b/kamon-system-metrics/src/main/scala/kamon/system/sigar/sigar-x86-winnt.dll |