Renames to align with the new API
This commit is contained in:
parent
b4b0afd787
commit
0c49c887e6
@ -2,7 +2,7 @@ package io.netty.buffer.api.pool;
|
|||||||
|
|
||||||
import io.netty.buffer.api.BufferAllocator;
|
import io.netty.buffer.api.BufferAllocator;
|
||||||
|
|
||||||
public interface ByteBufAllocatorMetric {
|
public interface BufferAllocatorMetric {
|
||||||
/**
|
/**
|
||||||
* Returns the number of bytes of heap memory used by a {@link BufferAllocator} or {@code -1} if unknown.
|
* Returns the number of bytes of heap memory used by a {@link BufferAllocator} or {@code -1} if unknown.
|
||||||
*/
|
*/
|
@ -0,0 +1,11 @@
|
|||||||
|
package io.netty.buffer.api.pool;
|
||||||
|
|
||||||
|
import io.netty.buffer.api.BufferAllocator;
|
||||||
|
|
||||||
|
public interface BufferAllocatorMetricProvider {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a {@link BufferAllocatorMetric} for a {@link BufferAllocator}.
|
||||||
|
*/
|
||||||
|
BufferAllocatorMetric metric();
|
||||||
|
}
|
@ -1,11 +0,0 @@
|
|||||||
package io.netty.buffer.api.pool;
|
|
||||||
|
|
||||||
import io.netty.buffer.api.BufferAllocator;
|
|
||||||
|
|
||||||
public interface ByteBufAllocatorMetricProvider {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a {@link ByteBufAllocatorMetric} for a {@link BufferAllocator}.
|
|
||||||
*/
|
|
||||||
ByteBufAllocatorMetric metric();
|
|
||||||
}
|
|
@ -21,7 +21,7 @@ class PoolArena extends SizeClasses implements PoolArenaMetric, AllocatorControl
|
|||||||
Normal
|
Normal
|
||||||
}
|
}
|
||||||
|
|
||||||
final PooledByteBufAllocator parent;
|
final PooledBufferAllocator parent;
|
||||||
final MemoryManager manager;
|
final MemoryManager manager;
|
||||||
|
|
||||||
final int numSmallSubpagePools;
|
final int numSmallSubpagePools;
|
||||||
@ -54,7 +54,7 @@ class PoolArena extends SizeClasses implements PoolArenaMetric, AllocatorControl
|
|||||||
// Number of thread caches backed by this arena.
|
// Number of thread caches backed by this arena.
|
||||||
final AtomicInteger numThreadCaches = new AtomicInteger();
|
final AtomicInteger numThreadCaches = new AtomicInteger();
|
||||||
|
|
||||||
protected PoolArena(PooledByteBufAllocator parent, MemoryManager manager, int pageSize,
|
protected PoolArena(PooledBufferAllocator parent, MemoryManager manager, int pageSize,
|
||||||
int pageShifts, int chunkSize, int cacheAlignment) {
|
int pageShifts, int chunkSize, int cacheAlignment) {
|
||||||
super(pageSize, pageShifts, chunkSize, cacheAlignment);
|
super(pageSize, pageShifts, chunkSize, cacheAlignment);
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
|
@ -3,7 +3,6 @@ package io.netty.buffer.api.pool;
|
|||||||
import static io.netty.util.internal.ObjectUtil.checkPositiveOrZero;
|
import static io.netty.util.internal.ObjectUtil.checkPositiveOrZero;
|
||||||
import static java.util.Objects.requireNonNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import io.netty.buffer.api.AllocatorControl;
|
|
||||||
import io.netty.buffer.api.Buffer;
|
import io.netty.buffer.api.Buffer;
|
||||||
import io.netty.buffer.api.BufferAllocator;
|
import io.netty.buffer.api.BufferAllocator;
|
||||||
import io.netty.buffer.api.MemoryManager;
|
import io.netty.buffer.api.MemoryManager;
|
||||||
@ -23,9 +22,9 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class PooledByteBufAllocator implements BufferAllocator, ByteBufAllocatorMetricProvider {
|
public class PooledBufferAllocator implements BufferAllocator, BufferAllocatorMetricProvider {
|
||||||
|
|
||||||
private static final InternalLogger logger = InternalLoggerFactory.getInstance(PooledByteBufAllocator.class);
|
private static final InternalLogger logger = InternalLoggerFactory.getInstance(PooledBufferAllocator.class);
|
||||||
private static final int DEFAULT_NUM_HEAP_ARENA;
|
private static final int DEFAULT_NUM_HEAP_ARENA;
|
||||||
private static final int DEFAULT_NUM_DIRECT_ARENA;
|
private static final int DEFAULT_NUM_DIRECT_ARENA;
|
||||||
|
|
||||||
@ -152,22 +151,22 @@ public class PooledByteBufAllocator implements BufferAllocator, ByteBufAllocator
|
|||||||
private final List<PoolArenaMetric> arenaMetrics;
|
private final List<PoolArenaMetric> arenaMetrics;
|
||||||
private final PoolThreadLocalCache threadCache;
|
private final PoolThreadLocalCache threadCache;
|
||||||
private final int chunkSize;
|
private final int chunkSize;
|
||||||
private final PooledByteBufAllocatorMetric metric;
|
private final PooledBufferAllocatorMetric metric;
|
||||||
|
|
||||||
public PooledByteBufAllocator(MemoryManager manager) {
|
public PooledBufferAllocator(MemoryManager manager) {
|
||||||
this(manager, manager.isNative()? DEFAULT_NUM_DIRECT_ARENA : DEFAULT_NUM_HEAP_ARENA,
|
this(manager, manager.isNative()? DEFAULT_NUM_DIRECT_ARENA : DEFAULT_NUM_HEAP_ARENA,
|
||||||
DEFAULT_PAGE_SIZE, DEFAULT_MAX_ORDER, DEFAULT_SMALL_CACHE_SIZE,
|
DEFAULT_PAGE_SIZE, DEFAULT_MAX_ORDER, DEFAULT_SMALL_CACHE_SIZE,
|
||||||
DEFAULT_NORMAL_CACHE_SIZE, DEFAULT_USE_CACHE_FOR_ALL_THREADS,
|
DEFAULT_NORMAL_CACHE_SIZE, DEFAULT_USE_CACHE_FOR_ALL_THREADS,
|
||||||
DEFAULT_DIRECT_MEMORY_CACHE_ALIGNMENT);
|
DEFAULT_DIRECT_MEMORY_CACHE_ALIGNMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PooledByteBufAllocator(MemoryManager manager, int numArenas, int pageSize, int maxOrder) {
|
public PooledBufferAllocator(MemoryManager manager, int numArenas, int pageSize, int maxOrder) {
|
||||||
this(manager, numArenas, pageSize, maxOrder, DEFAULT_SMALL_CACHE_SIZE,
|
this(manager, numArenas, pageSize, maxOrder, DEFAULT_SMALL_CACHE_SIZE,
|
||||||
DEFAULT_NORMAL_CACHE_SIZE, DEFAULT_USE_CACHE_FOR_ALL_THREADS,
|
DEFAULT_NORMAL_CACHE_SIZE, DEFAULT_USE_CACHE_FOR_ALL_THREADS,
|
||||||
DEFAULT_DIRECT_MEMORY_CACHE_ALIGNMENT);
|
DEFAULT_DIRECT_MEMORY_CACHE_ALIGNMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PooledByteBufAllocator(MemoryManager manager, int numArenas, int pageSize, int maxOrder,
|
public PooledBufferAllocator(MemoryManager manager, int numArenas, int pageSize, int maxOrder,
|
||||||
int smallCacheSize, int normalCacheSize,
|
int smallCacheSize, int normalCacheSize,
|
||||||
boolean useCacheForAllThreads) {
|
boolean useCacheForAllThreads) {
|
||||||
this(manager, numArenas, pageSize, maxOrder,
|
this(manager, numArenas, pageSize, maxOrder,
|
||||||
@ -175,7 +174,7 @@ public class PooledByteBufAllocator implements BufferAllocator, ByteBufAllocator
|
|||||||
useCacheForAllThreads, DEFAULT_DIRECT_MEMORY_CACHE_ALIGNMENT);
|
useCacheForAllThreads, DEFAULT_DIRECT_MEMORY_CACHE_ALIGNMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PooledByteBufAllocator(MemoryManager manager, int numArenas, int pageSize, int maxOrder,
|
public PooledBufferAllocator(MemoryManager manager, int numArenas, int pageSize, int maxOrder,
|
||||||
int smallCacheSize, int normalCacheSize,
|
int smallCacheSize, int normalCacheSize,
|
||||||
boolean useCacheForAllThreads, int directMemoryCacheAlignment) {
|
boolean useCacheForAllThreads, int directMemoryCacheAlignment) {
|
||||||
this.manager = requireNonNull(manager, "MemoryManager");
|
this.manager = requireNonNull(manager, "MemoryManager");
|
||||||
@ -225,7 +224,7 @@ public class PooledByteBufAllocator implements BufferAllocator, ByteBufAllocator
|
|||||||
arenaMetrics = Collections.emptyList();
|
arenaMetrics = Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
metric = new PooledByteBufAllocatorMetric(this);
|
metric = new PooledBufferAllocatorMetric(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static PoolArena[] newArenaArray(int size) {
|
private static PoolArena[] newArenaArray(int size) {
|
||||||
@ -414,7 +413,7 @@ public class PooledByteBufAllocator implements BufferAllocator, ByteBufAllocator
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PooledByteBufAllocatorMetric metric() {
|
public PooledBufferAllocatorMetric metric() {
|
||||||
return metric;
|
return metric;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -426,7 +425,7 @@ public class PooledByteBufAllocator implements BufferAllocator, ByteBufAllocator
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the number of thread local caches used by this {@link PooledByteBufAllocator}.
|
* Return the number of thread local caches used by this {@link PooledBufferAllocator}.
|
||||||
*/
|
*/
|
||||||
int numThreadLocalCaches() {
|
int numThreadLocalCaches() {
|
||||||
if (arenas == null) {
|
if (arenas == null) {
|
@ -5,14 +5,14 @@ import io.netty.util.internal.StringUtil;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exposed metric for {@link PooledByteBufAllocator}.
|
* Exposed metric for {@link PooledBufferAllocator}.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public final class PooledByteBufAllocatorMetric implements ByteBufAllocatorMetric {
|
public final class PooledBufferAllocatorMetric implements BufferAllocatorMetric {
|
||||||
|
|
||||||
private final PooledByteBufAllocator allocator;
|
private final PooledBufferAllocator allocator;
|
||||||
|
|
||||||
PooledByteBufAllocatorMetric(PooledByteBufAllocator allocator) {
|
PooledBufferAllocatorMetric(PooledBufferAllocator allocator) {
|
||||||
this.allocator = allocator;
|
this.allocator = allocator;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ public final class PooledByteBufAllocatorMetric implements ByteBufAllocatorMetri
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the number of thread local caches used by this {@link PooledByteBufAllocator}.
|
* Return the number of thread local caches used by this {@link PooledBufferAllocator}.
|
||||||
*/
|
*/
|
||||||
public int numThreadLocalCaches() {
|
public int numThreadLocalCaches() {
|
||||||
return allocator.numThreadLocalCaches();
|
return allocator.numThreadLocalCaches();
|
Loading…
x
Reference in New Issue
Block a user