Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6c9ae88

Browse files
committed
add more tests
1 parent 3fe10f0 commit 6c9ae88

12 files changed

Lines changed: 147 additions & 6 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ build
1111
*.ipr
1212
*.iws
1313
out
14+
.gradle
1415

1516
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
1617
hs_err_pid*
0 Bytes
Binary file not shown.
1.2 KB
Binary file not shown.
247 KB
Binary file not shown.
120 Bytes
Binary file not shown.
32.1 KB
Binary file not shown.

README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
This project provides two [OpenTSDB](http://opentsdb.net) *rpc* plugins.
2+
3+
### The Thrift Plugin
4+
5+
This is just a simple Thrift server that will be start when OpenTSDB starts.
6+
7+
By default, it binds to _0.0.0.0_, which is configable var property `em.thrift.host` and listen port is `9999`,
8+
which also can be changed using property `em.thrift.port`
9+
10+
The thrift IDL used here can be found at _src/main/thrift/metrics.thrift_ which will
11+
provided very detailed view of how to use this thrift service.
12+
13+
As defined in the IDL, this server accepts two types of metrics data, simple text or *Tsdata* which is a predefined
14+
thrift struct.
15+
16+
The plain text type data is just like the OpenTSDB's telent service, so one can write a thrift client and put same data
17+
that used in the telnet service, it uses same metrics syntax.
18+
19+
20+
### The Kafka Plugin
21+
22+
While, this is somehow misusing the OpenTSDB's RPC mechanism, since it is not a *RPC* plugin at all.
23+
24+
What this plugin does is simple start a kafka consumer and fetch data from kafka and then write it to OpenTSDB.
25+
26+
This kafka consumer reads at most two topics, the purpose is same as above, one topic for the plain text type data,
27+
and the other is for the tsdata's binary data.
28+
29+
The plain text's topic name can be configured with property `em.kafka.text.topic` and it's partition number is configured
30+
with property `em.kafka.text.topic.partition`.
31+
32+
The tsdata's topic name is configured with property `em.kafka.tsdata.topic` and `em.kafka.tsdata.topic.partiton`
33+
34+
Note: the topic name property has no default value, so if there is no such property provided, then this plugin will not fetch
35+
any data from kafka but just quite.
36+
37+
The partiton property is used to caucalute the consumer thread count, by default it is the cpu cores.
38+
39+
There are also two properties that should be defined in the configuration file:
40+
41+
1. em.kafka.zookeeper.connect
42+
43+
The zk host which will be used for the kafka consumer to connect to.
44+
45+
If there is no such property, then the value of property `tsd.storage.hbase.zk_quorum` will be used.
46+
47+
2. em.kafka.client.id
48+
49+
The client id used to identify kafka consumer group
50+
51+
52+
53+
### How to build
54+
55+
./gradlew clean build assembleMainDist
56+
57+
The artifact will be build and save to *build/distributions/*
58+
59+
### Install
60+
61+
Copy the build artifact and copy the jars to the OpenTSDB's lib dir, please note some dependencies of this project maybe already
62+
exist in the OpenTSDB's distribution, so just skip such jars and only copy non-exist ones.
63+
64+
Then modify OpenTSDB's conf file and add properties required by this plugin,
65+
all properties can be found in the class com.easemob.tsdb.thrift.rpc.Constants

build.gradle

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
apply plugin: 'java'
22
apply plugin: 'idea'
3+
apply plugin: 'eclipse'
34
apply plugin: 'thrift'
4-
5+
apply plugin: 'distribution'
6+
apply plugin: 'java-library-distribution'
57
buildscript {
68
repositories {
79
mavenCentral()
@@ -25,9 +27,13 @@ dependencies {
2527
}
2628
compile('org.apache.thrift:libthrift:0.9.2'){
2729
exclude group: 'org.slf4j'
30+
exclude group: 'org.apache.httpcomponents'
2831
}
2932
compile( 'org.apache.kafka:kafka_2.10:0.8.1.1'){
3033
exclude group: 'org.slf4j'
34+
exclude group: 'junit'
35+
exclude group: 'org.apache.zookeeper'
36+
exclude group: 'log4j'
3137
}
3238
compile( 'org.apache.zookeeper:zookeeper:3.4.6'){
3339
exclude group: 'org.slf4j'
@@ -70,4 +76,6 @@ generateThriftSource {
7076
//
7177
idea.module.excludeDirs = []
7278
idea.module.sourceDirs += file('build/generated-src/thrift/main')
73-
idea.module.jdkName = '1.8'
79+
idea.module.jdkName = '1.8'
80+
version='1.0.0'
81+
sourceCompatibility = 1.8

settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ include 'api'
1616
include 'services:webservice'
1717
*/
1818

19-
rootProject.name = 'kafka-opentsdb-bridage'
19+
rootProject.name = 'opentsdb-plugins'
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.easemob.tsdb.kafka.plugin;
2+
3+
/**
4+
* @author stliu <[email protected]>
5+
* @date 3/12/15
6+
*/
7+
public class AbstractKafkaTopicConsumer {
8+
9+
}

0 commit comments

Comments
 (0)