`
carlosfu
  • 浏览: 590221 次
  • 性别: Icon_minigender_1
  • 来自: 北京
博客专栏
Ba8b5055-9c58-3ab0-8a1c-e710f0495d2c
BigMemory实战与理...
浏览量:32281
53b2087e-c637-34d2-b61d-257846f73ade
RedisCluster开...
浏览量:152389
C9f66038-7478-3388-8086-d20c1f535495
缓存的使用与设计
浏览量:126709
社区版块
存档分类
最新评论

BigMemroy系列文章--8. Bigmemory快速接入实战

阅读更多

转载请注明出处哈:http://carlosfu.iteye.com/blog/2237511


 

更多BigMemory Go可参考官方文档:

一、BigMemory证书:

 

(1). 由于BigMemory是商业版,需要从官网上注册、下载证书(目前只支持90天)和对应版本的jar包:

下载地址:http://terracotta.org/downloads/bigmemorygo,完成表单填写,完成下载。

 

(2). 可以将证书放到classpath下,或者加入启动参数:

 

-Dcom.tc.productkey.path=/path/to/terracotta-license.key

 

(3). 证书示例: 

 

# This software license, granted by Terracotta Inc. - a Software AG company, is valid for and may only be used
# by the licensee of this product ("Licensee").
# Descriptor version: 4
# ------------------------------------------------------------------------------------
Date of Issue: 2015-08-19
Expiration Date: 2015-11-17
License Type: Trial
License Number: 1009994
Licensee: deren zhang, it
Email: 490431513@qq.com
Product: BigMemory Go
Edition: DX
Capabilities: ehcache, TMC, ehcache offheap
Max Client Count: 0
ehcache.maxOffHeap: 32G
Signature: MC0CFHmKKAqyuq+bmly3S6GzM9yJDznNAhUAjDDruAR/GtZRFs2dkUP6WtK7MTU=

 

其中:

ehcache.maxOffHeap代表最大的堆外内存

Capabilities: ehcache, TMC, ehcache offheap:表示证书可以适用于 ehcache, TMC, ehcache offheap

Signature:证书号

二、依赖

1. BigMemory依赖

<bigmemory.version>4.0.5</bigmemory.version>
<ehcache-ee.version>2.7.5</ehcache-ee.version>
<dependency>
    <groupId>org.terracotta.bigmemory</groupId>
    <artifactId>bigmemory</artifactId>
    <version>${bigmemory.version}</version>
</dependency>
<dependency>
    <groupId>net.sf.ehcache</groupId>
    <artifactId>ehcache-ee</artifactId>
    <version>${ehcache-ee.version}</version>
</dependency>

 

2. 序列化工具protostuff依赖

<protostuff.version>1.0.8</protostuff.version>
<dependency>
    <groupId>com.dyuproject.protostuff</groupId>
    <artifactId>protostuff-runtime</artifactId>
    <version>${protostuff.version}</version>
</dependency>
<dependency>
    <groupId>com.dyuproject.protostuff</groupId>
    <artifactId>protostuff-core</artifactId>
    <version>${protostuff.version}</version>
</dependency>

 

3. logback依赖(logback实现了slf4j-api)

<logback.version>1.0.13</logback.version>
<dependency>
    <groupId>ch.qos.logback</groupId>
    <artifactId>logback-core</artifactId>
    <version>${logback.version}</version>
</dependency>
<dependency>
    <groupId>ch.qos.logback</groupId>
    <artifactId>logback-classic</artifactId>
    <version>${logback.version}</version>
</dependency>    

4. 引入junit

<junit.version>4.11</junit.version>
<dependency>
   <groupId>junit</groupId>
   <artifactId>junit</artifactId>
   <version>${junit.version}</version>
</dependency>

 

5.最终pom配置

<properties>
    <bigmemory.version>4.0.5</bigmemory.version>
    <ehcache-ee.version>2.7.5</ehcache-ee.version>
    <protostuff.version>1.0.8</protostuff.version>
    <logback.version>1.0.13</logback.version>
    <junit.version>4.11</junit.version>
</properties>
<dependencies>
    <dependency>
        <groupId>org.terracotta.bigmemory</groupId>
        <artifactId>bigmemory</artifactId>
        <version>${bigmemory.version}</version>
    </dependency>
    <dependency>
        <groupId>net.sf.ehcache</groupId>
        <artifactId>ehcache-ee</artifactId>
        <version>${ehcache-ee.version}</version>
    </dependency>
    <dependency>
        <groupId>com.dyuproject.protostuff</groupId>
        <artifactId>protostuff-runtime</artifactId>
        <version>${protostuff.version}</version>
    </dependency>
    <dependency>
        <groupId>com.dyuproject.protostuff</groupId>
        <artifactId>protostuff-core</artifactId>
        <version>${protostuff.version}</version>
    </dependency>
    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-core</artifactId>
        <version>${logback.version}</version>
    </dependency>
    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>${logback.version}</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>${junit.version}</version>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
                <encoding>UTF-8</encoding>
            </configuration>
        </plugin>
    </plugins>
</build>

 

三、BigMemory配置 

 

BigMemory的配置一般也叫ehcache.xml, 放到classpath下:我们使用极简配置

<?xml version="1.0" encoding="UTF-8" ?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd">    
    <cache name="firstOffHeapCache" maxBytesLocalHeap="32M" maxBytesLocalOffHeap="1024M"/>
</ehcache>

 

Bigmemory的配置相对于Ehcache添加了两个属性:

maxBytesLocalOffHeap: 最大堆外内存
maxBytesLocalHeap:堆外内存在堆内内存的热点数据最大值

 

四、logback配置

 

<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="5 seconds">
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
        </encoder>
    </appender>
    <root level="INFO">
        <appender-ref ref="STDOUT"/>
    </root>
</configuration>

 

 五、BigMemory测试:

1. 一个实体类:

package com.sohu.tv.bigmemory.first;
import java.util.Date;
/**
 * 俱乐部
 * 
 * @author leifu
 * @Date 2015年7月28日
 * @Time 下午1:43:53
 */
public class Club {
    /**
     * 俱乐部id
     */
    private int id;
    /**
     * 俱乐部名
     */
    private String clubName;
    /**
     * 俱乐部描述
     */
    private String clubInfo;
    /**
     * 创建日期
     */
    private Date createDate;
    /**
     * 排名
     */
    private int rank;
    public Club(int id, String clubName, String clubInfo, Date createDate, int rank) {
        super();
        this.id = id;
        this.clubName = clubName;
        this.clubInfo = clubInfo;
        this.createDate = createDate;
        this.rank = rank;
    }
    public Club() {
        super();
    }
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public String getClubName() {
        return clubName;
    }
    public void setClubName(String clubName) {
        this.clubName = clubName;
    }
    public String getClubInfo() {
        return clubInfo;
    }
    public void setClubInfo(String clubInfo) {
        this.clubInfo = clubInfo;
    }
    public Date getCreateDate() {
        return createDate;
    }
    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }
    public int getRank() {
        return rank;
    }
    public void setRank(int rank) {
        this.rank = rank;
    }
    @Override
    public String toString() {
        return "Club [id=" + id + ", clubName=" + clubName + ", clubInfo=" + clubInfo + ", createDate=" + createDate
                + ", rank=" + rank + "]";
    }
}

 

2. BigMemory测试(Ehcache单元测试作为测试)

(1) 单元测试:
package com.sohu.tv.bigmemory.first;
import java.util.Date;
import org.junit.BeforeClass;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import net.sf.ehcache.Cache;
import net.sf.ehcache.CacheManager;
import net.sf.ehcache.Element;
/**
 * 第一个BigMemory测试
 * 
 * @author leifu
 * @Date 2015年8月12日
 * @Time 上午10:14:13
 */
public class FirstBigmemoryTest {
    private static Logger logger = LoggerFactory.getLogger(FirstBigmemoryTest.class);
    private static Cache cache;
    private static final String BIGMEORY_CACHE_NAME = "firstOffHeapCache";
     
    @BeforeClass
    public static void setUp() {
        CacheManager cacheManager = CacheManager.create(FirstBigmemoryTest.class.getClassLoader()
                .getResourceAsStream("ehcache.xml"));
        // 打印cacheManager管理的cache
        String[] cacheNameArr = cacheManager.getCacheNames();
        for (String cacheName : cacheNameArr) {
            logger.info("cacheName: {}", cacheName);
        }
        cache = cacheManager.getCache(BIGMEORY_CACHE_NAME);
    }
    @Test
    public void testCRUD() {
        logger.info("At start, bigmemory object size: {}", cache.getSize());
        // 唯一key
        String key = "football:club:1";
        Club club = new Club(1, "AC", "AC米兰", new Date(), 1);
        // 增
        Element element = new Element(key, club);
        cache.put(element);
        logger.info("after add bigmemory object size: {}", cache.getSize());
        // 查
        Element elementResult = cache.get(key);
        Club clubResult = (Club) elementResult.getObjectValue();
        logger.info("get key {} value is {}", key, clubResult.toString());
        // 修改
        club.setRank(8888);
        cache.put(element);
        logger.info("after set bigmemory object size: {}", cache.getSize());
        // 再查
        Element elementResultAgain = cache.get(key);
        Club clubResultAgain = (Club) elementResultAgain.getObjectValue();
        logger.info("get key {} again value is {}", key, clubResultAgain.toString());
        // 删
        boolean removeResult = cache.remove(key);
        logger.info("remove result is {}, after remove bigmemory object size: {}", removeResult, cache.getSize());
        // 增加一条,观察下次启动
        cache.put(element);
        logger.info("At final, bigmemory object size: " + cache.getSize());
        // 生产环境不要使用,影响性能
        logger.info("At final, bigmemory memory size: " + cache.calculateInMemorySize());
    }
}

 

(2) 输出报错:Club必须序列化

 

net.sf.ehcache.CacheException: The element '[ key = football:club:1, value=Club [id=1, clubName=AC, clubInfo=AC米兰, createDate=Sat Aug 22 09:40:29 CST 2015, rank=1], version=1, hitCount=0, CreationTime = 1440207629814, LastAccessTime = 1440207629814 ]' is not serializable and cannot be put into the offheap cache firstOffHeapCache
at net.sf.ehcache.store.offheap.OffHeapStore.handleNotSerializableException(OffHeapStore.java:384)
at net.sf.ehcache.store.offheap.OffHeapStore.putFaulted(OffHeapStore.java:419)
at net.sf.ehcache.store.CacheStore$2.call(CacheStore.java:127)
at net.sf.ehcache.store.CacheStore$2.call(CacheStore.java:121)
at net.sf.ehcache.store.cachingtier.OnHeapCachingTier$Fault.get(OnHeapCachingTier.java:327)
at net.sf.ehcache.store.cachingtier.OnHeapCachingTier$Fault.access$200(OnHeapCachingTier.java:304)
at net.sf.ehcache.store.cachingtier.OnHeapCachingTier.get(OnHeapCachingTier.java:174)
at net.sf.ehcache.store.CacheStore.put(CacheStore.java:121)
at net.sf.ehcache.Cache.putInternal(Cache.java:1501)
at net.sf.ehcache.Cache.put(Cache.java:1427)
at net.sf.ehcache.Cache.put(Cache.java:1392)
at com.sohu.tv.bigmemory.first.FirstBigmemoryTest.testCRUD(FirstBigmemoryTest.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
 

 

(3) 修复:Club实现序列化接口
public class Club implements Serializable

 

(4) 输出结果正常:

输出信息包含证书的验证、BigMemory堆外内存的分配

11:04:00.965 [main] INFO o.t.license.ehcache.LicenseManager - Terracotta license loaded from resource /terracotta-license.key
Date of Issue: 2015-08-19
Expiration Date: 2015-11-17
License Type: Trial
License Number: 1009994
Licensee: deren zhang, it
Email: 490431513@qq.com
Product: BigMemory Go
Edition: DX
Capabilities: ehcache, TMC, ehcache offheap
Max Client Count: 0
ehcache.maxOffHeap: 32G
11:04:01.287 [main] INFO n.s.e.p.s.f.AnnotationSizeOfFilter - Using regular expression provided through VM argument net.sf.ehcache.pool.sizeof.ignore.pattern for IgnoreSizeOf annotation : ^.*cache\..*IgnoreSizeOf$
11:04:01.296 [main] INFO n.sf.ehcache.pool.sizeof.AgentLoader - Located valid 'tools.jar' at 'C:\Program Files\Java\jdk1.7.0_60\jre\..\lib\tools.jar'
11:04:01.358 [main] INFO n.s.e.pool.sizeof.JvmInformation - Detected JVM data model settings of: 64-Bit HotSpot JVM with Compressed OOPs
11:04:01.430 [main] INFO n.sf.ehcache.pool.sizeof.AgentLoader - Extracted agent jar to temporary file C:\Users\leifu\AppData\Local\Temp\ehcache-sizeof-agent1571240522467793322.jar
11:04:01.430 [main] INFO n.sf.ehcache.pool.sizeof.AgentLoader - Trying to load agent @ C:\Users\leifu\AppData\Local\Temp\ehcache-sizeof-agent1571240522467793322.jar
11:04:01.438 [main] INFO n.s.e.pool.impl.DefaultSizeOfEngine - using Agent sizeof engine
11:04:01.510 [main] INFO n.s.e.s.offheap.OffHeapStoreFactory - Creating Off-Heap Area Using Config
Heuristic Configuration: firstOffHeapCache
Maximum Size (specified) : 2GB
Minimum Chunk Size : 128MB
Maximum Chunk Size : 1GB
Concurrency : 64
Initial Segment Table Size : 1K slots
Segment Data Page Size : 1MB
11:04:01.515 [main] INFO c.t.o.p.UpfrontAllocatingPageSource - Allocating 2GB in chunks
11:04:02.215 [main] INFO c.t.o.p.UpfrontAllocatingPageSource - Allocated 2GB in 1GB chunks.
11:04:02.215 [main] INFO c.t.o.p.UpfrontAllocatingPageSource - Took 699 ms to create CacheManager off-heap storage of 2GB.
11:04:02.304 [main] INFO c.s.t.b.first.FirstBigmemoryTest - cacheName: firstOffHeapCache
11:04:02.307 [main] INFO c.s.t.b.first.FirstBigmemoryTest - At start, bigmemory object size: 0
11:04:02.343 [main] INFO c.s.t.b.first.FirstBigmemoryTest - after add bigmemory object size: 1
11:04:02.346 [main] INFO c.s.t.b.first.FirstBigmemoryTest - get key football:club:1 value is Club [id=1, clubName=AC, clubInfo=AC米兰, createDate=Sat Aug 22 11:04:02 CST 2015, rank=1]
11:04:02.396 [main] INFO c.s.t.b.first.FirstBigmemoryTest - after set bigmemory object size: 1
11:04:02.396 [main] INFO c.s.t.b.first.FirstBigmemoryTest - get key football:club:1 again value is Club [id=1, clubName=AC, clubInfo=AC米兰, createDate=Sat Aug 22 11:04:02 CST 2015, rank=8888]
11:04:02.397 [main] INFO c.s.t.b.first.FirstBigmemoryTest - remove result is true, after remove bigmemory object size: 0
11:04:02.398 [main] INFO c.s.t.b.first.FirstBigmemoryTest - At final, bigmemory object size: 1
11:04:02.398 [main] INFO c.s.t.b.first.FirstBigmemoryTest - At final, bigmemory memory size: 784

  

3. BigMemory测试结论:

 

(1) 堆外内存存储的数据需要序列化。

 

(2) BigMemory使用Ehcache ee可以自动完成序列化,如果使用BigMemory存储java对象,就会存在SizeOf问题(简单对象除外),所以可以使用预序列化方式序列化要存的数据。

      具体参考:BigMemory关于sizeOf引擎的测试.

 

(3) BigMemory启动时候,会寻找BigMemory证书。

11:04:00.965 [main] INFO o.t.license.ehcache.LicenseManager - Terracotta license loaded from resource /terracotta-license.key

 

 

(4) 以下是bigMemory启动时打印的DirectMemory分区概述,

Maximum Size (specified) : 2GB
Minimum Chunk Size : 128MB
Maximum Chunk Size : 1GB
Concurrency : 64
Initial Segment Table Size : 1K slots
Segment Data Page Size : 1MB

 

 

根据日志,可以猜测出BigMemory预先将数据空间划分为一系列Chunk,目的为了防止内存碎片化,与Memcache内存分配策略很像.

六、BigMemory堆外内存,JVM启动参数:

 

-XX:MaxDirectMemorySize=4G

 

七、BigMemory更多使用示例:

http://www.terracotta.org/documentation/4.0/bigmemorygo/code-samples

 

 八、使用ProtoStuff序列化:

1. ProtoStuff序列化工具:

package com.sohu.tv.serializer;
import com.dyuproject.protostuff.LinkedBuffer;
import com.dyuproject.protostuff.ProtostuffIOUtil;
import com.dyuproject.protostuff.Schema;
import com.dyuproject.protostuff.runtime.RuntimeSchema;
import java.util.concurrent.ConcurrentHashMap;
/**
 * protostuff序列化工具
 * 
 * @author leifu
 * @Date 2015-8-22
 * @Time 上午10:05:20
 */
public class ProtostuffSerializer {
    private static ConcurrentHashMap<Class<?>, Schema<?>> cachedSchema = new ConcurrentHashMap<Class<?>, Schema<?>>();
    public <T> byte[] serialize(final T source) {
        VO<T> vo = new VO<T>(source);
        final LinkedBuffer buffer = LinkedBuffer.allocate(LinkedBuffer.DEFAULT_BUFFER_SIZE);
        try {
            final Schema<VO> schema = getSchema(VO.class);
            return serializeInternal(vo, schema, buffer);
        } catch (final Exception e) {
            throw new IllegalStateException(e.getMessage(), e);
        } finally {
            buffer.clear();
        }
    }
    public <T> T deserialize(final byte[] bytes) {
        try {
            Schema<VO> schema = getSchema(VO.class);
            VO vo = deserializeInternal(bytes, schema.newMessage(), schema);
            if (vo != null && vo.getValue() != null) {
                return (T) vo.getValue();
            }
        } catch (final Exception e) {
            throw new IllegalStateException(e.getMessage(), e);
        }
        return null;
    }
    private <T> byte[] serializeInternal(final T source, final Schema<T> schema, final LinkedBuffer buffer) {
        return ProtostuffIOUtil.toByteArray(source, schema, buffer);
    }
    private <T> T deserializeInternal(final byte[] bytes, final T result, final Schema<T> schema) {
        ProtostuffIOUtil.mergeFrom(bytes, result, schema);
        return result;
    }
    private static <T> Schema<T> getSchema(Class<T> clazz) {
        @SuppressWarnings("unchecked")
        Schema<T> schema = (Schema<T>) cachedSchema.get(clazz);
        if (schema == null) {
            schema = RuntimeSchema.createFrom(clazz);
            cachedSchema.put(clazz, schema);
        }
        return schema;
    }
}

 

package com.sohu.tv.serializer;
import java.io.Serializable;
/**
 * @author leifu
 * @Date 2015-8-22
 * @Time 上午10:05:44
 * @param <T>
 */
public class VO<T> implements Serializable {
    private T value;
    public VO(T value) {
        this.value = value;
    }
    public VO() {
    }
    public T getValue() {
        return value;
    }
    @Override
    public String toString() {
        return "VO{" +
                "value=" + value +
                '}';
    }
}

2. ProtoStuff + BigMemory单元测试:

@Test
public void testBigMemoryWithSerializable() {
    ProtostuffSerializer protostuffSerializer = new ProtostuffSerializer();
    // 唯一key
    String key = "football:club:1";
    byte[] clubBytes = protostuffSerializer.serialize(new Club(1, "AC", "AC米兰", new Date(), 1));
    // 增
    Element element = new Element(key, clubBytes);
    cache.put(element);
    // 查
    Element elementResult = cache.get(key);
    byte[] clubBytesResult = (byte[]) elementResult.getObjectValue();
    Club clubResult = protostuffSerializer.deserialize(clubBytesResult);
    logger.info("get key {} value is {}", key, clubResult.toString());
}

 

输出:

12:49:31.276 [main] INFO o.t.license.ehcache.LicenseManager - Terracotta license loaded from resource /terracotta-license.key
Date of Issue: 2015-08-19
Expiration Date: 2015-11-17
License Type: Trial
License Number: 1009994
Licensee: deren zhang, it
Email: 490431513@qq.com
Product: BigMemory Go
Edition: DX
Capabilities: ehcache, TMC, ehcache offheap
Max Client Count: 0
ehcache.maxOffHeap: 32G
12:49:31.627 [main] INFO n.s.e.p.s.f.AnnotationSizeOfFilter - Using regular expression provided through VM argument net.sf.ehcache.pool.sizeof.ignore.pattern for IgnoreSizeOf annotation : ^.*cache\..*IgnoreSizeOf$
12:49:31.634 [main] INFO n.sf.ehcache.pool.sizeof.AgentLoader - Located valid 'tools.jar' at 'C:\Program Files\Java\jdk1.7.0_60\jre\..\lib\tools.jar'
12:49:31.694 [main] INFO n.s.e.pool.sizeof.JvmInformation - Detected JVM data model settings of: 64-Bit HotSpot JVM with Compressed OOPs
12:49:31.771 [main] INFO n.sf.ehcache.pool.sizeof.AgentLoader - Extracted agent jar to temporary file C:\Users\leifu\AppData\Local\Temp\ehcache-sizeof-agent7979572902856961639.jar
12:49:31.771 [main] INFO n.sf.ehcache.pool.sizeof.AgentLoader - Trying to load agent @ C:\Users\leifu\AppData\Local\Temp\ehcache-sizeof-agent7979572902856961639.jar
12:49:31.783 [main] INFO n.s.e.pool.impl.DefaultSizeOfEngine - using Agent sizeof engine
12:49:31.839 [main] INFO n.s.e.s.offheap.OffHeapStoreFactory - Creating Off-Heap Area Using Config
Heuristic Configuration: firstOffHeapCache
Maximum Size (specified) : 2GB
Minimum Chunk Size : 128MB
Maximum Chunk Size : 1GB
Concurrency : 64
Initial Segment Table Size : 1K slots
Segment Data Page Size : 1MB
12:49:31.847 [main] INFO c.t.o.p.UpfrontAllocatingPageSource - Allocating 2GB in chunks
12:49:32.682 [main] INFO c.t.o.p.UpfrontAllocatingPageSource - Allocated 2GB in 1GB chunks.
12:49:32.682 [main] INFO c.t.o.p.UpfrontAllocatingPageSource - Took 835 ms to create CacheManager off-heap storage of 2GB.
12:49:32.801 [main] INFO c.s.t.b.first.FirstBigmemoryTest - cacheName: firstOffHeapCache
12:49:32.952 [main] INFO c.s.t.b.first.FirstBigmemoryTest - get key football:club:1 value is Club [id=1, clubName=AC, clubInfo=AC米兰, createDate=Sat Aug 22 12:49:32 CST 2015, rank=1]

 

 

 

分享到:
评论
3 楼 mrjianggd 2015-11-16  
官方网站给出的建议是配置hybrid后建议给足够空间存element的key部分,不过说也有钟方法可以将key部分存在磁盘,具体方法我没找到,所以请教下的?主要是因为我这边磁盘大,内存在一定的限定内,所以希望key也在磁盘上,不过实际测试配置hybrid后,存放数据到一定程度配置堆外内存大小后就会提示server is full,而我希望的是存放数据达到堆外大小后数据可以往磁盘放
2 楼 carlosfu 2015-11-14  
mrjianggd 写道
楼主能解答下bigmemory关于存放element时候,如何将key部分存在磁盘而非offheap吗?


直接存放在硬盘应该是不支持的,应该是offheap区域满了才会写到硬盘。
不过我不建议使用硬盘,既然使用的是bigmemory超高的性能,加上硬盘这种低性能且容易有故障的设备,有点适得其反了。不如后端在加其他存储好
1 楼 mrjianggd 2015-11-12  
楼主能解答下bigmemory关于存放element时候,如何将key部分存在磁盘而非offheap吗?

相关推荐

    常用1.SchLib

    常用1.SchLib

    tokenizers-0.26.0.jar中文文档.zip

    # 【tokenizers-***.jar***文档.zip】 中包含: ***文档:【tokenizers-***-javadoc-API文档-中文(简体)版.zip】 jar包下载地址:【tokenizers-***.jar下载地址(官方地址+国内镜像地址).txt】 Maven依赖:【tokenizers-***.jar Maven依赖信息(可用于项目pom.xml).txt】 Gradle依赖:【tokenizers-***.jar Gradle依赖信息(可用于项目build.gradle).txt】 源代码下载地址:【tokenizers-***-sources.jar下载地址(官方地址+国内镜像地址).txt】 # 本文件关键字: tokenizers-***.jar***文档.zip,java,tokenizers-***.jar,ai.djl.huggingface,tokenizers,***,ai.djl.engine.rust,jar包,Maven,第三方jar包,组件,开源组件,第三方组件,Gradle,djl,huggingface,中文API文档,手册,开发手册,使用手册,参考手册 # 使用方法: 解压 【tokenizers-***.jar***文档.zip】,再解压其中的 【tokenizers-***-javadoc-API文档-中文(简体)版.zip】,双击 【index.html】 文件,即可用浏览器打开、进行查看。 # 特殊说明: ·本文档为人性化翻译,精心制作,请放心使用。 ·只翻译了该翻译的内容,如:注释、说明、描述、用法讲解 等; ·不该翻译的内容保持原样,如:类名、方法名、包名、类型、关键字、代码 等。 # 温馨提示: (1)为了防止解压后路径太长导致浏览器无法打开,推荐在解压时选择“解压到当前文件夹”(放心,自带文件夹,文件不会散落一地); (2)有时,一套Java组件会有多个jar,所以在下载前,请仔细阅读本篇描述,以确保这就是你需要的文件; # Maven依赖: ``` <dependency> <groupId>ai.djl.huggingface</groupId> <artifactId>tokenizers</artifactId> <version>***</version> </dependency> ``` # Gradle依赖: ``` Gradle: implementation group: 'ai.djl.huggingface', name: 'tokenizers', version: '***' Gradle (Short): implementation 'ai.djl.huggingface:tokenizers:***' Gradle (Kotlin): implementation("ai.djl.huggingface:tokenizers:***") ``` # 含有的 Java package(包): ``` ai.djl.engine.rust ai.djl.engine.rust.zoo ai.djl.huggingface.tokenizers ai.djl.huggingface.tokenizers.jni ai.djl.huggingface.translator ai.djl.huggingface.zoo ``` # 含有的 Java class(类): ``` ai.djl.engine.rust.RsEngine ai.djl.engine.rust.RsEngineProvider ai.djl.engine.rust.RsModel ai.djl.engine.rust.RsNDArray ai.djl.engine.rust.RsNDArrayEx ai.djl.engine.rust.RsNDArrayIndexer ai.djl.engine.rust.RsNDManager ai.djl.engine.rust.RsSymbolBlock ai.djl.engine.rust.RustLibrary ai.djl.engine.rust.zoo.RsModelZoo ai.djl.engine.rust.zoo.RsZooProvider ai.djl.huggingface.tokenizers.Encoding ai.djl.huggingface.tokenizers.HuggingFaceTokenizer ai.djl.huggingface.tokenizers.HuggingFaceTokenizer.Builder ai.djl.hu

    电力系统PMU优化配置研究——基于MATLAB的多种算法实现与性能比较

    内容概要:本文详细探讨了电力系统中PMU(相量测量单元)的优化配置问题,旨在确保系统完全可观测的同时尽量减少PMU的数量。作者介绍了六种不同的算法,包括模拟退火、图论方法、递归安全N算法等,并通过MATLAB实现了这些算法。通过对IEEE标准测试系统的实验,展示了各种算法在不同规模系统中的表现。文中不仅提供了具体的MATLAB代码实现,还分享了许多实用的经验技巧,如邻域解生成、退火速率设置、拓扑排序等。 适合人群:从事电力系统研究的技术人员、研究生以及对组合优化感兴趣的科研工作者。 使用场景及目标:适用于电力系统状态估计、故障诊断等领域,帮助研究人员和工程师找到最优的PMU配置方案,提高系统的可靠性和经济性。 其他说明:文章强调了在实际应用中需要注意的问题,如变压器支路的影响、节点编号不连续等问题,并推荐了几篇相关领域的经典文献供进一步学习。此外,还提到了一些有趣的发现,如某些中间节点装PMU反而能减少总数。

    spring-ai-mistral-ai-1.0.0-M5.jar中文文档.zip

    # 压缩文件中包含: 中文文档 jar包下载地址 Maven依赖 Gradle依赖 源代码下载地址 # 本文件关键字: jar中文文档.zip,java,jar包,Maven,第三方jar包,组件,开源组件,第三方组件,Gradle,中文API文档,手册,开发手册,使用手册,参考手册 # 使用方法: 解压最外层zip,再解压其中的zip包,双击 【index.html】 文件,即可用浏览器打开、进行查看。 # 特殊说明: ·本文档为人性化翻译,精心制作,请放心使用。 ·只翻译了该翻译的内容,如:注释、说明、描述、用法讲解 等; ·不该翻译的内容保持原样,如:类名、方法名、包名、类型、关键字、代码 等。 # 温馨提示: (1)为了防止解压后路径太长导致浏览器无法打开,推荐在解压时选择“解压到当前文件夹”(放心,自带文件夹,文件不会散落一地); (2)有时,一套Java组件会有多个jar,所以在下载前,请仔细阅读本篇描述,以确保这就是你需要的文件;

    三菱FX1s与台达MS300变频器基于Modbus RTU通讯的实战指南

    内容概要:本文详细介绍了三菱FX1s PLC与台达MS300变频器通过Modbus RTU协议实现通讯的方法。首先,文中列举了所需的硬件设备及其连接方法,确保PLC与变频器能够正常通信。接下来,针对频率设定、频率读取及正反转启停控制三大主要功能进行了详细的编程讲解,提供了具体的梯形图代码示例并解释了每一步的作用。此外,还涉及到了触摸屏(MCGS和威纶通)的配置步骤,使用户可以通过触摸屏方便地操作变频器的各项功能。最后,作者分享了一些实用的小技巧和常见错误避免方法,帮助使用者快速解决问题,提高工作效率。 适合人群:从事自动化控制系统集成的技术人员,尤其是那些需要将三菱PLC与台达变频器进行互联的工程师。 使用场景及目标:适用于工业自动化领域的项目实施过程中,旨在帮助技术人员掌握三菱FX1s与台达MS300变频器之间的高效通信技术,从而更好地完成系统集成任务。 其他说明:文中不仅包含了详细的理论知识和技术要点,还有丰富的实践经验分享,有助于读者全面理解和应用相关技术。同时,提供的完整工程文件可以直接应用于实际项目中,极大地节省了开发时间和成本。

    winrar免费版压缩工具

    winrar免费版压缩工具

    基于CEC21测试函数的灰狼、鲸鱼、人工蜂群优化算法性能对比及Matlab实现

    内容概要:本文详细介绍了灰狼算法(GWO)、鲸鱼算法(WOA)和人工蜂群算法(ABC)在CEC21标准测试函数集上的性能对比。通过设定相同的实验条件(种群数量50,迭代次数500次,30维问题空间),分别探讨了各算法的关键参数调整及其对不同类型函数(单峰、多峰、复合)的影响。文中提供了每个算法的核心代码片段,并针对具体函数给出了优化建议。最终结果显示,GWO在单峰函数上有优势,WOA擅长处理旋转和平移问题,而ABC在高维复杂环境中表现出色。 适合人群:从事优化算法研究的科研人员、研究生以及对智能优化算法感兴趣的开发者。 使用场景及目标:适用于需要评估和比较不同优化算法性能的研究项目,特别是那些涉及高维、多峰、旋转平移等问题的实际应用场景。目标是帮助研究人员选择最适合特定任务的优化算法,并提供参数调优的经验。 其他说明:文章不仅提供了理论分析,还分享了许多实践经验,如参数调整技巧、初始化方法等。此外,所有实验均基于Matlab平台完成,附带完整的代码实现,方便读者复现实验结果。

    电控开关.SchLib

    电控开关.SchLib

    spring-ai-autoconfigure-model-openai-1.0.0-M7.jar中文-英文对照文档.zip

    # 【spring-ai-autoconfigure-model-openai-1.0.0-M7.jar中文-英文对照文档.zip】 中包含: 中文-英文对照文档:【spring-ai-autoconfigure-model-openai-1.0.0-M7-javadoc-API文档-中文(简体)-英语-对照版.zip】 jar包下载地址:【spring-ai-autoconfigure-model-openai-1.0.0-M7.jar下载地址(官方地址+国内镜像地址).txt】 Maven依赖:【spring-ai-autoconfigure-model-openai-1.0.0-M7.jar Maven依赖信息(可用于项目pom.xml).txt】 Gradle依赖:【spring-ai-autoconfigure-model-openai-1.0.0-M7.jar Gradle依赖信息(可用于项目build.gradle).txt】 源代码下载地址:【spring-ai-autoconfigure-model-openai-1.0.0-M7-sources.jar下载地址(官方地址+国内镜像地址).txt】 # 本文件关键字: spring-ai-autoconfigure-model-openai-1.0.0-M7.jar中文-英文对照文档.zip,java,spring-ai-autoconfigure-model-openai-1.0.0-M7.jar,org.springframework.ai,spring-ai-autoconfigure-model-openai,1.0.0-M7,org.springframework.ai.model.openai.autoconfigure,jar包,Maven,第三方jar包,组件,开源组件,第三方

    c++复习题.doc

    c++复习题.doc

    附件3:本科毕业设计(论文)中期检查报告(3)(1)(1).docx

    本科毕业设计(论文)中期检查报告

    【信号调制】使用不同的分类器(逻辑回归分类器、决策树、随机森林、全连接密集层和CNN)来训练模型,以预测不同信噪比值下信号的调制类型附Python代码.rar

    1.版本:matlab2014/2019a/2024a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。

    weixin248食堂订餐小程序ssm(文档+源码)_kaic

    weixin248食堂订餐小程序ssm(文档+源码)_kaic

    基于粒子群优化算法的微型燃气轮机冷热电联供系统优化调度附Matlab代码.rar

    1.版本:matlab2014/2019a/2024a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。

    e1e90185ca2f1eda312e7f604d38195c_b4125f83523abcb38acd9dc0deebd500.png

    e1e90185ca2f1eda312e7f604d38195c_b4125f83523abcb38acd9dc0deebd500

    spring-ai-autoconfigure-mcp-client-1.0.0-M7.jar中文-英文对照文档.zip

    # 【spring-ai-autoconfigure-mcp-client-1.0.0-M7.jar中文-英文对照文档.zip】 中包含: 中文-英文对照文档:【spring-ai-autoconfigure-mcp-client-1.0.0-M7-javadoc-API文档-中文(简体)-英语-对照版.zip】 jar包下载地址:【spring-ai-autoconfigure-mcp-client-1.0.0-M7.jar下载地址(官方地址+国内镜像地址).txt】 Maven依赖:【spring-ai-autoconfigure-mcp-client-1.0.0-M7.jar Maven依赖信息(可用于项目pom.xml).txt】 Gradle依赖:【spring-ai-autoconfigure-mcp-client-1.0.0-M7.jar Gradle依赖信息(可用于项目build.gradle).txt】 源代码下载地址:【spring-ai-autoconfigure-mcp-client-1.0.0-M7-sources.jar下载地址(官方地址+国内镜像地址).txt】 # 本文件关键字: spring-ai-autoconfigure-mcp-client-1.0.0-M7.jar中文-英文对照文档.zip,java,spring-ai-autoconfigure-mcp-client-1.0.0-M7.jar,org.springframework.ai,spring-ai-autoconfigure-mcp-client,1.0.0-M7,org.springframework.ai.mcp.client.autoconfigure,jar包,Maven,第三方jar包,组件,开源组件,第三方组件,Gradle,springfram

    基于 OpenCV 的图像颜色与形状识别项目(含完整 Python 源码)

    该项目使用 OpenCV 实现图像中红色目标的识别与轮廓框选,适用于图像处理、颜色追踪与形状检测等场景。项目无需深度学习框架,适合图像识别技术入门学习。附带测试图像与运行说明,支持一键运行。

    爱威6-8电脑调音软件是专为音响爱好者和专业人士设计的一款强大工具,喜欢的话,直接下载吧

    爱威6-8电脑调音软件是专为音响爱好者和专业人士设计的一款强大工具,喜欢的话,直接下载吧

    spring-ai-vertex-ai-0.8.0.jar中文-英文对照文档.zip

    # 【spring-ai-vertex-ai-0.8.0.jar中文-英文对照文档.zip】 中包含: 中文-英文对照文档:【spring-ai-vertex-ai-0.8.0-javadoc-API文档-中文(简体)-英语-对照版.zip】 jar包下载地址:【spring-ai-vertex-ai-0.8.0.jar下载地址(官方地址+国内镜像地址).txt】 Maven依赖:【spring-ai-vertex-ai-0.8.0.jar Maven依赖信息(可用于项目pom.xml).txt】 Gradle依赖:【spring-ai-vertex-ai-0.8.0.jar Gradle依赖信息(可用于项目build.gradle).txt】 源代码下载地址:【spring-ai-vertex-ai-0.8.0-sources.jar下载地址(官方地址+国内镜像地址).txt】 # 本文件关键字: spring-ai-vertex-ai-0.8.0.jar中文-英文对照文档.zip,java,spring-ai-vertex-ai-0.8.0.jar,org.springframework.ai,spring-ai-vertex-ai,0.8.0,org.springframework.ai.vertex,jar包,Maven,第三方jar包,组件,开源组件,第三方组件,Gradle,springframework,spring,ai,vertex,中文-英文对照API文档,手册,开发手册,使用手册,参考手册 # 使用方法: 解压 【spring-ai-vertex-ai-0.8.0.jar中文-英文对照文档.zip】,再解压其中的 【spring-ai-vertex-ai-0.8.0-javadoc-API文档-中文(简体)-英语-对照版.zip】,双

    电源.SCHLIB

    电源.SCHLIB

Global site tag (gtag.js) - Google Analytics