mnemonic-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jo...@apache.org
Subject mnemonic git commit: MNEMONIC-463: Should load native library in memory allocator service lazily
Date Tue, 06 Feb 2018 06:44:56 GMT
Repository: mnemonic
Updated Branches:
  refs/heads/master 1dc71263e -> a2abf28b3


MNEMONIC-463: Should load native library in memory allocator service lazily


Project: http://git-wip-us.apache.org/repos/asf/mnemonic/repo
Commit: http://git-wip-us.apache.org/repos/asf/mnemonic/commit/a2abf28b
Tree: http://git-wip-us.apache.org/repos/asf/mnemonic/tree/a2abf28b
Diff: http://git-wip-us.apache.org/repos/asf/mnemonic/diff/a2abf28b

Branch: refs/heads/master
Commit: a2abf28b3fde1b0c69ddd813d8bb159562e2bc4b
Parents: 1dc7126
Author: taojie <taojie@cmss.chinamobile.com>
Authored: Mon Feb 5 15:37:16 2018 +0800
Committer: taojie <taojie@cmss.chinamobile.com>
Committed: Mon Feb 5 15:37:16 2018 +0800

----------------------------------------------------------------------
 .../mnemonic/service/memory/internal/PMemServiceImpl.java    | 7 ++++++-
 .../mnemonic/service/memory/internal/VMemServiceImpl.java    | 7 ++++++-
 .../mnemonic/service/memory/internal/PMallocServiceImpl.java | 8 +++++++-
 .../mnemonic/service/memory/internal/SysVMemServiceImpl.java | 7 ++++++-
 4 files changed, 25 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mnemonic/blob/a2abf28b/mnemonic-memory-services/mnemonic-nvml-pmem-service/src/main/java/org/apache/mnemonic/service/memory/internal/PMemServiceImpl.java
----------------------------------------------------------------------
diff --git a/mnemonic-memory-services/mnemonic-nvml-pmem-service/src/main/java/org/apache/mnemonic/service/memory/internal/PMemServiceImpl.java
b/mnemonic-memory-services/mnemonic-nvml-pmem-service/src/main/java/org/apache/mnemonic/service/memory/internal/PMemServiceImpl.java
index 1617c1b..240583c 100644
--- a/mnemonic-memory-services/mnemonic-nvml-pmem-service/src/main/java/org/apache/mnemonic/service/memory/internal/PMemServiceImpl.java
+++ b/mnemonic-memory-services/mnemonic-nvml-pmem-service/src/main/java/org/apache/mnemonic/service/memory/internal/PMemServiceImpl.java
@@ -30,12 +30,14 @@ import java.util.HashSet;
 import java.util.Set;
 
 public class PMemServiceImpl implements NonVolatileMemoryAllocatorService {
-  static {
+  private static boolean nativeLoaded = false;
+  static void loadNativeLibrary() {
     try {
       NativeLibraryLoader.loadFromJar("pmemallocator");
     } catch (Exception e) {
       throw new Error(e);
     }
+    nativeLoaded = true;
   }
 
   @Override
@@ -45,6 +47,9 @@ public class PMemServiceImpl implements NonVolatileMemoryAllocatorService
{
 
   @Override
   public long init(long capacity, String uri, boolean isnew) {
+    if (!nativeLoaded) {
+      loadNativeLibrary();
+    }
     return ninit(capacity, uri, isnew);
   }
 

http://git-wip-us.apache.org/repos/asf/mnemonic/blob/a2abf28b/mnemonic-memory-services/mnemonic-nvml-vmem-service/src/main/java/org/apache/mnemonic/service/memory/internal/VMemServiceImpl.java
----------------------------------------------------------------------
diff --git a/mnemonic-memory-services/mnemonic-nvml-vmem-service/src/main/java/org/apache/mnemonic/service/memory/internal/VMemServiceImpl.java
b/mnemonic-memory-services/mnemonic-nvml-vmem-service/src/main/java/org/apache/mnemonic/service/memory/internal/VMemServiceImpl.java
index 9171154..805dc27 100644
--- a/mnemonic-memory-services/mnemonic-nvml-vmem-service/src/main/java/org/apache/mnemonic/service/memory/internal/VMemServiceImpl.java
+++ b/mnemonic-memory-services/mnemonic-nvml-vmem-service/src/main/java/org/apache/mnemonic/service/memory/internal/VMemServiceImpl.java
@@ -33,12 +33,14 @@ import java.util.Set;
 import java.util.HashSet;
 
 public class VMemServiceImpl implements VolatileMemoryAllocatorService {
-  static {
+  private static boolean nativeLoaded = false;
+  static void loadNativeLibrary() {
     try {
       NativeLibraryLoader.loadFromJar("vmemallocator");
     } catch (Exception e) {
       throw new Error(e);
     }
+    nativeLoaded = true;
   }
 
   protected Map<Long, Long> m_info = Collections.synchronizedMap(new HashMap<Long,
Long>());
@@ -50,6 +52,9 @@ public class VMemServiceImpl implements VolatileMemoryAllocatorService {
 
   @Override
   public long init(long capacity, String uri, boolean isnew) {
+    if (!nativeLoaded) {
+      loadNativeLibrary();
+    }
     long ret = ninit(capacity, uri, isnew);
     m_info.put(ret, capacity);
     return ret;

http://git-wip-us.apache.org/repos/asf/mnemonic/blob/a2abf28b/mnemonic-memory-services/mnemonic-pmalloc-service/src/main/java/org/apache/mnemonic/service/memory/internal/PMallocServiceImpl.java
----------------------------------------------------------------------
diff --git a/mnemonic-memory-services/mnemonic-pmalloc-service/src/main/java/org/apache/mnemonic/service/memory/internal/PMallocServiceImpl.java
b/mnemonic-memory-services/mnemonic-pmalloc-service/src/main/java/org/apache/mnemonic/service/memory/internal/PMallocServiceImpl.java
index 0257d75..0bf478f 100644
--- a/mnemonic-memory-services/mnemonic-pmalloc-service/src/main/java/org/apache/mnemonic/service/memory/internal/PMallocServiceImpl.java
+++ b/mnemonic-memory-services/mnemonic-pmalloc-service/src/main/java/org/apache/mnemonic/service/memory/internal/PMallocServiceImpl.java
@@ -30,12 +30,14 @@ import java.util.HashSet;
 import java.util.Set;
 
 public class PMallocServiceImpl implements NonVolatileMemoryAllocatorService {
-  static {
+  private static boolean nativeLoaded = false;
+  static void loadNativeLibrary() {
     try {
       NativeLibraryLoader.loadFromJar("pmallocallocator");
     } catch (Exception e) {
       throw new Error(e);
     }
+    nativeLoaded = true;
   }
 
   @Override
@@ -45,6 +47,9 @@ public class PMallocServiceImpl implements NonVolatileMemoryAllocatorService
{
 
   @Override
   public long init(long capacity, String uri, boolean isnew) {
+    if (!nativeLoaded) {
+      loadNativeLibrary();
+    }
     return ninit(capacity, uri, isnew);
   }
 
@@ -277,4 +282,5 @@ public class PMallocServiceImpl implements NonVolatileMemoryAllocatorService
{
   public ResultSet query(long id, String querystr) {
     throw new UnsupportedOperationException();
   }
+
 }

http://git-wip-us.apache.org/repos/asf/mnemonic/blob/a2abf28b/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/java/org/apache/mnemonic/service/memory/internal/SysVMemServiceImpl.java
----------------------------------------------------------------------
diff --git a/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/java/org/apache/mnemonic/service/memory/internal/SysVMemServiceImpl.java
b/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/java/org/apache/mnemonic/service/memory/internal/SysVMemServiceImpl.java
index 70e989a..0b3f562 100644
--- a/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/java/org/apache/mnemonic/service/memory/internal/SysVMemServiceImpl.java
+++ b/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/java/org/apache/mnemonic/service/memory/internal/SysVMemServiceImpl.java
@@ -33,12 +33,14 @@ import java.util.Set;
 import java.util.HashSet;
 
 public class SysVMemServiceImpl implements VolatileMemoryAllocatorService {
-  static {
+  private static boolean nativeLoaded = false;
+  static void loadNativeLibrary() {
     try {
       NativeLibraryLoader.loadFromJar("sysvmemallocator");
     } catch (Exception e) {
       throw new Error(e);
     }
+    nativeLoaded = true;
   }
 
   protected Map<Long, Long> m_info = Collections.synchronizedMap(new HashMap<Long,
Long>());
@@ -50,6 +52,9 @@ public class SysVMemServiceImpl implements VolatileMemoryAllocatorService
{
 
   @Override
   public long init(long capacity, String uri, boolean isnew) {
+    if (!nativeLoaded) {
+      loadNativeLibrary();
+    }
     long ret = ninit(capacity, uri, isnew);
     m_info.put(ret, capacity);
     return ret;


Mime
View raw message