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

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吗?

相关推荐

    实时监控体系:基于Prometheus的API性能指标可视化方案.pdf

    在日常的工作和学习中,你是否常常为处理复杂的数据、生成高质量的文本或者进行精准的图像识别而烦恼?DeepSeek 或许就是你一直在寻找的解决方案!它以其高效、智能的特点,在各个行业都展现出了巨大的应用价值。然而,想要充分发挥 DeepSeek 的优势,掌握从入门到精通的知识和技能至关重要。本文将从实际应用的角度出发,为你详细介绍 DeepSeek 的基本原理、操作方法以及高级技巧。通过系统的学习,你将能够轻松地运用 DeepSeek 解决实际问题,提升工作效率和质量,让自己在职场和学术领域脱颖而出。现在,就让我们一起开启这场实用又高效的学习之旅吧!

    5个提升DeepSeekAPI生成质量的调参技巧,开发者必看!.pdf

    在日常的工作和学习中,你是否常常为处理复杂的数据、生成高质量的文本或者进行精准的图像识别而烦恼?DeepSeek 或许就是你一直在寻找的解决方案!它以其高效、智能的特点,在各个行业都展现出了巨大的应用价值。然而,想要充分发挥 DeepSeek 的优势,掌握从入门到精通的知识和技能至关重要。本文将从实际应用的角度出发,为你详细介绍 DeepSeek 的基本原理、操作方法以及高级技巧。通过系统的学习,你将能够轻松地运用 DeepSeek 解决实际问题,提升工作效率和质量,让自己在职场和学术领域脱颖而出。现在,就让我们一起开启这场实用又高效的学习之旅吧!

    ACM动态规划模板-区间修改线段树问题模板

    ACM动态规划模板-区间修改线段树问题模板

    深度解析C语言调试技巧:VSCode+GDB实战排错指南.pdf

    # 踏入C语言的奇妙编程世界 在编程的广阔宇宙中,C语言宛如一颗璀璨恒星,以其独特魅力与强大功能,始终占据着不可替代的地位。无论你是编程小白,还是有一定基础想进一步提升的开发者,C语言都值得深入探索。 C语言的高效性与可移植性令人瞩目。它能直接操控硬件,执行速度快,是系统软件、嵌入式开发的首选。同时,代码可在不同操作系统和硬件平台间轻松移植,极大节省开发成本。 学习C语言,能让你深入理解计算机底层原理,培养逻辑思维和问题解决能力。掌握C语言后,再学习其他编程语言也会事半功倍。 现在,让我们一起开启C语言学习之旅。这里有丰富教程、实用案例、详细代码解析,助你逐步掌握C语言核心知识和编程技巧。别再犹豫,加入我们,在C语言的海洋中尽情遨游,挖掘无限可能,为未来的编程之路打下坚实基础!

    10个高效调用DeepSeekAPI的技巧:从请求优化到缓存策略.pdf

    在日常的工作和学习中,你是否常常为处理复杂的数据、生成高质量的文本或者进行精准的图像识别而烦恼?DeepSeek 或许就是你一直在寻找的解决方案!它以其高效、智能的特点,在各个行业都展现出了巨大的应用价值。然而,想要充分发挥 DeepSeek 的优势,掌握从入门到精通的知识和技能至关重要。本文将从实际应用的角度出发,为你详细介绍 DeepSeek 的基本原理、操作方法以及高级技巧。通过系统的学习,你将能够轻松地运用 DeepSeek 解决实际问题,提升工作效率和质量,让自己在职场和学术领域脱颖而出。现在,就让我们一起开启这场实用又高效的学习之旅吧!

    基于Python语言的PersonRelationKnowledgeGraph设计源码

    本项目为Python语言开发的PersonRelationKnowledgeGraph设计源码,总计包含49个文件,涵盖19个.pyc字节码文件、12个.py源代码文件、8个.txt文本文件、3个.xml配置文件、3个.png图片文件、2个.md标记文件、1个.iml项目配置文件、1个.cfg配置文件。该源码库旨在构建一个用于表示和查询人物关系的知识图谱系统。

    成本优化指南:通过Token计算模型将API费用降低57%的秘诀.pdf

    在日常的工作和学习中,你是否常常为处理复杂的数据、生成高质量的文本或者进行精准的图像识别而烦恼?DeepSeek 或许就是你一直在寻找的解决方案!它以其高效、智能的特点,在各个行业都展现出了巨大的应用价值。然而,想要充分发挥 DeepSeek 的优势,掌握从入门到精通的知识和技能至关重要。本文将从实际应用的角度出发,为你详细介绍 DeepSeek 的基本原理、操作方法以及高级技巧。通过系统的学习,你将能够轻松地运用 DeepSeek 解决实际问题,提升工作效率和质量,让自己在职场和学术领域脱颖而出。现在,就让我们一起开启这场实用又高效的学习之旅吧!

    大华智能物联平台,的对接其他接口的API,可以获得视频拉流的flv/hls/rstp 的拉流地址,demo项目为springBoot项目,可以通过摄像头的视频通道,获取到实时拉流的uRl

    rtsp实时预览接口URL:/evo-apigw/admin/API/MTS/Video/StartVideo HLS、FLV、RTMP实时预览接口方式 :接口URL/evo-apigw/admin/API/video/stream/realtime 参数名 必选 类型 说明 data true string Json串 +channelId true string 视频通道编码 +streamType true string 码流类型:1=主码流, 2=辅码流,3=辅码流2 +type true string 协议类型:hls,hlss,flv,flvs,ws_flv,wss_flv,rtmp hls:http协议,m3u8格式,端口7086; hlss:https协议,m3u8格式,端口是7096; flv:http协议,flv格式,端口7886; flvs:https协议,flv格式,端口是7896; ws_flv:ws协议,flv格式,端口是7886; wss_flv:wss协议,flv格式,端口是7896; rtmp:rtmp协议,端口是1975;

    Simulink永磁风机飞轮储能系统二次调频技术研究:频率特性分析与参数优化,Simulink永磁风机飞轮储能二次调频技术:系统频率特性详解及参数优化研究参考详实文献及两区域系统应用,simulink

    Simulink永磁风机飞轮储能系统二次调频技术研究:频率特性分析与参数优化,Simulink永磁风机飞轮储能二次调频技术:系统频率特性详解及参数优化研究参考详实文献及两区域系统应用,simulink永磁风机飞轮储能二次调频,系统频率特性如下,可改变调频参数改善频率。 参考文献详细,两区域系统二次调频。 ,核心关键词: 1. Simulink 2. 永磁风机 3. 飞轮储能 4. 二次调频 5. 系统频率特性 6. 调频参数 7. 改善频率 8. 参考文献 9. 两区域系统 以上关键词用分号(;)分隔,结果为:Simulink;永磁风机;飞轮储能;二次调频;系统频率特性;调频参数;改善频率;参考文献;两区域系统。,基于Simulink的永磁风机与飞轮储能系统二次调频研究:频率特性及调频参数优化

    MATLAB驱动的ASR防滑转模型:PID与对照控制算法对比,冰雪路面条件下滑移率与车速轮速对照展示,MATLAB驱动的ASR防滑转模型:PID与对照控制算法对比,冰雪路面条件下滑移率与车速轮速对照图

    MATLAB驱动的ASR防滑转模型:PID与对照控制算法对比,冰雪路面条件下滑移率与车速轮速对照展示,MATLAB驱动的ASR防滑转模型:PID与对照控制算法对比,冰雪路面条件下滑移率与车速轮速对照图展示,MATLAB驱动防滑转模型ASR模型 ASR模型驱动防滑转模型 ?牵引力控制系统模型 选择PID控制算法以及对照控制算法,共两种控制算法,可进行选择。 选择冰路面以及雪路面,共两种路面条件,可进行选择。 控制目标为滑移率0.2,出图显示车速以及轮速对照,出图显示车辆轮胎滑移率。 模型简单,仅供参考。 ,MATLAB; ASR模型; 防滑转模型; 牵引力控制系统模型; PID控制算法; 对照控制算法; 冰路面; 雪路面; 控制目标; 滑移率; 车速; 轮速。,MATLAB驱动的ASR模型:PID与对照算法在冰雪路面的滑移率控制研究

    芯片失效分析方法介绍 -深入解析芯片故障原因及预防措施.pptx

    芯片失效分析方法介绍 -深入解析芯片故障原因及预防措施.pptx

    4131_127989170.html

    4131_127989170.html

    PostgreSQL自动化部署与优化脚本:智能化安装、安全加固与监控集成

    内容概要:本文提供了一个全面的PostgreSQL自动化部署解决方案,涵盖智能环境适应、多平台支持、内存与性能优化以及安全性加强等重要方面。首先介绍了脚本的功能及其调用方法,随后详细阐述了操作系统和依赖软件包的准备过程、配置项的自动生成机制,还包括对实例的安全性和监控功能的强化措施。部署指南给出了具体的命令操作指导,便于新手理解和执行。最后强调了该工具对于不同硬件条件和服务需求的有效应对能力,特别是针对云计算环境下应用的支持特点。 适合人群:对PostgreSQL集群运维有一定基础并渴望提高效率和安全性的数据库管理员及工程师。 使用场景及目标:本脚本能够帮助企业在大规模部署时减少人工介入时间,确保系统的稳定性与高性能,适用于各类需要稳定可靠的数据库解决方案的企业或机构,特别是在大数据量和高并发事务处理场合。 其他说明:文中还提及了一些高级功能如自动备份、流复制等设置步骤,使得该方案不仅可以快速上线而且能满足后续维护和发展阶段的要求。同时提到的技术性能数据也为用户评估其能否满足业务需求提供了直观参考。

    房地产开发合同[示范文本].doc

    房地产开发合同[示范文本].doc

    成本优化实战:DeepSeekAPI的Tokens计算与计费策略拆解.pdf

    在日常的工作和学习中,你是否常常为处理复杂的数据、生成高质量的文本或者进行精准的图像识别而烦恼?DeepSeek 或许就是你一直在寻找的解决方案!它以其高效、智能的特点,在各个行业都展现出了巨大的应用价值。然而,想要充分发挥 DeepSeek 的优势,掌握从入门到精通的知识和技能至关重要。本文将从实际应用的角度出发,为你详细介绍 DeepSeek 的基本原理、操作方法以及高级技巧。通过系统的学习,你将能够轻松地运用 DeepSeek 解决实际问题,提升工作效率和质量,让自己在职场和学术领域脱颖而出。现在,就让我们一起开启这场实用又高效的学习之旅吧!

    安全必读:DeepSeek接口调用中的数据加密与合规实践.pdf

    在日常的工作和学习中,你是否常常为处理复杂的数据、生成高质量的文本或者进行精准的图像识别而烦恼?DeepSeek 或许就是你一直在寻找的解决方案!它以其高效、智能的特点,在各个行业都展现出了巨大的应用价值。然而,想要充分发挥 DeepSeek 的优势,掌握从入门到精通的知识和技能至关重要。本文将从实际应用的角度出发,为你详细介绍 DeepSeek 的基本原理、操作方法以及高级技巧。通过系统的学习,你将能够轻松地运用 DeepSeek 解决实际问题,提升工作效率和质量,让自己在职场和学术领域脱颖而出。现在,就让我们一起开启这场实用又高效的学习之旅吧!

    工程技术承包合同[示范文本].doc

    工程技术承包合同[示范文本].doc

    蓝桥杯开发赛作品源码【基于C语言】

    蓝桥杯开发赛【作品源码】

    深度解析DeepSeek语义分析API:实现情感分析与意图识别的进阶技巧.pdf

    在日常的工作和学习中,你是否常常为处理复杂的数据、生成高质量的文本或者进行精准的图像识别而烦恼?DeepSeek 或许就是你一直在寻找的解决方案!它以其高效、智能的特点,在各个行业都展现出了巨大的应用价值。然而,想要充分发挥 DeepSeek 的优势,掌握从入门到精通的知识和技能至关重要。本文将从实际应用的角度出发,为你详细介绍 DeepSeek 的基本原理、操作方法以及高级技巧。通过系统的学习,你将能够轻松地运用 DeepSeek 解决实际问题,提升工作效率和质量,让自己在职场和学术领域脱颖而出。现在,就让我们一起开启这场实用又高效的学习之旅吧!

    CVPR2023复现技术:多数据集验证下的YOLOX、YOLOv5及YOLOV7检测涨点助力器,CVPR2023复现实验助力检测涨点,验证了YOLOX、YOLOv5及YOLOV7在多个数据集上的有效性

    CVPR2023复现技术:多数据集验证下的YOLOX、YOLOv5及YOLOV7检测涨点助力器,CVPR2023复现实验助力检测涨点,验证了YOLOX、YOLOv5及YOLOV7在多个数据集上的有效性,cvpr2023复现,助力检测涨点,YOLOX YOLOv5 YOLOV7均有效,再多个数据集验证有效 ,cvpr2023复现; 助力检测涨点; YOLOX有效; YOLOv5有效; YOLOV7有效; 多数据集验证有效,CVPR2023复现成功:多模型检测涨点验证有效

Global site tag (gtag.js) - Google Analytics