|
|
package com.monitor;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.monitor.influxdb.mapper.impl.JavaApiStaticsMapper;
|
|
|
import com.monitor.javaserver.common.JavaApiStatics;
|
|
|
import com.monitor.model.domain.JavaApiStaticsModel;
|
|
|
import com.monitor.model.request.JavaApiStatusReq;
|
|
|
import com.monitor.model.response.JavaApiStatusRep;
|
|
|
import org.junit.Test;
|
|
|
import org.junit.runner.RunWith;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.annotation.PropertySource;
|
|
|
import org.springframework.test.context.ContextConfiguration;
|
|
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* Created by fruwei on 2016/6/22.
|
|
|
*/
|
|
|
@RunWith(SpringJUnit4ClassRunner.class)
|
|
|
@ContextConfiguration(locations = {
|
|
|
"classpath*:META-INF/spring/spring*.xml"})
|
|
|
@PropertySource({"classpath:jdbc.properties",
|
|
|
"classpath:*.properties"})
|
|
|
public class JavaApiInfluxDBTest {
|
|
|
Logger logger = LoggerFactory.getLogger("test");
|
|
|
@Autowired
|
|
|
JavaApiStaticsMapper javaApiStaticsMapper;
|
|
|
|
|
|
|
|
|
@Test
|
|
|
public void testQuery() {
|
|
|
|
|
|
JavaApiStatusReq param = new JavaApiStatusReq();
|
|
|
param.setServiceId(21);
|
|
|
param.setServiceId(43);
|
|
|
|
|
|
JavaApiStaticsModel rel = javaApiStaticsMapper.selectlatestJavaApiStatics(null, param);
|
|
|
|
|
|
logger.info(rel.toString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@Test
|
|
|
public void testBatchQuery() {
|
|
|
|
|
|
List<JavaApiStatusReq> listParam = new ArrayList<>();
|
|
|
for (int i = 0; i < 30; i++) {
|
|
|
JavaApiStatusReq param1 = new JavaApiStatusReq();
|
|
|
param1.setServiceId(19);
|
|
|
param1.setMObjectId(24);
|
|
|
listParam.add(param1);
|
|
|
}
|
|
|
|
|
|
|
|
|
long start = System.currentTimeMillis();
|
|
|
logger.info("############################################start...");
|
|
|
List<JavaApiStaticsModel> rel = javaApiStaticsMapper.selectlatestJavaApiStaticsList(null, listParam);
|
|
|
long end = System.currentTimeMillis();
|
|
|
logger.info("###########################################end... cost : {}", (end - start));
|
|
|
logger.info("############################################rel: {}", JSON.toJSON(rel));
|
|
|
logger.info(rel.toString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
} |