You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mnemonic.apache.org by ga...@apache.org on 2016/04/09 00:00:09 UTC
[7/7] incubator-mnemonic git commit: format codestyle & add Apache
License
format codestyle & add Apache License
Project: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/commit/551c8247
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/tree/551c8247
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/diff/551c8247
Branch: refs/heads/master
Commit: 551c8247d07ead2ce64be0e8520bfd1e3d8875d3
Parents: af3bb70
Author: Wang, Gang(Gary) <ga...@intel.com>
Authored: Fri Apr 8 14:45:39 2016 -0700
Committer: Wang, Gang(Gary) <ga...@intel.com>
Committed: Fri Apr 8 14:45:39 2016 -0700
----------------------------------------------------------------------
.../internal/VMemServiceImpl.java | 137 +-
.../nvml-vmem-service/src/main/native/common.c | 38 +-
.../nvml-vmem-service/src/main/native/common.h | 18 +
..._allocatorservice_internal_VMemServiceImpl.c | 261 +--
..._allocatorservice_internal_VMemServiceImpl.h | 23 +-
.../internal/PMallocServiceImpl.java | 218 +--
.../pmalloc-service/src/main/native/common.c | 38 +-
.../pmalloc-service/src/main/native/common.h | 18 +
...locatorservice_internal_PMallocServiceImpl.c | 437 +++--
...locatorservice_internal_PMallocServiceImpl.h | 23 +-
.../collections/NonVolatileNodeValue.java | 250 +--
.../collections/NonVolatileNodeValueNGTest.java | 469 ++---
.../collections/NonVolatilePersonNGTest.java | 233 +--
.../apache/mnemonic/collections/Payload.java | 45 +-
.../org/apache/mnemonic/collections/Person.java | 123 +-
.../java/org/apache/mnemonic/Allocatable.java | 193 +-
.../java/org/apache/mnemonic/Allocator.java | 69 +-
.../AnnotatedNonVolatileEntityClass.java | 1807 +++++++++---------
.../mnemonic/AnnotationProcessingException.java | 37 +-
.../apache/mnemonic/BigDataMemAllocator.java | 476 ++---
.../apache/mnemonic/BigDataPMemAllocator.java | 831 ++++----
.../mnemonic/ByteBufferBackedInputStream.java | 101 +-
.../mnemonic/ByteBufferBackedOutputStream.java | 99 +-
.../apache/mnemonic/ByteBufferSerializer.java | 266 +--
.../java/org/apache/mnemonic/CachePool.java | 247 +--
.../org/apache/mnemonic/CommonAllocator.java | 185 +-
.../apache/mnemonic/CommonPersistAllocator.java | 220 ++-
.../mnemonic/ContainerOverflowException.java | 37 +-
.../java/org/apache/mnemonic/DropEvent.java | 47 +-
.../main/java/org/apache/mnemonic/Durable.java | 136 +-
.../org/apache/mnemonic/EntityFactoryProxy.java | 68 +-
.../java/org/apache/mnemonic/EvictFilter.java | 49 +-
.../java/org/apache/mnemonic/GenericField.java | 529 ++---
.../org/apache/mnemonic/MemBufferHolder.java | 104 +-
.../mnemonic/MemBufferHolderCachePool.java | 440 ++---
.../org/apache/mnemonic/MemChunkHolder.java | 113 +-
.../java/org/apache/mnemonic/MemClustering.java | 496 ++---
.../main/java/org/apache/mnemonic/MemFile.java | 86 +-
.../java/org/apache/mnemonic/MemHolder.java | 109 +-
.../mnemonic/MemoryNonVolatileEntity.java | 35 +-
.../org/apache/mnemonic/NonVolatileEntity.java | 20 +-
.../mnemonic/NonVolatileEntityProcessor.java | 218 ++-
.../org/apache/mnemonic/NonVolatileGetter.java | 28 +-
.../org/apache/mnemonic/NonVolatileSetter.java | 20 +-
.../apache/mnemonic/OutOfPersistentMemory.java | 25 +-
.../apache/mnemonic/PMAddressTranslator.java | 86 +-
.../main/java/org/apache/mnemonic/Reclaim.java | 45 +-
.../RetrieveNonVolatileEntityError.java | 32 +-
.../org/apache/mnemonic/SysMemAllocator.java | 517 ++---
.../main/java/org/apache/mnemonic/Utils.java | 664 +++----
.../NonVolatileMemoryAllocatorService.java | 189 +-
.../VolatileMemoryAllocatorService.java | 240 +--
.../mnemonic/BigDataMemAllocatorNGTest.java | 91 +-
.../mnemonic/BigDataPMemAllocatorNGTest.java | 228 +--
.../mnemonic/ByteBufferSerializerNGTest.java | 89 +-
.../MemBufferHolderCachePoolNGTest.java | 257 +--
.../apache/mnemonic/MemClusteringNGTest.java | 329 ++--
.../mnemonic/NonVolatilePersonNGTest.java | 234 +--
.../test/java/org/apache/mnemonic/Payload.java | 45 +-
.../test/java/org/apache/mnemonic/Person.java | 121 +-
.../java/org/apache/mnemonic/example/Main.java | 316 +--
61 files changed, 6873 insertions(+), 6032 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/551c8247/allocator-services/nvml-vmem-service/src/main/java/org/apache/mnemonic/service/allocatorservice/internal/VMemServiceImpl.java
----------------------------------------------------------------------
diff --git a/allocator-services/nvml-vmem-service/src/main/java/org/apache/mnemonic/service/allocatorservice/internal/VMemServiceImpl.java b/allocator-services/nvml-vmem-service/src/main/java/org/apache/mnemonic/service/allocatorservice/internal/VMemServiceImpl.java
index 6e4558d..0bad38f 100644
--- a/allocator-services/nvml-vmem-service/src/main/java/org/apache/mnemonic/service/allocatorservice/internal/VMemServiceImpl.java
+++ b/allocator-services/nvml-vmem-service/src/main/java/org/apache/mnemonic/service/allocatorservice/internal/VMemServiceImpl.java
@@ -1,94 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.apache.mnemonic.service.allocatorservice.internal;
import org.apache.mnemonic.service.allocatorservice.VolatileMemoryAllocatorService;
import org.flowcomputing.commons.primitives.*;
import java.nio.ByteBuffer;
-
public class VMemServiceImpl implements VolatileMemoryAllocatorService {
- static {
- try {
- NativeLibraryLoader.loadFromJar("vmemallocator");
- } catch (Exception e) {
- throw new Error(e);
- }
- }
-
- @Override
- public String getServiceId() {
- return "vmem";
- }
-
- @Override
- public long init(long capacity, String uri, boolean isnew) {
- return ninit(capacity, uri, isnew);
- }
-
- @Override
- public void close(long id) {
- nclose(id);
- }
-
- @Override
- public void sync(long id) {
- nsync(id);
+ static {
+ try {
+ NativeLibraryLoader.loadFromJar("vmemallocator");
+ } catch (Exception e) {
+ throw new Error(e);
}
+ }
- @Override
- public long allocate(long id, long size, boolean initzero) {
- return nallocate(id, size, initzero);
- }
-
- @Override
- public long reallocate(long id, long address, long size, boolean initzero) {
- return nreallocate(id, address, size, initzero);
- }
-
- @Override
- public void free(long id, long address) {
- nfree(id, address);
- }
+ @Override
+ public String getServiceId() {
+ return "vmem";
+ }
- @Override
- public ByteBuffer createByteBuffer(long id, long size) {
- return ncreateByteBuffer(id, size);
- }
-
- @Override
- public ByteBuffer resizeByteBuffer(long id, ByteBuffer bytebuf, long size) {
- return nresizeByteBuffer(id, bytebuf, size);
- }
-
- @Override
- public void destroyByteBuffer(long id, ByteBuffer bytebuf) {
- ndestroyByteBuffer(id, bytebuf);
- }
+ @Override
+ public long init(long capacity, String uri, boolean isnew) {
+ return ninit(capacity, uri, isnew);
+ }
+ @Override
+ public void close(long id) {
+ nclose(id);
+ }
- protected native long ninit(long capacity, String uri, boolean isnew);
+ @Override
+ public void sync(long id) {
+ nsync(id);
+ }
+ @Override
+ public long allocate(long id, long size, boolean initzero) {
+ return nallocate(id, size, initzero);
+ }
- protected native void nclose(long id);
+ @Override
+ public long reallocate(long id, long address, long size, boolean initzero) {
+ return nreallocate(id, address, size, initzero);
+ }
+ @Override
+ public void free(long id, long address) {
+ nfree(id, address);
+ }
- protected native void nsync(long id);
+ @Override
+ public ByteBuffer createByteBuffer(long id, long size) {
+ return ncreateByteBuffer(id, size);
+ }
+ @Override
+ public ByteBuffer resizeByteBuffer(long id, ByteBuffer bytebuf, long size) {
+ return nresizeByteBuffer(id, bytebuf, size);
+ }
- protected native long nallocate(long id, long size, boolean initzero);
+ @Override
+ public void destroyByteBuffer(long id, ByteBuffer bytebuf) {
+ ndestroyByteBuffer(id, bytebuf);
+ }
+ protected native long ninit(long capacity, String uri, boolean isnew);
- protected native long nreallocate(long id, long address, long size, boolean initzero);
+ protected native void nclose(long id);
+ protected native void nsync(long id);
- protected native void nfree(long id, long address);
+ protected native long nallocate(long id, long size, boolean initzero);
+ protected native long nreallocate(long id, long address, long size, boolean initzero);
- protected native ByteBuffer ncreateByteBuffer(long id, long size);
+ protected native void nfree(long id, long address);
+ protected native ByteBuffer ncreateByteBuffer(long id, long size);
- protected native ByteBuffer nresizeByteBuffer(long id, ByteBuffer bytebuf, long size);
-
+ protected native ByteBuffer nresizeByteBuffer(long id, ByteBuffer bytebuf, long size);
- protected native void ndestroyByteBuffer(long id, ByteBuffer bytebuf);
+ protected native void ndestroyByteBuffer(long id, ByteBuffer bytebuf);
}
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/551c8247/allocator-services/nvml-vmem-service/src/main/native/common.c
----------------------------------------------------------------------
diff --git a/allocator-services/nvml-vmem-service/src/main/native/common.c b/allocator-services/nvml-vmem-service/src/main/native/common.c
index e7d6772..143743e 100644
--- a/allocator-services/nvml-vmem-service/src/main/native/common.c
+++ b/allocator-services/nvml-vmem-service/src/main/native/common.c
@@ -1,10 +1,23 @@
-/****************************************************************************************
-Revise Date: 20 Apr. 2014
-*****************************************************************************************/
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#include <common.h>
-
/******************************************************************************
** Generally-useful functions for JNI programming.
*****************************************************************************/
@@ -13,13 +26,12 @@ Revise Date: 20 Apr. 2014
* Throws a RuntimeException, with either an explicit message or the message
* corresponding to the current system error value.
*/
-void throw(JNIEnv* env, const char* msg)
-{
- if (msg == NULL)
- msg = sys_errlist[errno];
+void throw(JNIEnv* env, const char* msg) {
+ if (msg == NULL)
+ msg = sys_errlist[errno];
- jclass xklass = (*env)->FindClass(env, "java/lang/RuntimeException");
- (*env)->ThrowNew(env, xklass, msg);
+ jclass xklass = (*env)->FindClass(env, "java/lang/RuntimeException");
+ (*env)->ThrowNew(env, xklass, msg);
}
void* addr_from_java(jlong addr) {
@@ -27,11 +39,11 @@ void* addr_from_java(jlong addr) {
// It is impossible to predict whether native code that converts
// pointers to longs will sign-extend or zero-extend the addresses.
//assert(addr == (uintptr_t)addr, "must not be odd high bits");
- return (void*)(uintptr_t)addr;
+ return (void*) (uintptr_t) addr;
}
jlong addr_to_java(void* p) {
- assert(p == (void*)(uintptr_t)p);
- return (long)(uintptr_t)p;
+ assert(p == (void*) (uintptr_t) p);
+ return (long) (uintptr_t) p;
}
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/551c8247/allocator-services/nvml-vmem-service/src/main/native/common.h
----------------------------------------------------------------------
diff --git a/allocator-services/nvml-vmem-service/src/main/native/common.h b/allocator-services/nvml-vmem-service/src/main/native/common.h
index d2b8250..f03dbff 100644
--- a/allocator-services/nvml-vmem-service/src/main/native/common.h
+++ b/allocator-services/nvml-vmem-service/src/main/native/common.h
@@ -1,3 +1,21 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#ifndef _COMMON_H
#define _COMMON_H
#ifdef __cplusplus
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/551c8247/allocator-services/nvml-vmem-service/src/main/native/org_apache_mnemonic_service_allocatorservice_internal_VMemServiceImpl.c
----------------------------------------------------------------------
diff --git a/allocator-services/nvml-vmem-service/src/main/native/org_apache_mnemonic_service_allocatorservice_internal_VMemServiceImpl.c b/allocator-services/nvml-vmem-service/src/main/native/org_apache_mnemonic_service_allocatorservice_internal_VMemServiceImpl.c
index 824b703..eb02fe2 100644
--- a/allocator-services/nvml-vmem-service/src/main/native/org_apache_mnemonic_service_allocatorservice_internal_VMemServiceImpl.c
+++ b/allocator-services/nvml-vmem-service/src/main/native/org_apache_mnemonic_service_allocatorservice_internal_VMemServiceImpl.c
@@ -1,6 +1,20 @@
-/****************************************************************************************
-Revise Date: 20 Apr. 2014
-*****************************************************************************************/
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#include "org_apache_mnemonic_service_allocatorservice_internal_VMemServiceImpl.h"
@@ -18,168 +32,155 @@ static pthread_rwlock_t g_vmem_rwlock = PTHREAD_RWLOCK_INITIALIZER;
*****************************************************************************/
JNIEXPORT
-jlong JNICALL Java_org_apache_mnemonic_service_allocatorservice_internal_VMemServiceImpl_nallocate(
- JNIEnv* env,
- jobject this, jlong id,
- jlong size, jboolean initzero)
-{
- pthread_rwlock_rdlock(&g_vmem_rwlock);
- pthread_mutex_lock(g_vmem_mutex_ptr + id);
- void* nativebuf = initzero ? vmem_calloc(*(g_vmp_ptr + id), 1, size) : vmem_malloc(*(g_vmp_ptr + id), size);
- pthread_mutex_unlock(g_vmem_mutex_ptr + id);
- pthread_rwlock_unlock(&g_vmem_rwlock);
- return addr_to_java(nativebuf);
+jlong JNICALL Java_org_apache_mnemonic_service_allocatorservice_internal_VMemServiceImpl_nallocate(JNIEnv* env,
+ jobject this, jlong id, jlong size, jboolean initzero) {
+ pthread_rwlock_rdlock(&g_vmem_rwlock);
+ pthread_mutex_lock(g_vmem_mutex_ptr + id);
+ void* nativebuf = initzero ? vmem_calloc(*(g_vmp_ptr + id), 1, size) : vmem_malloc(*(g_vmp_ptr + id), size);
+ pthread_mutex_unlock(g_vmem_mutex_ptr + id);
+ pthread_rwlock_unlock(&g_vmem_rwlock);
+ return addr_to_java(nativebuf);
}
JNIEXPORT
-jlong JNICALL Java_org_apache_mnemonic_service_allocatorservice_internal_VMemServiceImpl_nreallocate(
- JNIEnv* env,
- jobject this, jlong id,
- jlong address,
- jlong size, jboolean initzero)
-{
- pthread_rwlock_rdlock(&g_vmem_rwlock);
- pthread_mutex_lock(g_vmem_mutex_ptr + id);
-
- void* p = addr_from_java(address);
-
- void* nativebuf = vmem_realloc(*(g_vmp_ptr + id), p, size);
-
- pthread_mutex_unlock(g_vmem_mutex_ptr + id);
- pthread_rwlock_unlock(&g_vmem_rwlock);
- return addr_to_java(nativebuf);
+jlong JNICALL Java_org_apache_mnemonic_service_allocatorservice_internal_VMemServiceImpl_nreallocate(JNIEnv* env,
+ jobject this, jlong id, jlong address, jlong size, jboolean initzero) {
+ pthread_rwlock_rdlock(&g_vmem_rwlock);
+ pthread_mutex_lock(g_vmem_mutex_ptr + id);
+
+ void* p = addr_from_java(address);
+
+ void* nativebuf = vmem_realloc(*(g_vmp_ptr + id), p, size);
+
+ pthread_mutex_unlock(g_vmem_mutex_ptr + id);
+ pthread_rwlock_unlock(&g_vmem_rwlock);
+ return addr_to_java(nativebuf);
}
JNIEXPORT
void JNICALL Java_org_apache_mnemonic_service_allocatorservice_internal_VMemServiceImpl_nfree(
- JNIEnv* env,
- jobject this, jlong id,
- jlong address)
+ JNIEnv* env,
+ jobject this, jlong id,
+ jlong address)
{
- pthread_rwlock_rdlock(&g_vmem_rwlock);
- pthread_mutex_lock(g_vmem_mutex_ptr + id);
- void* nativebuf = addr_from_java(address);
- if (nativebuf != NULL)
- vmem_free(*(g_vmp_ptr + id), nativebuf);
- pthread_mutex_unlock(g_vmem_mutex_ptr + id);
- pthread_rwlock_unlock(&g_vmem_rwlock);
+ pthread_rwlock_rdlock(&g_vmem_rwlock);
+ pthread_mutex_lock(g_vmem_mutex_ptr + id);
+ void* nativebuf = addr_from_java(address);
+ if (nativebuf != NULL)
+ vmem_free(*(g_vmp_ptr + id), nativebuf);
+ pthread_mutex_unlock(g_vmem_mutex_ptr + id);
+ pthread_rwlock_unlock(&g_vmem_rwlock);
}
JNIEXPORT
void JNICALL Java_org_apache_mnemonic_service_allocatorservice_internal_VMemServiceImpl_nsync(
- JNIEnv* env,
- jobject this, jlong id)
+ JNIEnv* env,
+ jobject this, jlong id)
{
}
JNIEXPORT
jobject JNICALL Java_org_apache_mnemonic_service_allocatorservice_internal_VMemServiceImpl_ncreateByteBuffer(
- JNIEnv *env, jobject this, jlong id, jlong size)
-{
- pthread_rwlock_rdlock(&g_vmem_rwlock);
- pthread_mutex_lock(g_vmem_mutex_ptr + id);
- jobject ret = NULL;
- void* nativebuf = vmem_malloc(*(g_vmp_ptr + id), size);
- ret = NULL != nativebuf ? (*env)->NewDirectByteBuffer(env, nativebuf, size) : NULL;
- pthread_mutex_unlock(g_vmem_mutex_ptr + id);
- pthread_rwlock_unlock(&g_vmem_rwlock);
- return ret;
+ JNIEnv *env, jobject this, jlong id, jlong size) {
+ pthread_rwlock_rdlock(&g_vmem_rwlock);
+ pthread_mutex_lock(g_vmem_mutex_ptr + id);
+ jobject ret = NULL;
+ void* nativebuf = vmem_malloc(*(g_vmp_ptr + id), size);
+ ret = NULL != nativebuf ? (*env)->NewDirectByteBuffer(env, nativebuf, size) : NULL;
+ pthread_mutex_unlock(g_vmem_mutex_ptr + id);
+ pthread_rwlock_unlock(&g_vmem_rwlock);
+ return ret;
}
JNIEXPORT
jobject JNICALL Java_org_apache_mnemonic_service_allocatorservice_internal_VMemServiceImpl_nresizeByteBuffer(
- JNIEnv *env, jobject this, jlong id, jobject bytebuf, jlong size)
-{
- pthread_rwlock_rdlock(&g_vmem_rwlock);
- pthread_mutex_lock(g_vmem_mutex_ptr + id);
- jobject ret = NULL;
- if (NULL != bytebuf) {
- void* nativebuf = (void*)(*env)->GetDirectBufferAddress(env, bytebuf);
- if (nativebuf != NULL) {
- nativebuf = vmem_realloc(*(g_vmp_ptr + id), nativebuf, size);
- ret = NULL != nativebuf ? (*env)->NewDirectByteBuffer(env, nativebuf, size) : NULL;
- }
+ JNIEnv *env, jobject this, jlong id, jobject bytebuf, jlong size) {
+ pthread_rwlock_rdlock(&g_vmem_rwlock);
+ pthread_mutex_lock(g_vmem_mutex_ptr + id);
+ jobject ret = NULL;
+ if (NULL != bytebuf) {
+ void* nativebuf = (void*) (*env)->GetDirectBufferAddress(env, bytebuf);
+ if (nativebuf != NULL) {
+ nativebuf = vmem_realloc(*(g_vmp_ptr + id), nativebuf, size);
+ ret = NULL != nativebuf ? (*env)->NewDirectByteBuffer(env, nativebuf, size) : NULL;
}
- pthread_mutex_unlock(g_vmem_mutex_ptr + id);
- pthread_rwlock_unlock(&g_vmem_rwlock);
- return ret;
+ }
+ pthread_mutex_unlock(g_vmem_mutex_ptr + id);
+ pthread_rwlock_unlock(&g_vmem_rwlock);
+ return ret;
}
JNIEXPORT
void JNICALL Java_org_apache_mnemonic_service_allocatorservice_internal_VMemServiceImpl_ndestroyByteBuffer(
- JNIEnv *env, jobject this, jlong id, jobject bytebuf)
+ JNIEnv *env, jobject this, jlong id, jobject bytebuf)
{
- pthread_rwlock_rdlock(&g_vmem_rwlock);
- pthread_mutex_lock(g_vmem_mutex_ptr + id);
- if (NULL != bytebuf) {
- void* nativebuf = (void*)(*env)->GetDirectBufferAddress(env, bytebuf);
- if (nativebuf != NULL) {
- vmem_free(*(g_vmp_ptr + id), nativebuf);
- }
+ pthread_rwlock_rdlock(&g_vmem_rwlock);
+ pthread_mutex_lock(g_vmem_mutex_ptr + id);
+ if (NULL != bytebuf) {
+ void* nativebuf = (void*)(*env)->GetDirectBufferAddress(env, bytebuf);
+ if (nativebuf != NULL) {
+ vmem_free(*(g_vmp_ptr + id), nativebuf);
}
- pthread_mutex_unlock(g_vmem_mutex_ptr + id);
- pthread_rwlock_unlock(&g_vmem_rwlock);
+ }
+ pthread_mutex_unlock(g_vmem_mutex_ptr + id);
+ pthread_rwlock_unlock(&g_vmem_rwlock);
}
-JNIEXPORT
-jlong JNICALL Java_org_apache_mnemonic_service_allocatorservice_internal_VMemServiceImpl_ninit
- (JNIEnv *env, jclass this, jlong capacity, jstring pathname, jboolean isnew)
-{
- pthread_rwlock_wrlock(&g_vmem_rwlock);
- size_t ret = -1;
- VMEM *vmp = NULL;
- const char* mpathname = (*env)->GetStringUTFChars(env, pathname, NULL);
- if (NULL == mpathname) {
- pthread_rwlock_unlock(&g_vmem_rwlock);
- throw(env, "Big memory path not specified!");
- }
- if ((vmp = vmem_create(mpathname, capacity)) == NULL) {
- pthread_rwlock_unlock(&g_vmem_rwlock);
- throw(env, "Big memory init failure!");
- }
- g_vmp_ptr = realloc(g_vmp_ptr, (g_vmp_count + 1) * sizeof(VMEM*));
- g_vmem_mutex_ptr =
- realloc(g_vmem_mutex_ptr, (g_vmp_count + 1) * sizeof(pthread_mutex_t));
- if (NULL != g_vmp_ptr && NULL != g_vmem_mutex_ptr) {
- g_vmp_ptr[g_vmp_count] = vmp;
- pthread_mutex_init(g_vmem_mutex_ptr + g_vmp_count, NULL);
- ret = g_vmp_count;
- g_vmp_count++;
- } else {
- pthread_rwlock_unlock(&g_vmem_rwlock);
- throw(env, "Big memory init Out of memory!");
- }
- pthread_rwlock_unlock(&g_vmem_rwlock);
- return ret;
+JNIEXPORT
+jlong JNICALL Java_org_apache_mnemonic_service_allocatorservice_internal_VMemServiceImpl_ninit(JNIEnv *env, jclass this,
+ jlong capacity, jstring pathname, jboolean isnew) {
+ pthread_rwlock_wrlock(&g_vmem_rwlock);
+ size_t ret = -1;
+ VMEM *vmp = NULL;
+ const char* mpathname = (*env)->GetStringUTFChars(env, pathname, NULL);
+ if (NULL == mpathname) {
+ pthread_rwlock_unlock(&g_vmem_rwlock);
+ throw(env, "Big memory path not specified!");
+ }
+ if ((vmp = vmem_create(mpathname, capacity)) == NULL) {
+ pthread_rwlock_unlock(&g_vmem_rwlock);
+ throw(env, "Big memory init failure!");
+ }
+ g_vmp_ptr = realloc(g_vmp_ptr, (g_vmp_count + 1) * sizeof(VMEM*));
+ g_vmem_mutex_ptr = realloc(g_vmem_mutex_ptr, (g_vmp_count + 1) * sizeof(pthread_mutex_t));
+ if (NULL != g_vmp_ptr && NULL != g_vmem_mutex_ptr) {
+ g_vmp_ptr[g_vmp_count] = vmp;
+ pthread_mutex_init(g_vmem_mutex_ptr + g_vmp_count, NULL);
+ ret = g_vmp_count;
+ g_vmp_count++;
+ } else {
+ pthread_rwlock_unlock(&g_vmem_rwlock);
+ throw(env, "Big memory init Out of memory!");
+ }
+ pthread_rwlock_unlock(&g_vmem_rwlock);
+ return ret;
}
-JNIEXPORT
+JNIEXPORT
void JNICALL Java_org_apache_mnemonic_service_allocatorservice_internal_VMemServiceImpl_nclose
- (JNIEnv *env, jobject this, jlong id)
+(JNIEnv *env, jobject this, jlong id)
{
- pthread_rwlock_rdlock(&g_vmem_rwlock);
- pthread_mutex_lock(g_vmem_mutex_ptr + id);
+ pthread_rwlock_rdlock(&g_vmem_rwlock);
+ pthread_mutex_lock(g_vmem_mutex_ptr + id);
- pthread_mutex_unlock(g_vmem_mutex_ptr + id);
- pthread_rwlock_unlock(&g_vmem_rwlock);
+ pthread_mutex_unlock(g_vmem_mutex_ptr + id);
+ pthread_rwlock_unlock(&g_vmem_rwlock);
}
-
-__attribute__((destructor)) void fini(void)
-{
- int i;
- if (NULL != g_vmp_ptr) {
- for (i = 0; i < g_vmp_count; ++i) {
- if (NULL != *(g_vmp_ptr + i)){
- /* vmem_close(*(g_vmp_ptr + i)); undefined function */
- *(g_vmp_ptr + i) = NULL;
- pthread_mutex_destroy(g_vmem_mutex_ptr + i);
- }
- }
- free(g_vmp_ptr);
- g_vmp_ptr = NULL;
- free(g_vmem_mutex_ptr);
- g_vmem_mutex_ptr = NULL;
- g_vmp_count = 0;
- }
+__attribute__((destructor)) void fini(void) {
+ int i;
+ if (NULL != g_vmp_ptr) {
+ for (i = 0; i < g_vmp_count; ++i) {
+ if (NULL != *(g_vmp_ptr + i)) {
+ /* vmem_close(*(g_vmp_ptr + i)); undefined function */
+ *(g_vmp_ptr + i) = NULL;
+ pthread_mutex_destroy(g_vmem_mutex_ptr + i);
+ }
+ }
+ free(g_vmp_ptr);
+ g_vmp_ptr = NULL;
+ free(g_vmem_mutex_ptr);
+ g_vmem_mutex_ptr = NULL;
+ g_vmp_count = 0;
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/551c8247/allocator-services/nvml-vmem-service/src/main/native/org_apache_mnemonic_service_allocatorservice_internal_VMemServiceImpl.h
----------------------------------------------------------------------
diff --git a/allocator-services/nvml-vmem-service/src/main/native/org_apache_mnemonic_service_allocatorservice_internal_VMemServiceImpl.h b/allocator-services/nvml-vmem-service/src/main/native/org_apache_mnemonic_service_allocatorservice_internal_VMemServiceImpl.h
index 9a2e73a..bdea3a7 100644
--- a/allocator-services/nvml-vmem-service/src/main/native/org_apache_mnemonic_service_allocatorservice_internal_VMemServiceImpl.h
+++ b/allocator-services/nvml-vmem-service/src/main/native/org_apache_mnemonic_service_allocatorservice_internal_VMemServiceImpl.h
@@ -1,4 +1,21 @@
-/* DO NOT EDIT THIS FILE - it is machine generated */
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include <jni.h>
/* Header for class org_apache_mnemonic_service_allocatorservice_internal_VMemServiceImpl */
@@ -15,7 +32,7 @@ extern "C" {
* Signature: (II)V
*/
JNIEXPORT void JNICALL Java_org_apache_mnemonic_service_allocatorservice_internal_VMemServiceImpl_jniInit
- (JNIEnv *, jobject, jint, jint);
+(JNIEnv *, jobject, jint, jint);
/*
* Class: org_apache_mnemonic_service_allocatorservice_internal_VMemServiceImpl
@@ -23,7 +40,7 @@ JNIEXPORT void JNICALL Java_org_apache_mnemonic_service_allocatorservice_interna
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_apache_mnemonic_service_allocatorservice_internal_VMemServiceImpl_jniTerm
- (JNIEnv *, jobject);
+(JNIEnv *, jobject);
#ifdef __cplusplus
}
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/551c8247/allocator-services/pmalloc-service/src/main/java/org/apache/mnemonic/service/allocatorservice/internal/PMallocServiceImpl.java
----------------------------------------------------------------------
diff --git a/allocator-services/pmalloc-service/src/main/java/org/apache/mnemonic/service/allocatorservice/internal/PMallocServiceImpl.java b/allocator-services/pmalloc-service/src/main/java/org/apache/mnemonic/service/allocatorservice/internal/PMallocServiceImpl.java
index f96d3b3..0a93f15 100644
--- a/allocator-services/pmalloc-service/src/main/java/org/apache/mnemonic/service/allocatorservice/internal/PMallocServiceImpl.java
+++ b/allocator-services/pmalloc-service/src/main/java/org/apache/mnemonic/service/allocatorservice/internal/PMallocServiceImpl.java
@@ -1,150 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.apache.mnemonic.service.allocatorservice.internal;
import org.apache.mnemonic.service.allocatorservice.NonVolatileMemoryAllocatorService;
import org.flowcomputing.commons.primitives.*;
import java.nio.ByteBuffer;
-
public class PMallocServiceImpl implements NonVolatileMemoryAllocatorService {
- static {
- try {
- NativeLibraryLoader.loadFromJar("pmallocallocator");
- } catch (Exception e) {
- throw new Error(e);
- }
- }
+ static {
+ try {
+ NativeLibraryLoader.loadFromJar("pmallocallocator");
+ } catch (Exception e) {
+ throw new Error(e);
+ }
+ }
+
+ @Override
+ public String getServiceId() {
+ return "pmalloc";
+ }
- @Override
- public String getServiceId() {
- return "pmalloc";
- }
+ @Override
+ public long init(long capacity, String uri, boolean isnew) {
+ return ninit(capacity, uri, isnew);
+ }
- @Override
- public long init(long capacity, String uri, boolean isnew) {
- return ninit(capacity, uri, isnew);
- }
-
- @Override
- public void close(long id) {
- nclose(id);
- }
+ @Override
+ public void close(long id) {
+ nclose(id);
+ }
- @Override
- public void sync(long id) {
- nsync(id);
- }
+ @Override
+ public void sync(long id) {
+ nsync(id);
+ }
- @Override
- public long allocate(long id, long size, boolean initzero) {
- return nallocate(id, size, initzero);
- }
+ @Override
+ public long allocate(long id, long size, boolean initzero) {
+ return nallocate(id, size, initzero);
+ }
- @Override
- public long reallocate(long id, long address, long size, boolean initzero) {
- return nreallocate(id, address, size, initzero);
- }
+ @Override
+ public long reallocate(long id, long address, long size, boolean initzero) {
+ return nreallocate(id, address, size, initzero);
+ }
- @Override
- public void free(long id, long address) {
- nfree(id, address);
- }
+ @Override
+ public void free(long id, long address) {
+ nfree(id, address);
+ }
- @Override
- public ByteBuffer createByteBuffer(long id, long size) {
- return ncreateByteBuffer(id, size);
- }
+ @Override
+ public ByteBuffer createByteBuffer(long id, long size) {
+ return ncreateByteBuffer(id, size);
+ }
- @Override
- public ByteBuffer resizeByteBuffer(long id, ByteBuffer bytebuf, long size) {
- return nresizeByteBuffer(id, bytebuf, size);
- }
+ @Override
+ public ByteBuffer resizeByteBuffer(long id, ByteBuffer bytebuf, long size) {
+ return nresizeByteBuffer(id, bytebuf, size);
+ }
- @Override
- public void destroyByteBuffer(long id, ByteBuffer bytebuf) {
- ndestroyByteBuffer(id, bytebuf);
- }
+ @Override
+ public void destroyByteBuffer(long id, ByteBuffer bytebuf) {
+ ndestroyByteBuffer(id, bytebuf);
+ }
- @Override
- public ByteBuffer retrieveByteBuffer(long id, long handler) {
- return nretrieveByteBuffer(id, handler);
- }
-
- @Override
- public long retrieveSize(long id, long handler) {
- return nretrieveSize(id, handler);
- }
-
- @Override
- public long getByteBufferHandler(long id, ByteBuffer buf) {
- return ngetByteBufferHandler(id, buf);
- }
-
- @Override
- public void setHandler(long id, long key, long handler) {
- nsetHandler(id, key, handler);
- }
-
- @Override
- public long getHandler(long id, long key) {
- return ngetHandler(id, key);
- }
-
- @Override
- public long handlerCapacity(long id) {
- return nhandlerCapacity(id);
- }
-
- @Override
- public long getBaseAddress(long id) {
- return ngetBaseAddress(id);
- }
+ @Override
+ public ByteBuffer retrieveByteBuffer(long id, long handler) {
+ return nretrieveByteBuffer(id, handler);
+ }
- protected native long ninit(long capacity, String uri, boolean isnew);
+ @Override
+ public long retrieveSize(long id, long handler) {
+ return nretrieveSize(id, handler);
+ }
+ @Override
+ public long getByteBufferHandler(long id, ByteBuffer buf) {
+ return ngetByteBufferHandler(id, buf);
+ }
- protected native void nclose(long id);
+ @Override
+ public void setHandler(long id, long key, long handler) {
+ nsetHandler(id, key, handler);
+ }
+ @Override
+ public long getHandler(long id, long key) {
+ return ngetHandler(id, key);
+ }
- protected native void nsync(long id);
+ @Override
+ public long handlerCapacity(long id) {
+ return nhandlerCapacity(id);
+ }
+ @Override
+ public long getBaseAddress(long id) {
+ return ngetBaseAddress(id);
+ }
- protected native long nallocate(long id, long size, boolean initzero);
+ protected native long ninit(long capacity, String uri, boolean isnew);
+ protected native void nclose(long id);
- protected native long nreallocate(long id, long address, long size, boolean initzero);
+ protected native void nsync(long id);
+ protected native long nallocate(long id, long size, boolean initzero);
- protected native void nfree(long id, long address);
+ protected native long nreallocate(long id, long address, long size, boolean initzero);
+ protected native void nfree(long id, long address);
- protected native ByteBuffer ncreateByteBuffer(long id, long size);
+ protected native ByteBuffer ncreateByteBuffer(long id, long size);
+ protected native ByteBuffer nresizeByteBuffer(long id, ByteBuffer bytebuf, long size);
- protected native ByteBuffer nresizeByteBuffer(long id, ByteBuffer bytebuf, long size);
-
+ protected native void ndestroyByteBuffer(long id, ByteBuffer bytebuf);
- protected native void ndestroyByteBuffer(long id, ByteBuffer bytebuf);
-
+ protected native ByteBuffer nretrieveByteBuffer(long id, long handler);
- protected native ByteBuffer nretrieveByteBuffer(long id, long handler);
-
-
- protected native long nretrieveSize(long id, long handler);
-
+ protected native long nretrieveSize(long id, long handler);
- protected native long ngetByteBufferHandler(long id, ByteBuffer buf);
-
+ protected native long ngetByteBufferHandler(long id, ByteBuffer buf);
- protected native void nsetHandler(long id, long key, long handler);
-
+ protected native void nsetHandler(long id, long key, long handler);
- protected native long ngetHandler(long id, long key);
-
+ protected native long ngetHandler(long id, long key);
- protected native long nhandlerCapacity(long id);
-
+ protected native long nhandlerCapacity(long id);
- protected native long ngetBaseAddress(long id);
+ protected native long ngetBaseAddress(long id);
-
}
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/551c8247/allocator-services/pmalloc-service/src/main/native/common.c
----------------------------------------------------------------------
diff --git a/allocator-services/pmalloc-service/src/main/native/common.c b/allocator-services/pmalloc-service/src/main/native/common.c
index e7d6772..143743e 100644
--- a/allocator-services/pmalloc-service/src/main/native/common.c
+++ b/allocator-services/pmalloc-service/src/main/native/common.c
@@ -1,10 +1,23 @@
-/****************************************************************************************
-Revise Date: 20 Apr. 2014
-*****************************************************************************************/
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#include <common.h>
-
/******************************************************************************
** Generally-useful functions for JNI programming.
*****************************************************************************/
@@ -13,13 +26,12 @@ Revise Date: 20 Apr. 2014
* Throws a RuntimeException, with either an explicit message or the message
* corresponding to the current system error value.
*/
-void throw(JNIEnv* env, const char* msg)
-{
- if (msg == NULL)
- msg = sys_errlist[errno];
+void throw(JNIEnv* env, const char* msg) {
+ if (msg == NULL)
+ msg = sys_errlist[errno];
- jclass xklass = (*env)->FindClass(env, "java/lang/RuntimeException");
- (*env)->ThrowNew(env, xklass, msg);
+ jclass xklass = (*env)->FindClass(env, "java/lang/RuntimeException");
+ (*env)->ThrowNew(env, xklass, msg);
}
void* addr_from_java(jlong addr) {
@@ -27,11 +39,11 @@ void* addr_from_java(jlong addr) {
// It is impossible to predict whether native code that converts
// pointers to longs will sign-extend or zero-extend the addresses.
//assert(addr == (uintptr_t)addr, "must not be odd high bits");
- return (void*)(uintptr_t)addr;
+ return (void*) (uintptr_t) addr;
}
jlong addr_to_java(void* p) {
- assert(p == (void*)(uintptr_t)p);
- return (long)(uintptr_t)p;
+ assert(p == (void*) (uintptr_t) p);
+ return (long) (uintptr_t) p;
}
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/551c8247/allocator-services/pmalloc-service/src/main/native/common.h
----------------------------------------------------------------------
diff --git a/allocator-services/pmalloc-service/src/main/native/common.h b/allocator-services/pmalloc-service/src/main/native/common.h
index d2b8250..f03dbff 100644
--- a/allocator-services/pmalloc-service/src/main/native/common.h
+++ b/allocator-services/pmalloc-service/src/main/native/common.h
@@ -1,3 +1,21 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#ifndef _COMMON_H
#define _COMMON_H
#ifdef __cplusplus
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/551c8247/allocator-services/pmalloc-service/src/main/native/org_apache_mnemonic_service_allocatorservice_internal_PMallocServiceImpl.c
----------------------------------------------------------------------
diff --git a/allocator-services/pmalloc-service/src/main/native/org_apache_mnemonic_service_allocatorservice_internal_PMallocServiceImpl.c b/allocator-services/pmalloc-service/src/main/native/org_apache_mnemonic_service_allocatorservice_internal_PMallocServiceImpl.c
index c377e82..b3bf391 100644
--- a/allocator-services/pmalloc-service/src/main/native/org_apache_mnemonic_service_allocatorservice_internal_PMallocServiceImpl.c
+++ b/allocator-services/pmalloc-service/src/main/native/org_apache_mnemonic_service_allocatorservice_internal_PMallocServiceImpl.c
@@ -1,14 +1,28 @@
-/****************************************************************************************
-Revise Date: 20 Apr. 2014
-*****************************************************************************************/
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#include "org_apache_mnemonic_service_allocatorservice_internal_PMallocServiceImpl.h"
#include <pmalloc.h>
typedef struct {
- //size_t size;
- jlong size;
+ //size_t size;
+ jlong size;
} PMBHeader;
#define PMBHSZ (sizeof(PMBHeader))
@@ -25,295 +39,276 @@ static pthread_rwlock_t g_pmp_rwlock = PTHREAD_RWLOCK_INITIALIZER;
*****************************************************************************/
JNIEXPORT
-jlong JNICALL Java_org_apache_mnemonic_service_allocatorservice_internal_PMallocServiceImpl_nallocate(
- JNIEnv* env,
- jobject this, jlong id,
- jlong size, jboolean initzero)
-{
- pthread_rwlock_rdlock(&g_pmp_rwlock);
- pthread_mutex_lock(g_pmalloc_mutex_ptr + id);
- jlong ret = 0L;
- void *md = *(g_pmp_ptr + id);
- void* nativebuf = initzero ? pmcalloc(md, 1, size + PMBHSZ) : pmalloc(md, size + PMBHSZ);
- if (NULL != nativebuf) {
- ((PMBHeader *)nativebuf)->size = size + PMBHSZ;
- ret = addr_to_java(nativebuf + PMBHSZ);
+jlong JNICALL Java_org_apache_mnemonic_service_allocatorservice_internal_PMallocServiceImpl_nallocate(JNIEnv* env,
+ jobject this, jlong id, jlong size, jboolean initzero) {
+ pthread_rwlock_rdlock(&g_pmp_rwlock);
+ pthread_mutex_lock(g_pmalloc_mutex_ptr + id);
+ jlong ret = 0L;
+ void *md = *(g_pmp_ptr + id);
+ void* nativebuf = initzero ? pmcalloc(md, 1, size + PMBHSZ) : pmalloc(md, size + PMBHSZ);
+ if (NULL != nativebuf) {
+ ((PMBHeader *) nativebuf)->size = size + PMBHSZ;
+ ret = addr_to_java(nativebuf + PMBHSZ);
// fprintf(stderr, "### nallocate size: %lld, %X, header size: %ld ### \n",
// ((PMBHeader *)nativebuf)->size, nativebuf-b_addr(*(g_pmp_ptr + id)), PMBHSZ);
- }
- pthread_mutex_unlock(g_pmalloc_mutex_ptr + id);
- pthread_rwlock_unlock(&g_pmp_rwlock);
- return ret;
+ }
+ pthread_mutex_unlock(g_pmalloc_mutex_ptr + id);
+ pthread_rwlock_unlock(&g_pmp_rwlock);
+ return ret;
}
JNIEXPORT
-jlong JNICALL Java_org_apache_mnemonic_service_allocatorservice_internal_PMallocServiceImpl_nreallocate(
- JNIEnv* env,
- jobject this, jlong id,
- jlong address,
- jlong size, jboolean initzero)
-{
- pthread_rwlock_rdlock(&g_pmp_rwlock);
- pthread_mutex_lock(g_pmalloc_mutex_ptr + id);
- jlong ret = 0L;
- void *md = *(g_pmp_ptr + id);
- void* nativebuf = NULL;
- void* p = addr_from_java(address);
- if (NULL != p) {
- nativebuf = pmrealloc(md, p - PMBHSZ, size + PMBHSZ);
- } else {
- nativebuf = initzero ? pmcalloc(md, 1, size + PMBHSZ) : pmalloc(md, size + PMBHSZ);
- }
- if (nativebuf != NULL) {
- ((PMBHeader *)nativebuf)->size = size + PMBHSZ;
- ret = addr_to_java(nativebuf + PMBHSZ);
- }
- pthread_mutex_unlock(g_pmalloc_mutex_ptr + id);
- pthread_rwlock_unlock(&g_pmp_rwlock);
- return ret;
+jlong JNICALL Java_org_apache_mnemonic_service_allocatorservice_internal_PMallocServiceImpl_nreallocate(JNIEnv* env,
+ jobject this, jlong id, jlong address, jlong size, jboolean initzero) {
+ pthread_rwlock_rdlock(&g_pmp_rwlock);
+ pthread_mutex_lock(g_pmalloc_mutex_ptr + id);
+ jlong ret = 0L;
+ void *md = *(g_pmp_ptr + id);
+ void* nativebuf = NULL;
+ void* p = addr_from_java(address);
+ if (NULL != p) {
+ nativebuf = pmrealloc(md, p - PMBHSZ, size + PMBHSZ);
+ } else {
+ nativebuf = initzero ? pmcalloc(md, 1, size + PMBHSZ) : pmalloc(md, size + PMBHSZ);
+ }
+ if (nativebuf != NULL) {
+ ((PMBHeader *) nativebuf)->size = size + PMBHSZ;
+ ret = addr_to_java(nativebuf + PMBHSZ);
+ }
+ pthread_mutex_unlock(g_pmalloc_mutex_ptr + id);
+ pthread_rwlock_unlock(&g_pmp_rwlock);
+ return ret;
}
JNIEXPORT
void JNICALL Java_org_apache_mnemonic_service_allocatorservice_internal_PMallocServiceImpl_nfree(
- JNIEnv* env,
- jobject this, jlong id,
- jlong address)
+ JNIEnv* env,
+ jobject this, jlong id,
+ jlong address)
{
- pthread_rwlock_rdlock(&g_pmp_rwlock);
- pthread_mutex_lock(g_pmalloc_mutex_ptr + id);
- //fprintf(stderr, "nfree Get Called %ld, %X\n", id, address);
- void *md = *(g_pmp_ptr + id);
- void* nativebuf = addr_from_java(address);
- if (nativebuf != NULL) {
+ pthread_rwlock_rdlock(&g_pmp_rwlock);
+ pthread_mutex_lock(g_pmalloc_mutex_ptr + id);
+ //fprintf(stderr, "nfree Get Called %ld, %X\n", id, address);
+ void *md = *(g_pmp_ptr + id);
+ void* nativebuf = addr_from_java(address);
+ if (nativebuf != NULL) {
// fprintf(stderr, "### nfree size: %lld, %X ###, header size: %ld \n",
// ((PMBHeader *)(nativebuf - PMBHSZ))->size, nativebuf - PMBHSZ-b_addr(*(g_pmp_ptr + id)), PMBHSZ);
- pmfree(md, nativebuf - PMBHSZ);
- }
- pthread_mutex_unlock(g_pmalloc_mutex_ptr + id);
- pthread_rwlock_unlock(&g_pmp_rwlock);
+ pmfree(md, nativebuf - PMBHSZ);
+ }
+ pthread_mutex_unlock(g_pmalloc_mutex_ptr + id);
+ pthread_rwlock_unlock(&g_pmp_rwlock);
}
JNIEXPORT
void JNICALL Java_org_apache_mnemonic_service_allocatorservice_internal_PMallocServiceImpl_nsync(
- JNIEnv* env,
- jobject this, jlong id)
+ JNIEnv* env,
+ jobject this, jlong id)
{
}
JNIEXPORT
jobject JNICALL Java_org_apache_mnemonic_service_allocatorservice_internal_PMallocServiceImpl_ncreateByteBuffer(
- JNIEnv *env, jobject this, jlong id, jlong size)
-{
- pthread_rwlock_rdlock(&g_pmp_rwlock);
- pthread_mutex_lock(g_pmalloc_mutex_ptr + id);
- jobject ret = NULL;
- void *md = *(g_pmp_ptr + id);
- void* nativebuf = pmalloc(md, size + PMBHSZ);
- if (NULL != nativebuf) {
- ((PMBHeader *)nativebuf)->size = size + PMBHSZ;
- ret = (*env)->NewDirectByteBuffer(env, nativebuf + PMBHSZ, size);
+ JNIEnv *env, jobject this, jlong id, jlong size) {
+ pthread_rwlock_rdlock(&g_pmp_rwlock);
+ pthread_mutex_lock(g_pmalloc_mutex_ptr + id);
+ jobject ret = NULL;
+ void *md = *(g_pmp_ptr + id);
+ void* nativebuf = pmalloc(md, size + PMBHSZ);
+ if (NULL != nativebuf) {
+ ((PMBHeader *) nativebuf)->size = size + PMBHSZ;
+ ret = (*env)->NewDirectByteBuffer(env, nativebuf + PMBHSZ, size);
// fprintf(stderr, "### ncreateByteBuffer size: %lld, %X ###, header size: %ld \n",
// ((PMBHeader *)nativebuf)->size, nativebuf-b_addr(*(g_pmp_ptr + id)), PMBHSZ);
- }
- pthread_mutex_unlock(g_pmalloc_mutex_ptr + id);
- pthread_rwlock_unlock(&g_pmp_rwlock);
- return ret;
+ }
+ pthread_mutex_unlock(g_pmalloc_mutex_ptr + id);
+ pthread_rwlock_unlock(&g_pmp_rwlock);
+ return ret;
}
JNIEXPORT
jobject JNICALL Java_org_apache_mnemonic_service_allocatorservice_internal_PMallocServiceImpl_nretrieveByteBuffer(
- JNIEnv *env, jobject this, jlong id, jlong e_addr)
-{
- jobject ret = NULL;
- void* p = addr_from_java(e_addr);
- if (NULL != p) {
- void* nativebuf = p - PMBHSZ;
- ret = (*env)->NewDirectByteBuffer(env, p, ((PMBHeader *)nativebuf)->size - PMBHSZ);
- }
- return ret;
+ JNIEnv *env, jobject this, jlong id, jlong e_addr) {
+ jobject ret = NULL;
+ void* p = addr_from_java(e_addr);
+ if (NULL != p) {
+ void* nativebuf = p - PMBHSZ;
+ ret = (*env)->NewDirectByteBuffer(env, p, ((PMBHeader *) nativebuf)->size - PMBHSZ);
+ }
+ return ret;
}
JNIEXPORT
-jlong JNICALL Java_org_apache_mnemonic_service_allocatorservice_internal_PMallocServiceImpl_nretrieveSize(
- JNIEnv *env, jobject this, jlong id, jlong e_addr)
-{
- jlong ret = 0L;
- void* p = addr_from_java(e_addr);
- if (NULL != p) {
- void* nativebuf = p - PMBHSZ;
- ret = ((PMBHeader *)nativebuf)->size - PMBHSZ;
+jlong JNICALL Java_org_apache_mnemonic_service_allocatorservice_internal_PMallocServiceImpl_nretrieveSize(JNIEnv *env,
+ jobject this, jlong id, jlong e_addr) {
+ jlong ret = 0L;
+ void* p = addr_from_java(e_addr);
+ if (NULL != p) {
+ void* nativebuf = p - PMBHSZ;
+ ret = ((PMBHeader *) nativebuf)->size - PMBHSZ;
// fprintf(stderr, "### nretrieveSize size: %lld, %X ###, header size: %ld \n",
// ((PMBHeader *)nativebuf)->size, nativebuf-b_addr(*(g_pmp_ptr + id)), PMBHSZ);
- }
- return ret;
+ }
+ return ret;
}
JNIEXPORT
jlong JNICALL Java_org_apache_mnemonic_service_allocatorservice_internal_PMallocServiceImpl_ngetByteBufferHandler(
- JNIEnv *env, jobject this, jlong id, jobject bytebuf)
-{
+ JNIEnv *env, jobject this, jlong id, jobject bytebuf) {
// fprintf(stderr, "ngetByteBufferAddress Get Called %X, %X\n", env, bytebuf);
- jlong ret = 0L;
- if (NULL != bytebuf) {
- void* nativebuf = (*env)->GetDirectBufferAddress(env, bytebuf);
+ jlong ret = 0L;
+ if (NULL != bytebuf) {
+ void* nativebuf = (*env)->GetDirectBufferAddress(env, bytebuf);
// fprintf(stderr, "ngetByteBufferAddress Get Native address %X\n", nativebuf);
- ret = addr_to_java(nativebuf);
- }
+ ret = addr_to_java(nativebuf);
+ }
// fprintf(stderr, "ngetByteBufferAddress returned address %016lx\n", ret);
- return ret;
+ return ret;
}
JNIEXPORT
jobject JNICALL Java_org_apache_mnemonic_service_allocatorservice_internal_PMallocServiceImpl_nresizeByteBuffer(
- JNIEnv *env, jobject this, jlong id, jobject bytebuf, jlong size)
-{
- pthread_rwlock_rdlock(&g_pmp_rwlock);
- pthread_mutex_lock(g_pmalloc_mutex_ptr + id);
- jobject ret = NULL;
- void *md = *(g_pmp_ptr + id);
- if (NULL != bytebuf) {
- void* nativebuf = (*env)->GetDirectBufferAddress(env, bytebuf);
- if (nativebuf != NULL) {
- nativebuf = pmrealloc(md, nativebuf - PMBHSZ, size + PMBHSZ);
- if (NULL != nativebuf) {
- ((PMBHeader *)nativebuf)->size = size + PMBHSZ;
- ret = (*env)->NewDirectByteBuffer(env, nativebuf + PMBHSZ, size);
- }
- }
+ JNIEnv *env, jobject this, jlong id, jobject bytebuf, jlong size) {
+ pthread_rwlock_rdlock(&g_pmp_rwlock);
+ pthread_mutex_lock(g_pmalloc_mutex_ptr + id);
+ jobject ret = NULL;
+ void *md = *(g_pmp_ptr + id);
+ if (NULL != bytebuf) {
+ void* nativebuf = (*env)->GetDirectBufferAddress(env, bytebuf);
+ if (nativebuf != NULL) {
+ nativebuf = pmrealloc(md, nativebuf - PMBHSZ, size + PMBHSZ);
+ if (NULL != nativebuf) {
+ ((PMBHeader *) nativebuf)->size = size + PMBHSZ;
+ ret = (*env)->NewDirectByteBuffer(env, nativebuf + PMBHSZ, size);
+ }
}
- pthread_mutex_unlock(g_pmalloc_mutex_ptr + id);
- pthread_rwlock_unlock(&g_pmp_rwlock);
- return ret;
+ }
+ pthread_mutex_unlock(g_pmalloc_mutex_ptr + id);
+ pthread_rwlock_unlock(&g_pmp_rwlock);
+ return ret;
}
JNIEXPORT
void JNICALL Java_org_apache_mnemonic_service_allocatorservice_internal_PMallocServiceImpl_ndestroyByteBuffer(
- JNIEnv *env, jobject this, jlong id, jobject bytebuf)
+ JNIEnv *env, jobject this, jlong id, jobject bytebuf)
{
- pthread_rwlock_rdlock(&g_pmp_rwlock);
- pthread_mutex_lock(g_pmalloc_mutex_ptr + id);
- void *md = *(g_pmp_ptr + id);
- if (NULL != bytebuf) {
- void* nativebuf = (*env)->GetDirectBufferAddress(env, bytebuf);
- if (nativebuf != NULL) {
+ pthread_rwlock_rdlock(&g_pmp_rwlock);
+ pthread_mutex_lock(g_pmalloc_mutex_ptr + id);
+ void *md = *(g_pmp_ptr + id);
+ if (NULL != bytebuf) {
+ void* nativebuf = (*env)->GetDirectBufferAddress(env, bytebuf);
+ if (nativebuf != NULL) {
// fprintf(stderr, "### ndestroyByteBuffer size: %lld, %X, header size: %ld ### \n",
// ((PMBHeader *)(nativebuf - PMBHSZ))->size, nativebuf - PMBHSZ -b_addr(*(g_pmp_ptr + id)), PMBHSZ);
- pmfree(md, nativebuf - PMBHSZ);
- }
+ pmfree(md, nativebuf - PMBHSZ);
}
- pthread_mutex_unlock(g_pmalloc_mutex_ptr + id);
- pthread_rwlock_unlock(&g_pmp_rwlock);
+ }
+ pthread_mutex_unlock(g_pmalloc_mutex_ptr + id);
+ pthread_rwlock_unlock(&g_pmp_rwlock);
}
JNIEXPORT
void JNICALL Java_org_apache_mnemonic_service_allocatorservice_internal_PMallocServiceImpl_nsetHandler(
- JNIEnv *env, jobject this, jlong id, jlong key, jlong value)
+ JNIEnv *env, jobject this, jlong id, jlong key, jlong value)
{
- pthread_rwlock_rdlock(&g_pmp_rwlock);
- pthread_mutex_lock(g_pmalloc_mutex_ptr + id);
- void *md = *(g_pmp_ptr + id);
- if (id < PMALLOC_KEYS && id >= 0) {
- pmalloc_setkey(md, key, (void*)value);
- }
- pthread_mutex_unlock(g_pmalloc_mutex_ptr + id);
- pthread_rwlock_unlock(&g_pmp_rwlock);
+ pthread_rwlock_rdlock(&g_pmp_rwlock);
+ pthread_mutex_lock(g_pmalloc_mutex_ptr + id);
+ void *md = *(g_pmp_ptr + id);
+ if (id < PMALLOC_KEYS && id >= 0) {
+ pmalloc_setkey(md, key, (void*)value);
+ }
+ pthread_mutex_unlock(g_pmalloc_mutex_ptr + id);
+ pthread_rwlock_unlock(&g_pmp_rwlock);
}
JNIEXPORT
-jlong JNICALL Java_org_apache_mnemonic_service_allocatorservice_internal_PMallocServiceImpl_ngetHandler(
- JNIEnv *env, jobject this, jlong id, jlong key)
-{
- pthread_rwlock_rdlock(&g_pmp_rwlock);
- pthread_mutex_lock(g_pmalloc_mutex_ptr + id);
- void *md = *(g_pmp_ptr + id);
- jlong ret = (id < PMALLOC_KEYS && id >= 0) ? (long)pmalloc_getkey(md, key) : 0;
- pthread_mutex_unlock(g_pmalloc_mutex_ptr + id);
- pthread_rwlock_unlock(&g_pmp_rwlock);
- return ret;
+jlong JNICALL Java_org_apache_mnemonic_service_allocatorservice_internal_PMallocServiceImpl_ngetHandler(JNIEnv *env,
+ jobject this, jlong id, jlong key) {
+ pthread_rwlock_rdlock(&g_pmp_rwlock);
+ pthread_mutex_lock(g_pmalloc_mutex_ptr + id);
+ void *md = *(g_pmp_ptr + id);
+ jlong ret = (id < PMALLOC_KEYS && id >= 0) ? (long) pmalloc_getkey(md, key) : 0;
+ pthread_mutex_unlock(g_pmalloc_mutex_ptr + id);
+ pthread_rwlock_unlock(&g_pmp_rwlock);
+ return ret;
}
JNIEXPORT
jlong JNICALL Java_org_apache_mnemonic_service_allocatorservice_internal_PMallocServiceImpl_nhandlerCapacity(
- JNIEnv *env, jobject this)
-{
- return PMALLOC_KEYS;
+ JNIEnv *env, jobject this) {
+ return PMALLOC_KEYS;
}
JNIEXPORT
-jlong JNICALL Java_org_apache_mnemonic_service_allocatorservice_internal_PMallocServiceImpl_ngetBaseAddress(
- JNIEnv *env, jobject this, jlong id)
-{
- pthread_rwlock_rdlock(&g_pmp_rwlock);
- void *md = *(g_pmp_ptr + id);
- jlong ret = (long)b_addr(md);
- pthread_rwlock_unlock(&g_pmp_rwlock);
- return ret;
+jlong JNICALL Java_org_apache_mnemonic_service_allocatorservice_internal_PMallocServiceImpl_ngetBaseAddress(JNIEnv *env,
+ jobject this, jlong id) {
+ pthread_rwlock_rdlock(&g_pmp_rwlock);
+ void *md = *(g_pmp_ptr + id);
+ jlong ret = (long) b_addr(md);
+ pthread_rwlock_unlock(&g_pmp_rwlock);
+ return ret;
}
-JNIEXPORT
-jlong JNICALL Java_org_apache_mnemonic_service_allocatorservice_internal_PMallocServiceImpl_ninit
- (JNIEnv *env, jclass this, jlong capacity, jstring pathname, jboolean isnew)
-{
- pthread_rwlock_wrlock(&g_pmp_rwlock);
- size_t ret = -1;
- void *md = NULL;
- const char* mpathname = (*env)->GetStringUTFChars(env, pathname, NULL);
- if (NULL == mpathname) {
- pthread_rwlock_unlock(&g_pmp_rwlock);
- throw(env, "Big memory path not specified!");
- }
- if ((md = pmopen(mpathname, NULL, capacity)) == NULL) {
- pthread_rwlock_unlock(&g_pmp_rwlock);
- throw(env, "Big memory init failure!");
- }
- (*env)->ReleaseStringUTFChars(env, pathname, mpathname);
- g_pmp_ptr = realloc(g_pmp_ptr, (g_pmp_count + 1) * sizeof(void*));
- g_pmalloc_mutex_ptr =
- realloc(g_pmalloc_mutex_ptr, (g_pmp_count + 1) * sizeof(pthread_mutex_t));
- if (NULL != g_pmp_ptr && NULL != g_pmalloc_mutex_ptr) {
- *(g_pmp_ptr + g_pmp_count) = md;
- pthread_mutex_init(g_pmalloc_mutex_ptr + g_pmp_count, NULL);
- ret = g_pmp_count;
- ++g_pmp_count;
- } else {
- pthread_rwlock_unlock(&g_pmp_rwlock);
- throw(env, "Big memory init Out of memory!");
- }
- pthread_rwlock_unlock(&g_pmp_rwlock);
- return ret;
+JNIEXPORT
+jlong JNICALL Java_org_apache_mnemonic_service_allocatorservice_internal_PMallocServiceImpl_ninit(JNIEnv *env,
+ jclass this, jlong capacity, jstring pathname, jboolean isnew) {
+ pthread_rwlock_wrlock(&g_pmp_rwlock);
+ size_t ret = -1;
+ void *md = NULL;
+ const char* mpathname = (*env)->GetStringUTFChars(env, pathname, NULL);
+ if (NULL == mpathname) {
+ pthread_rwlock_unlock(&g_pmp_rwlock);
+ throw(env, "Big memory path not specified!");
+ }
+ if ((md = pmopen(mpathname, NULL, capacity)) == NULL) {
+ pthread_rwlock_unlock(&g_pmp_rwlock);
+ throw(env, "Big memory init failure!");
+ }
+ (*env)->ReleaseStringUTFChars(env, pathname, mpathname);
+ g_pmp_ptr = realloc(g_pmp_ptr, (g_pmp_count + 1) * sizeof(void*));
+ g_pmalloc_mutex_ptr = realloc(g_pmalloc_mutex_ptr, (g_pmp_count + 1) * sizeof(pthread_mutex_t));
+ if (NULL != g_pmp_ptr && NULL != g_pmalloc_mutex_ptr) {
+ *(g_pmp_ptr + g_pmp_count) = md;
+ pthread_mutex_init(g_pmalloc_mutex_ptr + g_pmp_count, NULL);
+ ret = g_pmp_count;
+ ++g_pmp_count;
+ } else {
+ pthread_rwlock_unlock(&g_pmp_rwlock);
+ throw(env, "Big memory init Out of memory!");
+ }
+ pthread_rwlock_unlock(&g_pmp_rwlock);
+ return ret;
}
-JNIEXPORT
+JNIEXPORT
void JNICALL Java_org_apache_mnemonic_service_allocatorservice_internal_PMallocServiceImpl_nclose
- (JNIEnv *env, jobject this, jlong id)
+(JNIEnv *env, jobject this, jlong id)
{
- pthread_rwlock_rdlock(&g_pmp_rwlock);
- pthread_mutex_lock(g_pmalloc_mutex_ptr + id);
- void *md = *(g_pmp_ptr + id);
- pmclose(md);
- *(g_pmp_ptr + id) = NULL;
- pthread_mutex_unlock(g_pmalloc_mutex_ptr + id);
- pthread_mutex_destroy(g_pmalloc_mutex_ptr + id);
- pthread_rwlock_unlock(&g_pmp_rwlock);
+ pthread_rwlock_rdlock(&g_pmp_rwlock);
+ pthread_mutex_lock(g_pmalloc_mutex_ptr + id);
+ void *md = *(g_pmp_ptr + id);
+ pmclose(md);
+ *(g_pmp_ptr + id) = NULL;
+ pthread_mutex_unlock(g_pmalloc_mutex_ptr + id);
+ pthread_mutex_destroy(g_pmalloc_mutex_ptr + id);
+ pthread_rwlock_unlock(&g_pmp_rwlock);
}
-
-__attribute__((destructor)) void fini(void)
-{
- int i;
- if (NULL != g_pmp_ptr) {
- for (i = 0; i < g_pmp_count; ++i) {
- if (NULL != *(g_pmp_ptr + i)){
- pmclose(*(g_pmp_ptr + i));
- *(g_pmp_ptr + i) = NULL;
- pthread_mutex_destroy(g_pmalloc_mutex_ptr + i);
- }
- }
- free(g_pmp_ptr);
- g_pmp_ptr = NULL;
- free(g_pmalloc_mutex_ptr);
- g_pmalloc_mutex_ptr = NULL;
- g_pmp_count = 0;
- }
- pthread_rwlock_destroy(&g_pmp_rwlock);
+__attribute__((destructor)) void fini(void) {
+ int i;
+ if (NULL != g_pmp_ptr) {
+ for (i = 0; i < g_pmp_count; ++i) {
+ if (NULL != *(g_pmp_ptr + i)) {
+ pmclose(*(g_pmp_ptr + i));
+ *(g_pmp_ptr + i) = NULL;
+ pthread_mutex_destroy(g_pmalloc_mutex_ptr + i);
+ }
+ }
+ free(g_pmp_ptr);
+ g_pmp_ptr = NULL;
+ free(g_pmalloc_mutex_ptr);
+ g_pmalloc_mutex_ptr = NULL;
+ g_pmp_count = 0;
+ }
+ pthread_rwlock_destroy(&g_pmp_rwlock);
}
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/551c8247/allocator-services/pmalloc-service/src/main/native/org_apache_mnemonic_service_allocatorservice_internal_PMallocServiceImpl.h
----------------------------------------------------------------------
diff --git a/allocator-services/pmalloc-service/src/main/native/org_apache_mnemonic_service_allocatorservice_internal_PMallocServiceImpl.h b/allocator-services/pmalloc-service/src/main/native/org_apache_mnemonic_service_allocatorservice_internal_PMallocServiceImpl.h
index 4b119c7..7550462 100644
--- a/allocator-services/pmalloc-service/src/main/native/org_apache_mnemonic_service_allocatorservice_internal_PMallocServiceImpl.h
+++ b/allocator-services/pmalloc-service/src/main/native/org_apache_mnemonic_service_allocatorservice_internal_PMallocServiceImpl.h
@@ -1,4 +1,21 @@
-/* DO NOT EDIT THIS FILE - it is machine generated */
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include <jni.h>
/* Header for class PMallocServiceImpl */
@@ -15,7 +32,7 @@ extern "C" {
* Signature: (II)V
*/
JNIEXPORT void JNICALL Java_org_apache_mnemonic_service_allocatorservice_internal_PMallocServiceImpl_jniInit
- (JNIEnv *, jobject, jint, jint);
+(JNIEnv *, jobject, jint, jint);
/*
* Class: org_apache_mnemonic_service_allocatorservice_internal_PMallocServiceImpl
@@ -23,7 +40,7 @@ JNIEXPORT void JNICALL Java_org_apache_mnemonic_service_allocatorservice_interna
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_apache_mnemonic_service_allocatorservice_internal_PMallocServiceImpl_jniTerm
- (JNIEnv *, jobject);
+(JNIEnv *, jobject);
#ifdef __cplusplus
}
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/551c8247/collections/src/main/java/org/apache/mnemonic/collections/NonVolatileNodeValue.java
----------------------------------------------------------------------
diff --git a/collections/src/main/java/org/apache/mnemonic/collections/NonVolatileNodeValue.java b/collections/src/main/java/org/apache/mnemonic/collections/NonVolatileNodeValue.java
index d7f45e4..98375e9 100644
--- a/collections/src/main/java/org/apache/mnemonic/collections/NonVolatileNodeValue.java
+++ b/collections/src/main/java/org/apache/mnemonic/collections/NonVolatileNodeValue.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.apache.mnemonic.collections;
import java.util.Arrays;
@@ -7,144 +24,145 @@ import java.util.NoSuchElementException;
import org.apache.mnemonic.*;
/**
- * this class defines a non-volatile node for a generic value to form a unidirectional link
+ * this class defines a non-volatile node for a generic value to form a
+ * unidirectional link
*
*/
@NonVolatileEntity
-public abstract class NonVolatileNodeValue<E>
- implements Durable, Iterable<E> {
- protected transient EntityFactoryProxy[] m_node_efproxies;
- protected transient GenericField.GType[] m_node_gftypes;
+public abstract class NonVolatileNodeValue<E> implements Durable, Iterable<E> {
+ protected transient EntityFactoryProxy[] m_node_efproxies;
+ protected transient GenericField.GType[] m_node_gftypes;
- /**
- * creation callback for initialization
- *
- */
- @Override
- public void initializeAfterCreate() {
- // System.out.println("Initializing After Created");
- }
+ /**
+ * creation callback for initialization
+ *
+ */
+ @Override
+ public void initializeAfterCreate() {
+ // System.out.println("Initializing After Created");
+ }
- /**
- * restore callback for initialization
- *
- */
- @Override
- public void initializeAfterRestore() {
- // System.out.println("Initializing After Restored");
- }
+ /**
+ * restore callback for initialization
+ *
+ */
+ @Override
+ public void initializeAfterRestore() {
+ // System.out.println("Initializing After Restored");
+ }
- /**
- * this function will be invoked by its factory to setup generic related info to avoid expensive operations from reflection
- *
- * @param efproxies
- * specify a array of factory to proxy the restoring of its generic field objects
- *
- * @param gftypes
- * specify a array of types corresponding to efproxies
- */
- @Override
- public void setupGenericInfo(EntityFactoryProxy[] efproxies, GenericField.GType[] gftypes) {
- m_node_efproxies = efproxies;
- m_node_gftypes = gftypes;
- }
+ /**
+ * this function will be invoked by its factory to setup generic related info
+ * to avoid expensive operations from reflection
+ *
+ * @param efproxies
+ * specify a array of factory to proxy the restoring of its generic
+ * field objects
+ *
+ * @param gftypes
+ * specify a array of types corresponding to efproxies
+ */
+ @Override
+ public void setupGenericInfo(EntityFactoryProxy[] efproxies, GenericField.GType[] gftypes) {
+ m_node_efproxies = efproxies;
+ m_node_gftypes = gftypes;
+ }
- /**
- * get the item value of this node
- *
- * @return the item value of this node
- */
- @NonVolatileGetter(Id = 1L, EntityFactoryProxies = "m_node_efproxies", GenericFieldTypes = "m_node_gftypes")
- abstract public E getItem();
+ /**
+ * get the item value of this node
+ *
+ * @return the item value of this node
+ */
+ @NonVolatileGetter(Id = 1L, EntityFactoryProxies = "m_node_efproxies", GenericFieldTypes = "m_node_gftypes")
+ abstract public E getItem();
- /**
- * set a value to this node item
- *
- * @param value
- * the value to be set
- *
- * @param destroy
- * true if want to destroy exist one
- *
- */
- @NonVolatileSetter
- abstract public void setItem(E value, boolean destroy);
+ /**
+ * set a value to this node item
+ *
+ * @param value
+ * the value to be set
+ *
+ * @param destroy
+ * true if want to destroy exist one
+ *
+ */
+ @NonVolatileSetter
+ abstract public void setItem(E value, boolean destroy);
+
+ /**
+ * get next node
+ *
+ * @return the next node
+ *
+ */
+ @NonVolatileGetter(Id = 2L, EntityFactoryProxies = "m_node_efproxies", GenericFieldTypes = "m_node_gftypes")
+ abstract public NonVolatileNodeValue<E> getNext();
+
+ /**
+ * set next node
+ *
+ * @param next
+ * specify the next node
+ *
+ * @param destroy
+ * true if want to destroy the exist node
+ */
+ @NonVolatileSetter
+ abstract public void setNext(NonVolatileNodeValue<E> next, boolean destroy);
+
+ /**
+ * get an iterator instance of this list
+ *
+ * @return an iterator of this list
+ */
+ @Override
+ public Iterator<E> iterator() {
+ return new Intr(this);
+ }
+
+ /**
+ * this class defines a iterator for this non-volatile list
+ *
+ */
+ private class Intr implements Iterator<E> {
+
+ protected NonVolatileNodeValue<E> next = null;
/**
- * get next node
+ * Constructor
*
- * @return the next node
+ * @param head
+ * the start point for this iterator
*
*/
- @NonVolatileGetter(Id = 2L, EntityFactoryProxies = "m_node_efproxies", GenericFieldTypes = "m_node_gftypes")
- abstract public NonVolatileNodeValue<E> getNext();
+ Intr(NonVolatileNodeValue<E> head) {
+ next = head;
+ }
/**
- * set next node
+ * determine the existing of next
*
- * @param next
- * specify the next node
- *
- * @param destroy
- * true if want to destroy the exist node
- */
- @NonVolatileSetter
- abstract public void setNext(NonVolatileNodeValue<E> next, boolean destroy);
-
-
- /**
- * get an iterator instance of this list
+ * @return true if there is a next node
*
- * @return an iterator of this list
*/
@Override
- public Iterator<E> iterator() {
- return new Intr(this);
+ public boolean hasNext() {
+ return null != next;
}
-
+
/**
- * this class defines a iterator for this non-volatile list
+ * get next node
*
+ * @return the next node
*/
- private class Intr implements Iterator<E> {
-
- protected NonVolatileNodeValue<E> next = null;
-
- /**
- * Constructor
- *
- * @param head
- * the start point for this iterator
- *
- */
- Intr(NonVolatileNodeValue<E> head) {
- next = head;
- }
-
- /**
- * determine the existing of next
- *
- * @return true if there is a next node
- *
- */
- @Override
- public boolean hasNext() {
- return null != next;
- }
-
- /**
- * get next node
- *
- * @return the next node
- */
- @Override
- public E next() {
- if (null == next) {
- new NoSuchElementException();
- }
- E ret = next.getItem();
- next = next.getNext();
- return ret;
- }
+ @Override
+ public E next() {
+ if (null == next) {
+ new NoSuchElementException();
+ }
+ E ret = next.getItem();
+ next = next.getNext();
+ return ret;
}
+ }
}