You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ds...@apache.org on 2016/03/10 01:50:08 UTC
incubator-geode git commit: removed old logging code from offheap
Repository: incubator-geode
Updated Branches:
refs/heads/feature/GEODE-1070 [created] 694dc17c0
removed old logging code from offheap
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/694dc17c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/694dc17c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/694dc17c
Branch: refs/heads/feature/GEODE-1070
Commit: 694dc17c0376c1d295d366e28ce37aa286d13c77
Parents: 445efdb
Author: Darrel Schneider <ds...@pivotal.io>
Authored: Wed Mar 9 16:48:49 2016 -0800
Committer: Darrel Schneider <ds...@pivotal.io>
Committed: Wed Mar 9 16:48:49 2016 -0800
----------------------------------------------------------------------
.../internal/InternalDistributedSystem.java | 2 +-
.../cache/control/OffHeapMemoryMonitor.java | 45 ++++++++--------
.../internal/offheap/FreeListManager.java | 20 +++----
.../internal/offheap/OffHeapStorage.java | 9 ++--
.../OffHeapStoredObjectAddressStack.java | 6 +--
.../offheap/SimpleMemoryAllocatorImpl.java | 47 +++++++----------
.../internal/offheap/FreeListManagerTest.java | 5 +-
.../offheap/OffHeapHelperJUnitTest.java | 5 +-
.../OffHeapRegionEntryHelperJUnitTest.java | 4 +-
.../offheap/OffHeapStorageJUnitTest.java | 12 ++---
...ffHeapStoredObjectAddressStackJUnitTest.java | 9 ++--
.../offheap/OffHeapStoredObjectJUnitTest.java | 4 +-
.../offheap/SimpleMemoryAllocatorJUnitTest.java | 55 ++++----------------
13 files changed, 82 insertions(+), 141 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/694dc17c/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/InternalDistributedSystem.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/InternalDistributedSystem.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/InternalDistributedSystem.java
index 92cb9f8..8fc884a 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/InternalDistributedSystem.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/InternalDistributedSystem.java
@@ -614,7 +614,7 @@ public class InternalDistributedSystem
final long offHeapMemorySize = OffHeapStorage.parseOffHeapMemorySize(getConfig().getOffHeapMemorySize());
- this.offHeapStore = OffHeapStorage.createOffHeapStorage(getLogWriter(), this, offHeapMemorySize, this);
+ this.offHeapStore = OffHeapStorage.createOffHeapStorage(this, offHeapMemorySize, this);
// Note: this can only happen on a linux system
if (getConfig().getLockMemory()) {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/694dc17c/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/control/OffHeapMemoryMonitor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/control/OffHeapMemoryMonitor.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/control/OffHeapMemoryMonitor.java
index 3ab39ea..100d560 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/control/OffHeapMemoryMonitor.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/control/OffHeapMemoryMonitor.java
@@ -21,8 +21,6 @@ import java.util.Set;
import org.apache.logging.log4j.Logger;
import com.gemstone.gemfire.CancelException;
-import com.gemstone.gemfire.LogWriter;
-import com.gemstone.gemfire.i18n.LogWriterI18n;
import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
import com.gemstone.gemfire.internal.cache.control.InternalResourceManager.ResourceType;
import com.gemstone.gemfire.internal.cache.control.MemoryThresholds.MemoryState;
@@ -30,6 +28,7 @@ import com.gemstone.gemfire.internal.cache.control.ResourceAdvisor.ResourceManag
import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
import com.gemstone.gemfire.internal.logging.LogService;
import com.gemstone.gemfire.internal.logging.LoggingThreadGroup;
+import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage;
import com.gemstone.gemfire.internal.offheap.MemoryAllocator;
import com.gemstone.gemfire.internal.offheap.MemoryUsageListener;
@@ -67,7 +66,6 @@ public class OffHeapMemoryMonitor implements ResourceMonitor, MemoryUsageListene
* does not have off-heap memory. So we need to handle memoryAllocator being null.
*/
private final MemoryAllocator memoryAllocator;
- private final LogWriterI18n log;
OffHeapMemoryMonitor(final InternalResourceManager resourceManager, final GemFireCacheImpl cache, final MemoryAllocator memoryAllocator, final ResourceManagerStats stats) {
this.resourceManager = resourceManager;
@@ -80,7 +78,6 @@ public class OffHeapMemoryMonitor implements ResourceMonitor, MemoryUsageListene
this.thresholds = new MemoryThresholds(this.memoryAllocator.getTotalMemory());
}
- this.log = cache.getLoggerI18n();
this.offHeapMemoryUsageListener = new OffHeapMemoryUsageListener();
}
@@ -439,28 +436,28 @@ public class OffHeapMemoryMonitor implements ResourceMonitor, MemoryUsageListene
void processLocalEvent(MemoryEvent event) {
assert event.isLocal();
- if (this.log.fineEnabled()) {
- this.log.fine("Handling new local event " + event);
+ if (logger.isDebugEnabled()) {
+ logger.debug("Handling new local event {}", event);
}
if (event.getState().isCritical() && !event.getPreviousState().isCritical()) {
- this.log.error(LocalizedStrings.MemoryMonitor_MEMBER_ABOVE_CRITICAL_THRESHOLD,
- new Object[] { event.getMember(), "off-heap" });
+ logger.error(LocalizedMessage.create(LocalizedStrings.MemoryMonitor_MEMBER_ABOVE_CRITICAL_THRESHOLD,
+ new Object[] { event.getMember(), "off-heap" }));
} else if (!event.getState().isCritical() && event.getPreviousState().isCritical()) {
- this.log.error(LocalizedStrings.MemoryMonitor_MEMBER_BELOW_CRITICAL_THRESHOLD,
- new Object[] { event.getMember(), "off-heap" });
+ logger.error(LocalizedMessage.create(LocalizedStrings.MemoryMonitor_MEMBER_BELOW_CRITICAL_THRESHOLD,
+ new Object[] { event.getMember(), "off-heap" }));
}
if (event.getState().isEviction() && !event.getPreviousState().isEviction()) {
- this.log.info(LocalizedStrings.MemoryMonitor_MEMBER_ABOVE_HIGH_THRESHOLD,
- new Object[] { event.getMember(), "off-heap" });
+ logger.info(LocalizedMessage.create(LocalizedStrings.MemoryMonitor_MEMBER_ABOVE_HIGH_THRESHOLD,
+ new Object[] { event.getMember(), "off-heap" }));
} else if (!event.getState().isEviction() && event.getPreviousState().isEviction()) {
- this.log.info(LocalizedStrings.MemoryMonitor_MEMBER_BELOW_HIGH_THRESHOLD,
- new Object[] { event.getMember(), "off-heap" });
+ logger.info(LocalizedMessage.create(LocalizedStrings.MemoryMonitor_MEMBER_BELOW_HIGH_THRESHOLD,
+ new Object[] { event.getMember(), "off-heap" }));
}
- if (this.log.fineEnabled()) {
- this.log.fine("Informing remote members of event " + event);
+ if (logger.isDebugEnabled()) {
+ logger.debug("Informing remote members of event {}", event);
}
this.resourceAdvisor.updateRemoteProfile();
@@ -475,15 +472,11 @@ public class OffHeapMemoryMonitor implements ResourceMonitor, MemoryUsageListene
} catch (CancelException ignore) {
// ignore
} catch (Throwable t) {
- this.log.error(LocalizedStrings.MemoryMonitor_EXCEPTION_OCCURED_WHEN_NOTIFYING_LISTENERS, t);
+ logger.error(LocalizedMessage.create(LocalizedStrings.MemoryMonitor_EXCEPTION_OCCURED_WHEN_NOTIFYING_LISTENERS), t);
}
}
}
- LogWriter getLogWriter() {
- return this.log.convertToLogWriter();
- }
-
@Override
public String toString() {
return "OffHeapMemoryMonitor [thresholds=" + this.thresholds + ", mostRecentEvent=" + this.mostRecentEvent + "]";
@@ -508,7 +501,9 @@ public class OffHeapMemoryMonitor implements ResourceMonitor, MemoryUsageListene
@Override
public void run() {
- getLogWriter().fine("OffHeapMemoryUsageListener is starting " + this);
+ if (logger.isDebugEnabled()) {
+ logger.debug("OffHeapMemoryUsageListener is starting {}", this);
+ }
int callsWithNoEvent = 0;
final int MS_TIMEOUT = 10;
final int MAX_CALLS_WITH_NO_EVENT = 1000/MS_TIMEOUT;
@@ -541,7 +536,7 @@ public class OffHeapMemoryMonitor implements ResourceMonitor, MemoryUsageListene
this.wait(MS_TIMEOUT);
this.deliverEvent = false;
} catch (InterruptedException iex) {
- getLogWriter().warning("OffHeapMemoryUsageListener was interrupted " + this);
+ logger.warn("OffHeapMemoryUsageListener was interrupted {}", this);
this.stopRequested = true;
exitRunLoop = true;
}
@@ -549,7 +544,9 @@ public class OffHeapMemoryMonitor implements ResourceMonitor, MemoryUsageListene
}
}
- getLogWriter().fine("OffHeapMemoryUsageListener is stopping " + this);
+ if (logger.isDebugEnabled()) {
+ logger.debug("OffHeapMemoryUsageListener is stopping {}", this);
+ }
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/694dc17c/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/FreeListManager.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/FreeListManager.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/FreeListManager.java
index ed7035a..05010ab 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/FreeListManager.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/FreeListManager.java
@@ -29,14 +29,17 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReferenceArray;
-import com.gemstone.gemfire.LogWriter;
+import org.apache.logging.log4j.Logger;
+
import com.gemstone.gemfire.OutOfOffHeapMemoryException;
-import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
+import com.gemstone.gemfire.internal.logging.LogService;
/**
* Manages the free lists for a SimpleMemoryAllocatorImpl
*/
public class FreeListManager {
+ static final Logger logger = LogService.getLogger();
+
/** The MemoryChunks that this allocator is managing by allocating smaller chunks of them.
* The contents of this array never change.
*/
@@ -232,13 +235,10 @@ public class FreeListManager {
}
private void logOffHeapState(int chunkSize) {
- if (InternalDistributedSystem.getAnyInstance() != null) {
- LogWriter lw = InternalDistributedSystem.getAnyInstance().getLogWriter();
- logOffHeapState(lw, chunkSize);
- }
+ logOffHeapState(logger, chunkSize);
}
- void logOffHeapState(LogWriter lw, int chunkSize) {
+ void logOffHeapState(Logger lw, int chunkSize) {
OffHeapMemoryStats stats = this.ma.getStats();
lw.info("OutOfOffHeapMemory allocating size of " + chunkSize + ". allocated=" + this.allocatedSize.get() + " compactions=" + this.compactCount.get() + " objects=" + stats.getObjects() + " free=" + stats.getFreeMemory() + " fragments=" + stats.getFragments() + " largestFragment=" + stats.getLargestFragment() + " fragmentation=" + stats.getFragmentation());
logFragmentState(lw);
@@ -246,12 +246,12 @@ public class FreeListManager {
logHugeState(lw);
}
- private void logHugeState(LogWriter lw) {
+ private void logHugeState(Logger lw) {
for (OffHeapStoredObject c: this.hugeChunkSet) {
lw.info("Free huge of size " + c.getSize());
}
}
- private void logTinyState(LogWriter lw) {
+ private void logTinyState(Logger lw) {
for (int i=0; i < this.tinyFreeLists.length(); i++) {
OffHeapStoredObjectAddressStack cl = this.tinyFreeLists.get(i);
if (cl != null) {
@@ -259,7 +259,7 @@ public class FreeListManager {
}
}
}
- private void logFragmentState(LogWriter lw) {
+ private void logFragmentState(Logger lw) {
for (Fragment f: this.fragmentList) {
int freeSpace = f.freeSpace();
if (freeSpace > 0) {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/694dc17c/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapStorage.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapStorage.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapStorage.java
index 3156067..9c6c75a 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapStorage.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapStorage.java
@@ -18,7 +18,6 @@ package com.gemstone.gemfire.internal.offheap;
import java.lang.reflect.Method;
-import com.gemstone.gemfire.LogWriter;
import com.gemstone.gemfire.StatisticDescriptor;
import com.gemstone.gemfire.Statistics;
import com.gemstone.gemfire.StatisticsFactory;
@@ -171,7 +170,7 @@ public class OffHeapStorage implements OffHeapMemoryStats {
* Constructs a MemoryAllocator for off-heap storage.
* @return MemoryAllocator for off-heap storage
*/
- public static MemoryAllocator createOffHeapStorage(LogWriter lw, StatisticsFactory sf, long offHeapMemorySize, DistributedSystem system) {
+ public static MemoryAllocator createOffHeapStorage(StatisticsFactory sf, long offHeapMemorySize, DistributedSystem system) {
if (offHeapMemorySize == 0 || Boolean.getBoolean(InternalLocator.FORCE_LOCATOR_DM_TYPE)) {
// Checking the FORCE_LOCATOR_DM_TYPE is a quick hack to keep our locator from allocating off heap memory.
return null;
@@ -189,10 +188,10 @@ public class OffHeapStorage implements OffHeapMemoryStats {
}
// ooohml provides the hook for disconnecting and closing cache on OutOfOffHeapMemoryException
OutOfOffHeapMemoryListener ooohml = new DisconnectingOutOfOffHeapMemoryListener((InternalDistributedSystem) system);
- return basicCreateOffHeapStorage(lw, sf, offHeapMemorySize, ooohml);
+ return basicCreateOffHeapStorage(sf, offHeapMemorySize, ooohml);
}
- static MemoryAllocator basicCreateOffHeapStorage(LogWriter lw, StatisticsFactory sf, long offHeapMemorySize, OutOfOffHeapMemoryListener ooohml) {
+ static MemoryAllocator basicCreateOffHeapStorage(StatisticsFactory sf, long offHeapMemorySize, OutOfOffHeapMemoryListener ooohml) {
final OffHeapMemoryStats stats = new OffHeapStorage(sf);
// determine off-heap and slab sizes
@@ -200,7 +199,7 @@ public class OffHeapStorage implements OffHeapMemoryStats {
final int slabCount = calcSlabCount(maxSlabSize, offHeapMemorySize);
- return SimpleMemoryAllocatorImpl.create(ooohml, stats, lw, slabCount, offHeapMemorySize, maxSlabSize);
+ return SimpleMemoryAllocatorImpl.create(ooohml, stats, slabCount, offHeapMemorySize, maxSlabSize);
}
private static final long MAX_SLAB_SIZE = Integer.MAX_VALUE;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/694dc17c/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObjectAddressStack.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObjectAddressStack.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObjectAddressStack.java
index bde30e2..40d0143 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObjectAddressStack.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObjectAddressStack.java
@@ -16,7 +16,7 @@
*/
package com.gemstone.gemfire.internal.offheap;
-import com.gemstone.gemfire.LogWriter;
+import org.apache.logging.log4j.Logger;
/**
* A "stack" of addresses of OffHeapStoredObject instances. The stored objects are not kept
@@ -77,7 +77,7 @@ public class OffHeapStoredObjectAddressStack {
}
return result;
}
- public void logSizes(LogWriter lw, String msg) {
+ public void logSizes(Logger logger, String msg) {
long headAddr = this.topAddr;
long addr;
boolean concurrentModDetected;
@@ -99,7 +99,7 @@ public class OffHeapStoredObjectAddressStack {
}
// TODO construct a single log msg
// that gets reset when concurrentModDetected.
- lw.info(msg + curSize);
+ logger.info(msg + curSize);
}
} while (concurrentModDetected);
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/694dc17c/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorImpl.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorImpl.java
index 209a4a4..f7fa888 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorImpl.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorImpl.java
@@ -28,7 +28,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.logging.log4j.Logger;
-import com.gemstone.gemfire.LogWriter;
import com.gemstone.gemfire.cache.CacheClosedException;
import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.RegionService;
@@ -87,10 +86,10 @@ public class SimpleMemoryAllocatorImpl implements MemoryAllocator {
private static final boolean DO_EXPENSIVE_VALIDATION = Boolean.getBoolean("gemfire.OFF_HEAP_DO_EXPENSIVE_VALIDATION");
- public static MemoryAllocator create(OutOfOffHeapMemoryListener ooohml, OffHeapMemoryStats stats, LogWriter lw,
- int slabCount, long offHeapMemorySize, long maxSlabSize) {
- return create(ooohml, stats, lw, slabCount, offHeapMemorySize, maxSlabSize,
- null, new SlabFactory() {
+ public static MemoryAllocator create(OutOfOffHeapMemoryListener ooohml, OffHeapMemoryStats stats, int slabCount,
+ long offHeapMemorySize, long maxSlabSize) {
+ return create(ooohml, stats, slabCount, offHeapMemorySize, maxSlabSize, null,
+ new SlabFactory() {
@Override
public Slab create(int size) {
return new SlabImpl(size);
@@ -98,26 +97,21 @@ public class SimpleMemoryAllocatorImpl implements MemoryAllocator {
});
}
- private static SimpleMemoryAllocatorImpl create(OutOfOffHeapMemoryListener ooohml, OffHeapMemoryStats stats, LogWriter lw,
- int slabCount, long offHeapMemorySize, long maxSlabSize,
- Slab[] slabs, SlabFactory slabFactory) {
+ private static SimpleMemoryAllocatorImpl create(OutOfOffHeapMemoryListener ooohml, OffHeapMemoryStats stats, int slabCount,
+ long offHeapMemorySize, long maxSlabSize, Slab[] slabs,
+ SlabFactory slabFactory) {
SimpleMemoryAllocatorImpl result = singleton;
boolean created = false;
try {
if (result != null) {
- result.reuse(ooohml, lw, stats, offHeapMemorySize, slabs);
- if (lw != null) {
- lw.config("Reusing " + result.getTotalMemory() + " bytes of off-heap memory. The maximum size of a single off-heap object is " + result.freeList.getLargestSlabSize() + " bytes.");
- }
+ result.reuse(ooohml, stats, offHeapMemorySize, slabs);
+ logger.info("Reusing {} bytes of off-heap memory. The maximum size of a single off-heap object is {} bytes.", result.getTotalMemory(), result.freeList.getLargestSlabSize());
created = true;
LifecycleListener.invokeAfterReuse(result);
} else {
if (slabs == null) {
// allocate memory chunks
- //SimpleMemoryAllocatorImpl.cleanupPreviousAllocator();
- if (lw != null) {
- lw.config("Allocating " + offHeapMemorySize + " bytes of off-heap memory. The maximum size of a single off-heap object is " + maxSlabSize + " bytes.");
- }
+ logger.info("Allocating {} bytes of off-heap memory. The maximum size of a single off-heap object is {} bytes.", offHeapMemorySize, maxSlabSize);
slabs = new SlabImpl[slabCount];
long uncreatedMemory = offHeapMemorySize;
for (int i=0; i < slabCount; i++) {
@@ -131,9 +125,7 @@ public class SimpleMemoryAllocatorImpl implements MemoryAllocator {
}
} catch (OutOfMemoryError err) {
if (i > 0) {
- if (lw != null) {
- lw.severe("Off-heap memory creation failed after successfully allocating " + (i*maxSlabSize) + " bytes of off-heap memory.");
- }
+ logger.error("Off-heap memory creation failed after successfully allocating {} bytes of off-heap memory.", (i*maxSlabSize));
}
for (int j=0; j < i; j++) {
if (slabs[j] != null) {
@@ -162,10 +154,10 @@ public class SimpleMemoryAllocatorImpl implements MemoryAllocator {
}
return result;
}
- static SimpleMemoryAllocatorImpl createForUnitTest(OutOfOffHeapMemoryListener ooohml, OffHeapMemoryStats stats, LogWriter lw,
- int slabCount, long offHeapMemorySize, long maxSlabSize, SlabFactory memChunkFactory) {
- return create(ooohml, stats, lw, slabCount, offHeapMemorySize, maxSlabSize,
- null, memChunkFactory);
+ static SimpleMemoryAllocatorImpl createForUnitTest(OutOfOffHeapMemoryListener ooohml, OffHeapMemoryStats stats, int slabCount,
+ long offHeapMemorySize, long maxSlabSize, SlabFactory memChunkFactory) {
+ return create(ooohml, stats, slabCount, offHeapMemorySize, maxSlabSize, null,
+ memChunkFactory);
}
public static SimpleMemoryAllocatorImpl createForUnitTest(OutOfOffHeapMemoryListener oooml, OffHeapMemoryStats stats, Slab[] slabs) {
int slabCount = 0;
@@ -181,11 +173,11 @@ public class SimpleMemoryAllocatorImpl implements MemoryAllocator {
}
}
}
- return create(oooml, stats, null, slabCount, offHeapMemorySize, maxSlabSize, slabs, null);
+ return create(oooml, stats, slabCount, offHeapMemorySize, maxSlabSize, slabs, null);
}
- private void reuse(OutOfOffHeapMemoryListener oooml, LogWriter lw, OffHeapMemoryStats newStats, long offHeapMemorySize, Slab[] slabs) {
+ private void reuse(OutOfOffHeapMemoryListener oooml, OffHeapMemoryStats newStats, long offHeapMemorySize, Slab[] slabs) {
if (isClosed()) {
throw new IllegalStateException("Can not reuse a closed off-heap memory manager.");
}
@@ -193,9 +185,7 @@ public class SimpleMemoryAllocatorImpl implements MemoryAllocator {
throw new IllegalArgumentException("OutOfOffHeapMemoryListener is null");
}
if (getTotalMemory() != offHeapMemorySize) {
- if (lw != null) {
- lw.warning("Using " + getTotalMemory() + " bytes of existing off-heap memory instead of the requested " + offHeapMemorySize);
- }
+ logger.warn("Using {} bytes of existing off-heap memory instead of the requested {}.", getTotalMemory(), offHeapMemorySize);
}
if (!this.freeList.okToReuse(slabs)) {
throw new IllegalStateException("attempted to reuse existing off-heap memory even though new off-heap memory was allocated");
@@ -213,7 +203,6 @@ public class SimpleMemoryAllocatorImpl implements MemoryAllocator {
this.ooohml = oooml;
this.stats = stats;
- //OSProcess.printStacks(0, InternalDistributedSystem.getAnyInstance().getLogWriter(), false);
this.stats.setFragments(slabs.length);
this.stats.setLargestFragment(slabs[0].getSize());
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/694dc17c/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListManagerTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListManagerTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListManagerTest.java
index 3787129..382bd98 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListManagerTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListManagerTest.java
@@ -25,6 +25,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicReferenceArray;
+import org.apache.logging.log4j.Logger;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
@@ -33,8 +34,6 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import com.gemstone.gemfire.LogWriter;
-import com.gemstone.gemfire.OutOfOffHeapMemoryException;
import com.gemstone.gemfire.test.junit.categories.UnitTest;
@Category(UnitTest.class)
@@ -736,7 +735,7 @@ public class FreeListManagerTest {
OffHeapStoredObject.release(c.getAddress(), this.freeListManager);
OffHeapStoredObject.release(c2.getAddress(), this.freeListManager);
- LogWriter lw = mock(LogWriter.class);
+ Logger lw = mock(Logger.class);
this.freeListManager.logOffHeapState(lw, 1024);
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/694dc17c/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapHelperJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapHelperJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapHelperJUnitTest.java
index 989abfc..fa4e776 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapHelperJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapHelperJUnitTest.java
@@ -27,7 +27,6 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import com.gemstone.gemfire.LogWriter;
import com.gemstone.gemfire.internal.cache.EntryEventImpl;
import com.gemstone.gemfire.internal.cache.VMCachedDeserializable;
import com.gemstone.gemfire.test.junit.categories.UnitTest;
@@ -47,10 +46,8 @@ public class OffHeapHelperJUnitTest extends AbstractStoredObjectTestBase {
public void setUp() {
OutOfOffHeapMemoryListener ooohml = mock(OutOfOffHeapMemoryListener.class);
OffHeapMemoryStats stats = mock(OffHeapMemoryStats.class);
- LogWriter lw = mock(LogWriter.class);
- ma = SimpleMemoryAllocatorImpl.create(ooohml, stats, lw, 3, OffHeapStorage.MIN_SLAB_SIZE * 3,
- OffHeapStorage.MIN_SLAB_SIZE);
+ ma = SimpleMemoryAllocatorImpl.create(ooohml, stats, 3, OffHeapStorage.MIN_SLAB_SIZE * 3, OffHeapStorage.MIN_SLAB_SIZE);
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/694dc17c/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelperJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelperJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelperJUnitTest.java
index 540bba5..cf47a72 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelperJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelperJUnitTest.java
@@ -37,7 +37,6 @@ import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
-import com.gemstone.gemfire.LogWriter;
import com.gemstone.gemfire.compression.Compressor;
import com.gemstone.gemfire.internal.DSCODE;
import com.gemstone.gemfire.internal.cache.CachePerfStats;
@@ -65,9 +64,8 @@ public class OffHeapRegionEntryHelperJUnitTest {
public void setUp() {
OutOfOffHeapMemoryListener ooohml = mock(OutOfOffHeapMemoryListener.class);
OffHeapMemoryStats stats = mock(OffHeapMemoryStats.class);
- LogWriter lw = mock(LogWriter.class);
- ma = SimpleMemoryAllocatorImpl.create(ooohml, stats, lw, 1, OffHeapStorage.MIN_SLAB_SIZE * 1, OffHeapStorage.MIN_SLAB_SIZE);
+ ma = SimpleMemoryAllocatorImpl.create(ooohml, stats, 1, OffHeapStorage.MIN_SLAB_SIZE * 1, OffHeapStorage.MIN_SLAB_SIZE);
}
@After
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/694dc17c/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStorageJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStorageJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStorageJUnitTest.java
index d5db4e4..d878358 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStorageJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStorageJUnitTest.java
@@ -122,17 +122,17 @@ public class OffHeapStorageJUnitTest {
@Test
public void createOffHeapStorageReturnsNullIfForceLocator() {
System.setProperty(InternalLocator.FORCE_LOCATOR_DM_TYPE, "true");
- assertEquals(null, OffHeapStorage.createOffHeapStorage(null, null, 1, null));
+ assertEquals(null, OffHeapStorage.createOffHeapStorage(null, 1, null));
}
@Test
public void createOffHeapStorageReturnsNullIfMemorySizeIsZero() {
- assertEquals(null, OffHeapStorage.createOffHeapStorage(null, null, 0, null));
+ assertEquals(null, OffHeapStorage.createOffHeapStorage(null, 0, null));
}
@Test
public void exceptionIfSlabCountTooSmall() {
StatisticsFactory statsFactory = mock(StatisticsFactory.class);
try {
- OffHeapStorage.createOffHeapStorage(null, statsFactory, OffHeapStorage.MIN_SLAB_SIZE-1, null);
+ OffHeapStorage.createOffHeapStorage(statsFactory, OffHeapStorage.MIN_SLAB_SIZE-1, null);
} catch (IllegalArgumentException expected) {
expected.getMessage().equals("The amount of off heap memory must be at least " + OffHeapStorage.MIN_SLAB_SIZE + " but it was set to " + (OffHeapStorage.MIN_SLAB_SIZE-1));
}
@@ -141,7 +141,7 @@ public class OffHeapStorageJUnitTest {
public void exceptionIfDistributedSystemNull() {
StatisticsFactory statsFactory = mock(StatisticsFactory.class);
try {
- OffHeapStorage.createOffHeapStorage(null, statsFactory, OffHeapStorage.MIN_SLAB_SIZE, (DistributedSystem)null);
+ OffHeapStorage.createOffHeapStorage(statsFactory, OffHeapStorage.MIN_SLAB_SIZE, (DistributedSystem)null);
} catch (IllegalArgumentException expected) {
expected.getMessage().equals("InternalDistributedSystem is null");
}
@@ -151,7 +151,7 @@ public class OffHeapStorageJUnitTest {
public void createOffHeapStorageWorks() {
StatisticsFactory localStatsFactory = new LocalStatisticsFactory(null);
InternalDistributedSystem ids = mock(InternalDistributedSystem.class);
- MemoryAllocator ma = OffHeapStorage.createOffHeapStorage(null, localStatsFactory, OffHeapStorage.MIN_SLAB_SIZE, ids);
+ MemoryAllocator ma = OffHeapStorage.createOffHeapStorage(localStatsFactory, OffHeapStorage.MIN_SLAB_SIZE, ids);
System.setProperty(SimpleMemoryAllocatorImpl.FREE_OFF_HEAP_MEMORY_PROPERTY, "true");
ma.close();
}
@@ -160,7 +160,7 @@ public class OffHeapStorageJUnitTest {
public void testCreateOffHeapStorage() {
StatisticsFactory localStatsFactory = new LocalStatisticsFactory(null);
OutOfOffHeapMemoryListener ooohml = mock(OutOfOffHeapMemoryListener.class);
- MemoryAllocator ma = OffHeapStorage.basicCreateOffHeapStorage(null, localStatsFactory, 1024*1024, ooohml);
+ MemoryAllocator ma = OffHeapStorage.basicCreateOffHeapStorage(localStatsFactory, 1024*1024, ooohml);
try {
OffHeapMemoryStats stats = ma.getStats();
assertNotNull(stats.getStats());
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/694dc17c/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObjectAddressStackJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObjectAddressStackJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObjectAddressStackJUnitTest.java
index 8040bf7..884787f 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObjectAddressStackJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObjectAddressStackJUnitTest.java
@@ -19,6 +19,8 @@ package com.gemstone.gemfire.internal.offheap;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
+import org.apache.logging.log4j.Logger;
+
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
@@ -28,7 +30,6 @@ import org.junit.experimental.categories.Category;
import org.mockito.listeners.InvocationListener;
import org.mockito.listeners.MethodInvocationReport;
-import com.gemstone.gemfire.LogWriter;
import com.gemstone.gemfire.test.junit.categories.UnitTest;
@Category(UnitTest.class)
@@ -87,7 +88,7 @@ public class OffHeapStoredObjectAddressStackJUnitTest {
@Test
public void defaultStackLogsNothing() {
OffHeapStoredObjectAddressStack stack = new OffHeapStoredObjectAddressStack();
- LogWriter lw = mock(LogWriter.class, withSettings().invocationListeners(new InvocationListener() {
+ Logger lw = mock(Logger.class, withSettings().invocationListeners(new InvocationListener() {
@Override
public void reportInvocation(MethodInvocationReport methodInvocationReport) {
fail("Unexpected invocation");
@@ -223,7 +224,7 @@ public class OffHeapStoredObjectAddressStackJUnitTest {
long addr = chunk.getAddress();
OffHeapStoredObjectAddressStack stack = new OffHeapStoredObjectAddressStack();
stack.offer(addr);
- LogWriter lw = mock(LogWriter.class);
+ Logger lw = mock(Logger.class);
stack.logSizes(lw, "foo");
verify(lw).info("foo"+chunkSize);
} finally {
@@ -278,7 +279,7 @@ public class OffHeapStoredObjectAddressStackJUnitTest {
long addr = chunk.getAddress();
TestableSyncChunkStack stack = new TestableSyncChunkStack(ma);
stack.offer(addr);
- LogWriter lw = mock(LogWriter.class);
+ Logger lw = mock(Logger.class);
stack.logSizes(lw, "foo");
verify(lw).info("foo"+chunkSize);
verify(lw).info("foo"+stack.chunk2Size);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/694dc17c/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObjectJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObjectJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObjectJUnitTest.java
index 2f6b32c..956acb4 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObjectJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObjectJUnitTest.java
@@ -38,7 +38,6 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import com.gemstone.gemfire.LogWriter;
import com.gemstone.gemfire.compression.Compressor;
import com.gemstone.gemfire.internal.DSCODE;
import com.gemstone.gemfire.internal.HeapDataOutputStream;
@@ -63,9 +62,8 @@ public class OffHeapStoredObjectJUnitTest extends AbstractStoredObjectTestBase {
public void setUp() {
OutOfOffHeapMemoryListener ooohml = mock(OutOfOffHeapMemoryListener.class);
OffHeapMemoryStats stats = mock(OffHeapMemoryStats.class);
- LogWriter lw = mock(LogWriter.class);
- ma = SimpleMemoryAllocatorImpl.create(ooohml, stats, lw, 3, OffHeapStorage.MIN_SLAB_SIZE * 3, OffHeapStorage.MIN_SLAB_SIZE);
+ ma = SimpleMemoryAllocatorImpl.create(ooohml, stats, 3, OffHeapStorage.MIN_SLAB_SIZE * 3, OffHeapStorage.MIN_SLAB_SIZE);
}
@After
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/694dc17c/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorJUnitTest.java
index cc791fc..135aba2 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorJUnitTest.java
@@ -58,62 +58,27 @@ public class SimpleMemoryAllocatorJUnitTest {
} catch (IllegalArgumentException expected) {
}
}
- /**
- * Logger that remembers the last severe message
- */
- private static class LastSevereLogger extends NullLogWriter {
- private String lastSevereMessage;
- private Throwable lastSevereThrowable;
-
- private void setLastSevere(String msg, Throwable ex) {
- this.lastSevereMessage = msg;
- this.lastSevereThrowable = ex;
- }
- public String getLastSevereMessage() {
- return this.lastSevereMessage;
- }
- public Throwable getLastSevereThrowable() {
- return this.lastSevereThrowable;
- }
- @Override
- public void severe(String msg, Throwable ex) {
- setLastSevere(msg, ex);
- }
- @Override
- public void severe(String msg) {
- setLastSevere(msg, null);
- }
- @Override
- public void severe(Throwable ex) {
- setLastSevere(null, ex);
- }
- }
@Test
public void testCreate() {
System.setProperty(SimpleMemoryAllocatorImpl.FREE_OFF_HEAP_MEMORY_PROPERTY, "false");
{
NullOutOfOffHeapMemoryListener listener = new NullOutOfOffHeapMemoryListener();
NullOffHeapMemoryStats stats = new NullOffHeapMemoryStats();
- LastSevereLogger logger = new LastSevereLogger();
try {
- SimpleMemoryAllocatorImpl.createForUnitTest(listener, stats, logger, 10, 950, 100,
- new SlabFactory() {
- @Override
- public Slab create(int size) {
- throw new OutOfMemoryError("expected");
- }
- });
+ SimpleMemoryAllocatorImpl.createForUnitTest(listener, stats, 10, 950, 100, new SlabFactory() {
+ @Override
+ public Slab create(int size) {
+ throw new OutOfMemoryError("expected");
+ }
+ });
} catch (OutOfMemoryError expected) {
}
assertTrue(listener.isClosed());
assertTrue(stats.isClosed());
- assertEquals(null, logger.getLastSevereThrowable());
- assertEquals(null, logger.getLastSevereMessage());
}
{
NullOutOfOffHeapMemoryListener listener = new NullOutOfOffHeapMemoryListener();
NullOffHeapMemoryStats stats = new NullOffHeapMemoryStats();
- LastSevereLogger logger = new LastSevereLogger();
int MAX_SLAB_SIZE = 100;
try {
SlabFactory factory = new SlabFactory() {
@@ -128,13 +93,11 @@ public class SimpleMemoryAllocatorJUnitTest {
}
}
};
- SimpleMemoryAllocatorImpl.createForUnitTest(listener, stats, logger, 10, 950, MAX_SLAB_SIZE, factory);
+ SimpleMemoryAllocatorImpl.createForUnitTest(listener, stats, 10, 950, MAX_SLAB_SIZE, factory);
} catch (OutOfMemoryError expected) {
}
assertTrue(listener.isClosed());
assertTrue(stats.isClosed());
- assertEquals(null, logger.getLastSevereThrowable());
- assertEquals("Off-heap memory creation failed after successfully allocating " + MAX_SLAB_SIZE + " bytes of off-heap memory.", logger.getLastSevereMessage());
}
{
NullOutOfOffHeapMemoryListener listener = new NullOutOfOffHeapMemoryListener();
@@ -146,7 +109,7 @@ public class SimpleMemoryAllocatorJUnitTest {
}
};
MemoryAllocator ma =
- SimpleMemoryAllocatorImpl.createForUnitTest(listener, stats, new NullLogWriter(), 10, 950, 100, factory);
+ SimpleMemoryAllocatorImpl.createForUnitTest(listener, stats, 10, 950, 100, factory);
try {
assertFalse(listener.isClosed());
assertFalse(stats.isClosed());
@@ -171,7 +134,7 @@ public class SimpleMemoryAllocatorJUnitTest {
}
listener = new NullOutOfOffHeapMemoryListener();
stats2 = new NullOffHeapMemoryStats();
- MemoryAllocator ma2 = SimpleMemoryAllocatorImpl.createForUnitTest(listener, stats2, new NullLogWriter(), 10, 950, 100, factory);
+ MemoryAllocator ma2 = SimpleMemoryAllocatorImpl.createForUnitTest(listener, stats2, 10, 950, 100, factory);
assertSame(ma, ma2);
assertTrue(stats.isClosed());
assertFalse(listener.isClosed());