├── .classpath
├── .gitignore
├── .project
├── .settings
├── org.eclipse.core.resources.prefs
├── org.eclipse.jdt.core.prefs
└── org.eclipse.m2e.core.prefs
├── README.md
├── nb-configuration.xml
├── nbactions.xml
├── pom.xml
└── src
├── main
├── java
│ └── com
│ │ └── hortonworks
│ │ ├── ConsumerGroupExample.java
│ │ ├── ConsumerTest.java
│ │ ├── Field.java
│ │ ├── JsonUtils.java
│ │ ├── KafkaToHBaseConfig.java
│ │ ├── MappingConfig.java
│ │ ├── Notifier.java
│ │ └── Util.java
└── resources
│ └── kafka.json
└── test
└── java
└── com
└── hortonworks
└── JsonUtilsTest.java
/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | KafkaHBaseBenchmark
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.m2e.core.maven2Builder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.jdt.core.javanature
21 | org.eclipse.m2e.core.maven2Nature
22 |
23 |
24 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding//src/main/java=UTF-8
3 | encoding//src/main/resources=UTF-8
4 | encoding//src/test/java=UTF-8
5 | encoding/=UTF-8
6 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
3 | org.eclipse.jdt.core.compiler.compliance=1.7
4 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
5 | org.eclipse.jdt.core.compiler.source=1.7
6 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.m2e.core.prefs:
--------------------------------------------------------------------------------
1 | activeProfiles=
2 | eclipse.preferences.version=1
3 | resolveWorkspaceProjects=true
4 | version=1
5 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # KafkaHBaseBenchmark
2 |
--------------------------------------------------------------------------------
/nb-configuration.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
16 | apache20
17 |
18 |
19 |
--------------------------------------------------------------------------------
/nbactions.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | run
5 |
6 | jar
7 |
8 |
9 | process-classes
10 | org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
11 |
12 |
13 | -classpath %classpath com.hortonworks.kafka.ConsumerGroupExample
14 | java
15 |
16 |
17 |
18 | debug
19 |
20 | jar
21 |
22 |
23 | process-classes
24 | org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
25 |
26 |
27 | -Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath com.hortonworks.kafka.ConsumerGroupExample
28 | java
29 | true
30 |
31 |
32 |
33 | profile
34 |
35 | jar
36 |
37 |
38 | process-classes
39 | org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
40 |
41 |
42 | -classpath %classpath com.hortonworks.kafka.ConsumerGroupExample
43 | java
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | com.jet
8 | KafkaHBaseBenchmark
9 | 1.0-SNAPSHOT
10 | jar
11 |
12 |
13 | UTF-8
14 | 1.7
15 | 1.7
16 | 0.8.2.2.3.0.0-2557
17 |
18 |
19 |
20 |
21 |
22 | org.apache.maven.plugins
23 | maven-compiler-plugin
24 | 2.5.1
25 |
26 | 1.7
27 | 1.7
28 |
29 |
30 |
31 |
32 | org.apache.maven.plugins
33 | maven-jar-plugin
34 | 2.6
35 |
36 |
37 |
38 | org.apache.maven.plugins
39 | maven-assembly-plugin
40 | 2.5.5
41 |
42 |
43 | jar-with-dependencies
44 |
45 |
46 |
47 | com.hortonworks.ConsumerGroupExample
48 |
49 |
50 |
51 |
52 |
53 | package
54 |
55 | single
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 | HDPReleases
66 | HDP Releases
67 | http://repo.hortonworks.com/content/repositories/public
68 | default
69 |
70 | true
71 | always
72 | warn
73 |
74 |
75 | false
76 | never
77 | fail
78 |
79 |
80 |
81 |
82 |
83 |
84 | org.apache.kafka
85 | kafka-clients
86 | ${kafka.version}
87 |
88 |
89 | org.apache.kafka
90 | kafka_2.10
91 | ${kafka.version}
92 |
93 |
94 | javax.jms
95 | jms
96 |
97 |
98 | com.sun.jdmk
99 | jmxtools
100 |
101 |
102 | com.sun.jmx
103 | jmxri
104 |
105 |
106 | org.slf4j
107 | slf4j-log4j12
108 |
109 |
110 |
111 |
112 | org.apache.hbase
113 | hbase-client
114 | 1.1.1
115 | jar
116 |
117 |
118 | org.apache.hadoop
119 | hadoop-hdfs
120 | 2.7.1
121 | jar
122 |
123 |
124 | org.apache.hadoop
125 | hadoop-common
126 | 2.7.1
127 | jar
128 |
129 |
130 | com.google.code.gson
131 | gson
132 | 2.3.1
133 |
134 |
135 | org.apache.commons
136 | commons-lang3
137 | 3.4
138 | jar
139 |
140 |
141 | KafkaHBaseBenchmark
142 |
--------------------------------------------------------------------------------
/src/main/java/com/hortonworks/ConsumerGroupExample.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 aervits.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.hortonworks;
17 |
18 | /**
19 | *
20 | * @author aervits
21 | *
22 | * https://cwiki.apache.org/confluence/display/KAFKA/Consumer+Group+Example
23 | */
24 |
25 | import java.io.IOException;
26 | import java.util.ArrayList;
27 | import java.util.Collection;
28 | import java.util.HashMap;
29 | import java.util.List;
30 | import java.util.Map;
31 | import java.util.Properties;
32 | import java.util.Set;
33 | import java.util.concurrent.ExecutorService;
34 | import java.util.concurrent.Executors;
35 | import java.util.concurrent.LinkedBlockingQueue;
36 | import java.util.concurrent.TimeUnit;
37 | import java.util.logging.Level;
38 | import java.util.logging.Logger;
39 |
40 | import kafka.consumer.ConsumerConfig;
41 | import kafka.consumer.KafkaStream;
42 | import kafka.javaapi.consumer.ConsumerConnector;
43 |
44 | import org.apache.hadoop.conf.Configuration;
45 | import org.apache.hadoop.hbase.HBaseConfiguration;
46 | import org.apache.hadoop.hbase.TableName;
47 | import org.apache.hadoop.hbase.client.BufferedMutator;
48 | import org.apache.hadoop.hbase.client.BufferedMutatorParams;
49 | import org.apache.hadoop.hbase.client.Connection;
50 | import org.apache.hadoop.hbase.client.ConnectionFactory;
51 | import org.apache.hadoop.hbase.client.Put;
52 | import org.apache.hadoop.hbase.client.RetriesExhaustedWithDetailsException;
53 | import org.apache.hadoop.hbase.util.Bytes;
54 |
55 | public class ConsumerGroupExample {
56 |
57 | private int total = 0;
58 |
59 | public synchronized int getTotal() {
60 | return total;
61 | }
62 |
63 | public synchronized void setTotal(int total) {
64 | this.total = total;
65 | }
66 | public synchronized void updateTotal(int newNumber) {
67 | this.total = total +newNumber;
68 | }
69 |
70 | private final ConsumerConnector consumer;
71 | private final String topic;
72 | private ExecutorService executor;
73 | private static final byte[] CF_DEFAULT = Bytes.toBytes("cf");
74 | private static final byte[] CF_FAMILY = Bytes.toBytes("message");
75 | private static final Logger LOG = Logger
76 | .getLogger(ConsumerGroupExample.class.getName());
77 | protected LinkedBlockingQueue