Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
shell0dh committed May 27, 2013
2 parents c54312a + 3af8f96 commit b443831
Show file tree
Hide file tree
Showing 174 changed files with 4,140 additions and 1,301 deletions.
Binary file added docs/Hydra 安装手册.docx
Binary file not shown.
Binary file added docs/Hydra架构介绍.docx
Binary file not shown.
73 changes: 73 additions & 0 deletions docs/table-mysql/initTable.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#创建seed表
CREATE TABLE `TB_DATA_SEED` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`VALUE` bigint(11) DEFAULT NULL,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=82 DEFAULT CHARSET=utf8;

#创建app表
CREATE TABLE `TB_PARA_APP` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`NAME` varchar(100) DEFAULT NULL,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=154 DEFAULT CHARSET=utf8;

#创建service表
CREATE TABLE `TB_PARA_SERVICE` (
`ID` varchar(6) NOT NULL,
`NAME` varchar(100) DEFAULT NULL,
`APP_ID` int(11) DEFAULT NULL,
PRIMARY KEY (`ID`),
KEY `fk_appId` (`APP_ID`),
CONSTRAINT `fk_appId` FOREIGN KEY (`APP_ID`) REFERENCES `TB_PARA_APP` (`ID`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

#创建serviceId生成策略表
CREATE TABLE `TB_PARA_SERVICE_ID_GEN` (
`MAX_ID` int(11) NOT NULL,
`HEAD` int(11) NOT NULL,
`MAX_HEAD` int(11) NOT NULL,
`ID_SCOPE` int(11) NOT NULL,
PRIMARY KEY (`MAX_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

#初始化生成策略数据,serviceId由head+max_id两部分组成max_id和head分别自增。
#head自增至26之后重置为0(为了配合hbase分区策略,hbase分多少个区,则max_head为多少)
#max_id自增值9999后后重置为0
INSERT INTO `TB_PARA_SERVICE_ID_GEN` VALUES (0, 0, 26, 10000);

#annotation
CREATE TABLE `annotation` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`k` varchar(128) DEFAULT NULL,
`value` varchar(2048) DEFAULT NULL,
`ip` varchar(45) DEFAULT NULL,
`port` varchar(11) DEFAULT NULL,
`timestamp` bigint(20) DEFAULT NULL,
`duration` int(11) DEFAULT NULL,
`spanId` bigint(128) DEFAULT NULL,
`traceId` bigint(128) DEFAULT NULL,
`service` varchar(128) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=217122 DEFAULT CHARSET=utf8;

#span
CREATE TABLE `span` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(128) DEFAULT NULL,
`traceId` bigint(20) DEFAULT NULL,
`parentId` bigint(20) DEFAULT NULL,
`spanId` bigint(20) DEFAULT NULL,
`service` varchar(128) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=53365 DEFAULT CHARSET=utf8;

#trace
CREATE TABLE `trace` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`traceId` bigint(128) DEFAULT NULL,
`duration` int(11) DEFAULT NULL,
`service` varchar(1024) CHARACTER SET utf8 DEFAULT NULL,
`time` bigint(20) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=16924 DEFAULT CHARSET=utf8;
Binary file added docs/test/Hydra-client功能测试清单.xls
Binary file not shown.
Binary file added docs/test/Hydra-client测试报告-1.0.doc
Binary file not shown.
Binary file added docs/~$dra架构介绍.docx
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,8 @@ public boolean isSample() {

public void addBinaryAnntation(BinaryAnnotation b) {
Span span = spanThreadLocal.get();
System.out.println("111---"+span.getSpanName());
if (span != null) {
span.addBinaryAnnotation(b);
System.out.println("222---"+span.getSpanName());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ public boolean registerService(String name, List<String> services) {
try {
this.registerInfo = leaderService.registerClient(name, services);
} catch (Exception e) {
logger.warn("client global config-info cannot regist into the hydra system");
logger.warn("[Hydra] Client global config-info cannot regist into the hydra system");
}
if (registerInfo != null) {
logger.info("Global registry option is ok!");
logger.info("[Hydra] Global registry option is ok!");
isRegister = true;
}
return isRegister;
Expand All @@ -65,10 +65,10 @@ public boolean registerService(String appName, String serviceName) {
try {
serviceId = leaderService.registerClient(appName, serviceName);
} catch (Exception e) {
logger.warn("client cannot regist service <" + serviceName + "> into the hydra system");
logger.warn("[Hydra] client cannot regist service <" + serviceName + "> into the hydra system");
}
if (serviceId != null) {
logger.info("Registry ["+serviceName+"] option is ok!");
logger.info("[Hydra] Registry ["+serviceName+"] option is ok!");
registerInfo.put(serviceName, serviceId); //更新本地注册信息
return true;
} else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ public class HydraFilter implements Filter {

private Tracer tracer = null;

public HydraFilter(){
System.out.println("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
}

// 调用过程拦截
public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
String serviceId = tracer.getServiceId(RpcContext.getContext().getUrl().getServiceInterface());
Expand All @@ -59,7 +55,10 @@ public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcExcept

long start = System.currentTimeMillis();
RpcContext context = RpcContext.getContext();
<<<<<<< HEAD
System.out.println((context.isConsumerSide()?"C":"S") + "----"+serviceId + "---" + context.getMethodName() + "---" + RpcContext.getContext().getUrl().getServiceInterface());
=======
>>>>>>> 3af8f968b8202ff690076d78d6fcebd31e1c6a55
boolean isConsumerSide = context.isConsumerSide();
Span span = null;
Endpoint endpoint = null;
Expand All @@ -81,24 +80,25 @@ public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcExcept
parentId = TracerUtils.getAttachmentLong(invocation.getAttachment(TracerUtils.PID));
spanId = TracerUtils.getAttachmentLong(invocation.getAttachment(TracerUtils.SID));
boolean isSample = (traceId != null);
<<<<<<< HEAD
span = tracer.genSpan(traceId, parentId, spanId, context.getMethodName(), isSample, serviceId);
System.out.println(serviceId + "-----" + context.getMethodName());
=======
span = tracer.genSpan(traceId, parentId, spanId, context.getMethodName(), isSample, this.serviceId);
>>>>>>> 3af8f968b8202ff690076d78d6fcebd31e1c6a55
}
invokerBefore(invocation, span, endpoint, start);
RpcInvocation invocation1 = (RpcInvocation) invocation;
setAttachment(span, invocation1);
Result result = invoker.invoke(invocation);
if (result.getException() != null){
System.out.println("EEE1----" + context.getMethodName());
catchException(result.getException(), endpoint);
}
return result;
}catch (RpcException e) {
if (e.getCause() != null && e.getCause() instanceof TimeoutException){
System.out.println("EEE2----" + context.getMethodName());
catchTimeoutException(e, endpoint);
}else {
System.out.println("EEE3----" + context.getMethodName());
catchException(e, endpoint);
}
throw e;
Expand Down
50 changes: 50 additions & 0 deletions modules/hydra-collector-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,18 @@
<name>HYDRA COLLECTOR SERVICE</name>

<dependencies>
<dependency>
<groupId>com.jd.bdp</groupId>
<artifactId>hydra-store-interface</artifactId>
</dependency>
<dependency>
<groupId>com.jd.bdp</groupId>
<artifactId>hydra-hbase</artifactId>
</dependency>
<dependency>
<groupId>com.jd.bdp</groupId>
<artifactId>hydra-mysql</artifactId>
</dependency>
<dependency>
<groupId>com.taobao.metamorphosis</groupId>
<artifactId>metamorphosis-client</artifactId>
Expand All @@ -46,4 +54,46 @@
<artifactId>spring-context</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>package-only-java-files</id>
<goals>
<goal>jar</goal>
</goals>
<phase>package</phase>
<configuration>
<includes>
<include>**/*.class</include>
</includes>
<classifier>assemble</classifier>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<descriptors>
<descriptor>src/main/resources/assembly/assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Date: 13-4-16
* Time: 上午11:01
*/
public class Bootstrap {
public class CSBootstrap {

public static void main(String[] strings){
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.jd.bdp.hydra.collector.service;

import com.jd.bdp.hydra.Span;
import com.jd.bdp.hydra.hbase.service.InsertService;
import com.jd.bdp.hydra.store.inter.InsertService;
import com.jd.dd.glowworm.PB;
import com.taobao.metamorphosis.Message;
import com.taobao.metamorphosis.client.consumer.MessageConsumer;
Expand Down Expand Up @@ -66,10 +66,11 @@ public void persistent(Message message){
try{
for(Span s : spanList){
insertService.addSpan(s);
insertService.annotationIndex(s);
insertService.durationIndex(s);
insertService.addAnnotation(s);
insertService.addTrace(s);
}
}catch (Exception e){
e.printStackTrace();
log.error(e.getMessage());
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>jd</id>
<formats>
<format>dir</format>
<format>tar.gz</format>
</formats>
<includeBaseDirectory>true</includeBaseDirectory>
<dependencySets>
<dependencySet>
<outputDirectory>lib</outputDirectory>
<useProjectArtifact>false</useProjectArtifact>
<useProjectAttachments>true</useProjectAttachments>
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<directory>/src/main/resources</directory>
<outputDirectory>/conf</outputDirectory>
<fileMode>0755</fileMode>
<includes>
<include>**.**</include>
</includes>
<excludes>
<exclude>/assembly</exclude>
<exclude>/scripts</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>/src/main/resources/scripts</directory>
<outputDirectory>/bin</outputDirectory>
<includes>
<include>*.*</include>
</includes>
</fileSet>
</fileSets>
</assembly>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
metaq.zk.address=192.168.200.110:2181
metaq.topic=hydra_test

metaq.consumer.maxDelayFetchTimeInMills=100
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,20 @@

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"
default-autowire="byName">
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"
default-autowire="byName">

<!-- 选择存储方式为hbase -->
<import resource="classpath*:hydra-hbase.xml" />
<!-- 选择存储方式为mysql -->
<!--<import resource="classpath*:hydra-mysql.xml" />-->

<context:property-placeholder location="classpath:conf.properties"/>

<bean id="collectorSerService" class="com.jd.bdp.hydra.collector.service.CollectorSerService" >
<property name="topic" value="hydra_test"></property>
<property name="topic" value="${metaq.topic}"></property>
</bean>


Expand All @@ -32,7 +40,7 @@
<property name="zkConfig">
<bean class="com.taobao.metamorphosis.utils.ZkUtils.ZKConfig">
<constructor-arg>
<value>192.168.227.83:2181</value>
<value>${metaq.zk.address}</value>
</constructor-arg>
<constructor-arg>
<value>30000</value>
Expand All @@ -56,9 +64,9 @@
<constructor-arg>
<bean class="com.taobao.metamorphosis.client.consumer.ConsumerConfig">
<!-- group name -->
<constructor-arg type="java.lang.String" value="meta-example1"/>
<constructor-arg type="java.lang.String" value="meta-example"/>
<!-- other options -->
<property name="maxDelayFetchTimeInMills" value="100"/>
<property name="maxDelayFetchTimeInMills" value="${metaq.consumer.maxDelayFetchTimeInMills}"/>
</bean>
</constructor-arg>
</bean>
Expand Down
Loading

0 comments on commit b443831

Please sign in to comment.