mirror of
https://github.com/wahyd4/pinpoint.git
synced 2026-08-17 16:56:15 +10:00
Merge pull request #243 from jaehong-kim/1.0.x
apply cacheable(ehcache) for api metadata - 1.0.5
This commit is contained in:
@@ -23,6 +23,7 @@ import com.sematext.hbase.wd.RowKeyDistributorByHashPrefix;
|
||||
import org.apache.hadoop.hbase.client.Get;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.data.hadoop.hbase.RowMapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@@ -36,7 +37,9 @@ import com.navercorp.pinpoint.web.dao.ApiMetaDataDao;
|
||||
*/
|
||||
@Repository
|
||||
public class HbaseApiMetaDataDao implements ApiMetaDataDao {
|
||||
|
||||
static final String SPEL_KEY = "#agentId.toString() + '.' + #time.toString() + '.' + #apiId.toString()";
|
||||
|
||||
|
||||
@Autowired
|
||||
private HbaseOperations2 hbaseOperations2;
|
||||
|
||||
@@ -49,6 +52,7 @@ public class HbaseApiMetaDataDao implements ApiMetaDataDao {
|
||||
private RowKeyDistributorByHashPrefix rowKeyDistributorByHashPrefix;
|
||||
|
||||
@Override
|
||||
@Cacheable(value="apiMetaData", key=SPEL_KEY)
|
||||
public List<ApiMetaDataBo> getApiMetaData(String agentId, long time, int apiId) {
|
||||
if (agentId == null) {
|
||||
throw new NullPointerException("agentId must not be null");
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
<import resource="classpath:applicationContext-dao-config.xml" />
|
||||
<import resource="classpath:applicationContext-scheduler.xml" />
|
||||
-->
|
||||
<!--<import resource="classpath:applicationContext-cache.xml" />-->
|
||||
<import resource="classpath:applicationContext-cache.xml" />
|
||||
|
||||
<bean id="spanMapper" class="com.navercorp.pinpoint.web.mapper.SpanMapper"></bean>
|
||||
<bean id="annotationMapper" class="com.navercorp.pinpoint.web.mapper.AnnotationMapper"></bean>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
overflowToDisk="false" diskPersistent="false" timeToIdleSeconds="0"
|
||||
timeToLiveSeconds="600" memoryStoreEvictionPolicy="LRU" />
|
||||
|
||||
<cache name="pinpoint" maxElementsInMemory="10000" eternal="false"
|
||||
<cache name="apiMetaData" maxElementsInMemory="10000" eternal="false"
|
||||
timeToIdleSeconds="0" timeToLiveSeconds="600" overflowToDisk="false"
|
||||
diskPersistent="false" diskExpiryThreadIntervalSeconds="120"
|
||||
memoryStoreEvictionPolicy="LRU">
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.navercorp.pinpoint.web.dao.hbase;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.expression.ExpressionParser;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
import org.springframework.expression.spel.support.StandardEvaluationContext;
|
||||
|
||||
public class HbaseApiMetaDataDaoTest {
|
||||
|
||||
@Test
|
||||
public void getApiMetaDataCachable() {
|
||||
// cacheable key - spring expression language
|
||||
ExpressionParser parser = new SpelExpressionParser();
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
context.setVariable("agentId", "foo");
|
||||
context.setVariable("time", (long) 1);
|
||||
context.setVariable("apiId", (int) 2);
|
||||
|
||||
String key = (String) parser.parseExpression(HbaseApiMetaDataDao.SPEL_KEY).getValue(context);
|
||||
assertEquals("foo.1.2", key);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user