Skip to content

Commit

Permalink
测试环境ip迁移
Browse files Browse the repository at this point in the history
  • Loading branch information
kuixiang committed May 21, 2013
1 parent d9f21c7 commit 1f8d484
Show file tree
Hide file tree
Showing 16 changed files with 67 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,56 @@

import com.jd.bdp.hydra.Span;
import com.jd.bdp.hydra.dubbomonitor.HydraService;
import com.jd.bdp.hydra.dubbomonitor.provider.impl.support.Configuration;
import com.jd.bdp.hydra.store.inter.InsertService;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class HydraMysqlServiceImpl implements HydraService {

private ArrayBlockingQueue<List<Span>> queue = new ArrayBlockingQueue<List<Span>>(1024);
private ArrayBlockingQueue<List<Span>> queue;
private int taskCount=3;
private ExecutorService executors = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());


public HydraMysqlServiceImpl(){
for(int i = 0;i < 3 ;i++){
public HydraMysqlServiceImpl() {
queue = new ArrayBlockingQueue<List<Span>>(2048);
this.taskCount=3;
for (int i = 0; i < taskCount; i++) {
executors.execute(new InsertTask());
}
}

class InsertTask implements Runnable{
public HydraMysqlServiceImpl(Configuration c) {
int queueSize= c.getTaskCount() == null ? 2048 : c.getQueueSize();
this.taskCount = c.getTaskCount() == null ? 3 : c.getTaskCount();
queue = new ArrayBlockingQueue<List<Span>>(queueSize);
for (int i = 0; i < taskCount; i++) {
executors.execute(new InsertTask());
}
}

class InsertTask implements Runnable {
@Override
public void run() {
while(true){
while (true) {
try {
List<Span> span = queue.take();
if(span != null){
for(Span s : span){
if (span != null) {
for (Span s : span) {
insertService.addSpan(s);
insertService.addTrace(s);
insertService.addAnnotation(s);
}
}
} catch (InterruptedException e) {
//ig
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
}
}
Expand All @@ -51,6 +65,7 @@ public boolean push(List<Span> span) throws IOException {
}

private InsertService insertService;

public void setInsertService(InsertService insertService) {
this.insertService = insertService;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
collector.taskCount=3
collector.queueSize=2048
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://192.168.227.48:3306/hydra-config-pressure-test
jdbc.url=jdbc:mysql://192.168.200.113:3306/hydra-config-pressure-test
jdbc.username=root
jdbc.password=root
a=a
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ dubbo.application.name=hydra-collector
dubbo.application.owner=jd-bdp

dubbo.registry.protocol=zookeeper
dubbo.registry.address=192.168.227.49:2181
dubbo.registry.address=192.168.228.81:2181

dubbo.protocol.name=dubbo
dubbo.protocol.port=20889
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,42 @@
default-autowire="byName">

<!-- 使用Spring自带的占位符替换功能 -->
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<bean id="dubboPropertyConfigureation" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<!-- 系统-D参数覆盖 -->
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
<property name="location" value="classpath:dubbo-collector.properties" />
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/>
<property name="location" value="classpath:dubbo-collector.properties"/>
<property name="order" value="2"/>
<property name="ignoreUnresolvablePlaceholders" value="true"/>
</bean>
<!--管理端 默认提供一个属性配置 决定数据源-->
<bean id="dbPropertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="order" value="2" />
<property name="order" value="3"/>
<property name="ignoreUnresolvablePlaceholders" value="true"/>
<property name="locations">
<list>
<value>classpath:collector-dbsource.properties</value>
</list>
</property>
</bean>

<bean id="collector-common" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="order" value="4"/>
<property name="ignoreUnresolvablePlaceholders" value="true"/>
<property name="location">
<value>classpath:collector-common.properties</value>
</property>
</bean>
<bean id="configuration" class="com.jd.bdp.hydra.dubbomonitor.provider.impl.support.Configuration">
<property name="queueSize" value="${collector.queueSize}"/>
<property name="taskCount" value="${collector.taskCount}"/>
</bean>
<bean id="hydraService" class="com.jd.bdp.hydra.dubbomonitor.provider.impl.HydraMysqlServiceImpl">
<constructor-arg ref="configuration"/>
</bean>
<dubbo:application name="${dubbo.application.name}" owner="${dubbo.application.owner}"/>
<dubbo:registry protocol="${dubbo.registry.protocol}" address="${dubbo.registry.address}"/>
<dubbo:protocol name="${dubbo.protocol.name}" port="${dubbo.protocol.port}" />
<bean id="hydraService" class="com.jd.bdp.hydra.dubbomonitor.provider.impl.HydraMysqlServiceImpl"/>
<dubbo:protocol name="${dubbo.protocol.name}" port="${dubbo.protocol.port}"/>
<dubbo:service interface="com.jd.bdp.hydra.dubbomonitor.HydraService" ref="hydraService">
</dubbo:service>
<!-- 选择存储方式为mysql -->
<import resource="classpath*:hydra-mysql.xml" />
<import resource="classpath*:hydra-mysql.xml"/>
</beans>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ dubbo.application.name=hydra-example-exp1
dubbo.application.owner=jd-bdp

dubbo.registry.protocol=zookeeper
dubbo.registry.address=192.168.227.49:2181
dubbo.registry.address=192.168.228.81:2181

#dubbo.service.filter=-hydra
#dubbo.reference.filter=-hydra
Original file line number Diff line number Diff line change
@@ -1,5 +0,0 @@
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/hydra-config
jdbc.username=
jdbc.password=
a=a
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ public class LeaderServiceImpl implements LeaderService {

@Override
public Map<String, String> registerClient(String name, List<String> services) {
System.out.println("接受请求");
long startTime=System.currentTimeMillis();
HashMap<String, String> map = new HashMap<String, String>();
map.put("seed", seedService.getSeed().toString());
map.put(name, appService.getAppId(name).toString());
for (String serviceName : services) {
map.put("serviceName", serviceService.getServiceId(serviceName, name).toString());
}
System.out.println("结束请求");
System.out.println("userTime:"+(System.currentTimeMillis()-startTime));
return map;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ dubbo.application.name=hydra-manager
dubbo.application.owner=jd-bdp

dubbo.registry.protocol=zookeeper
dubbo.registry.address=192.168.227.49:2181
dubbo.registry.address=192.168.228.81:2181

dubbo.protocol.name=dubbo
dubbo.protocol.port=20890
7 changes: 5 additions & 2 deletions modules/hydra-manager/src/main/resources/hydra-manager.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,25 @@
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd"
default-autowire="byName">
<import resource="classpath*:hydra-manager-db.xml"/>
<bean id="hydra-manager-proConfigure" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="order" value="2" />
<property name="ignoreUnresolvablePlaceholders" value="true"/>
<!-- 系统-D参数覆盖 -->
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/>
<property name="location" value="classpath:hydra-manager.properties"/>
</bean>
<!--管理端 默认提供一个属性配置 决定数据源-->
<bean id="dbPropertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="order" value="2" />
<property name="order" value="3" />
<property name="ignoreUnresolvablePlaceholders" value="true"/>
<property name="locations">
<list>
<value>classpath:manager-dbsource.properties</value>
</list>
</property>
</bean>
<import resource="classpath*:hydra-manager-db.xml"/>

<dubbo:application name="${dubbo.application.name}" owner="${dubbo.application.owner}"/>
<dubbo:registry protocol="${dubbo.registry.protocol}" address="${dubbo.registry.address}"/>
<!-- 用dubbo协议在20880端口暴露服务 -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://192.168.227.48:3306/hydra-config
jdbc.url=jdbc:mysql://192.168.200.113:3306/hydra-config
jdbc.username=root
jdbc.password=root
a=a
jdbc.password=root
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd" default-autowire="byName">

<!--数据库层 自己默认提供一个属性配置-->
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<bean id="propertyConfigurer-hydraMysql" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="order" value="1" />
<property name="ignoreUnresolvablePlaceholders" value="true"/>
<property name="locations">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/hydra-config
jdbc.username=
jdbc.password=
a=a
8 changes: 4 additions & 4 deletions modules/hydra-test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,22 @@ Hydra 测试
</tr>
<tr>
<td>Benchmark/Trigger</td>
<td>192.168.227.48</td>
<td>192.168.200.113</td>
<td>基准测试/冒烟触发器</td>
</tr>
<tr>
<td>A</td>
<td>192.168.227.83</td>
<td>192.168.200.110</td>
<td>A</td>
</tr>
<tr>
<td>B</td>
<td>192.168.227.86</td>
<td>192.168.200.111</td>
<td>B</td>
</tr>
<tr>
<td>C</td>
<td>192.168.228.85</td>
<td>192.168.200.112</td>
<td>C</td>
</tr>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static void main(String[] args) {
});
context.start();
Trigger trigger=(Trigger)context.getBean("trigger");
trigger.startWorkWithSleep(Integer.MAX_VALUE,100);
trigger.startWorkWithSleep(Integer.MAX_VALUE,500);
} catch (Exception e) {
e.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
dubbo.application.name=hydra-example
dubbo.application.owner=xiangkui
dubbo.registry.protocol=zookeeper
dubbo.registry.address=192.168.227.49:2181
dubbo.registry.address=192.168.228.81:2181

#dubbo.service.filter=-hydra
#dubbo.reference.filter=-hydra

0 comments on commit 1f8d484

Please sign in to comment.