Skip to content

Commit 0ac16ed

Browse files
committed
完成基本的api
Signed-off-by: qianjc <leviqian@sina.com>
1 parent 2e2ac34 commit 0ac16ed

File tree

13 files changed

+625
-1
lines changed

13 files changed

+625
-1
lines changed

.gitignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
bin/
2+
target/
3+
file/
4+
logs/
5+
gen-java/
6+
.externalToolBuilders/
7+
.settings/
8+
.gradle/
9+
.classpath
10+
.gradletasknamecache
11+
.buildpath
12+
.project
13+
.springBeans
14+
dependency-reduced-pom.xml
15+
*.iml
16+
nohup.out
17+
/tmp
18+
/.apt_generated/
19+
.idea/
20+
disconf/
21+
/target/

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
# spring-boot-starter-hbase
1+
# 项目介绍
2+
自定义的spring-boot的hbase starter,为hbase的query操作提供简易的api并集成spring-boot的auto configuration
3+
# 使用方式
4+
## 集成

build.gradle

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
apply plugin: 'java'
2+
apply plugin: 'maven'
3+
apply plugin: 'eclipse'
4+
apply plugin: 'idea'
5+
apply plugin: 'spring-boot'
6+
7+
group = 'jthink'
8+
version = '0.0.1'
9+
10+
sourceCompatibility = 1.7
11+
targetCompatibility = 1.7
12+
compileJava.options.encoding = 'UTF-8'
13+
buildDir = 'target'
14+
15+
ext {
16+
mavenPublicUrl = 'http://192.168.88.8:8081/nexus/content/repositories/public'
17+
mavenReleaseUrl = 'http://192.168.88.8:8081/nexus/content/repositories/releases'
18+
mavenSnapshotUrl = 'http://192.168.88.8:8081/nexus/content/repositories/snapshots'
19+
springBootVersion = '1.3.6.RELEASE'
20+
springVersion = '4.2.7.RELEASE'
21+
hbaseVersion = '1.0.0-cdh5.4.0'
22+
slf4jVersion = '1.7.21'
23+
}
24+
25+
repositories {
26+
mavenLocal()
27+
maven { url "https://repository.cloudera.com/artifactory/cloudera-repos" }
28+
maven { url mavenPublicUrl }
29+
maven { url mavenReleaseUrl }
30+
maven { url mavenSnapshotUrl }
31+
mavenCentral()
32+
}
33+
34+
task sourcesJar(type: Jar, dependsOn: classes) {
35+
classifier = 'sources'
36+
from sourceSets.main.allSource
37+
}
38+
39+
artifacts {
40+
archives sourcesJar
41+
}
42+
43+
uploadArchives {
44+
repositories {
45+
mavenDeployer {
46+
repository(url: mavenReleaseUrl) {
47+
authentication(userName: 'admin', password: 'admin123')
48+
}
49+
snapshotRepository(url: mavenSnapshotUrl) {
50+
authentication(userName: 'admin', password: 'admin123')
51+
}
52+
}
53+
}
54+
}
55+
56+
dependencies {
57+
compile "org.slf4j:slf4j-api:$slf4jVersion"
58+
compile "org.springframework.boot:spring-boot-autoconfigure:$springBootVersion"
59+
compile "org.springframework:spring-tx:$springVersion"
60+
compile ("org.apache.hbase:hbase-client:$hbaseVersion") {
61+
exclude group: 'javax.servlet', module: 'servlet-api'
62+
}
63+
64+
testCompile "junit:junit:4.12"
65+
}
66+
67+
buildscript {
68+
ext {
69+
springBootVersion = '1.3.6.RELEASE'
70+
}
71+
72+
repositories {
73+
mavenLocal()
74+
maven { url "http://192.168.88.8:8081/nexus/content/groups/public" }
75+
mavenCentral()
76+
}
77+
78+
dependencies {
79+
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
80+
classpath("io.spring.gradle:dependency-management-plugin:0.6.0.RELEASE")
81+
}
82+
}

settings.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = 'spring-boot-starter-hbase'
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
package com.jthink.spring.boot.starter.hbase.api;
2+
3+
import org.apache.hadoop.hbase.client.Mutation;
4+
import org.apache.hadoop.hbase.client.Scan;
5+
6+
import java.util.List;
7+
8+
/**
9+
* Interface that specifies a basic set of Hbase operations, implemented by {@link HbaseTemplate}. Not often used,
10+
* but a useful option to enhance testability, as it can easily be mocked or stubbed.
11+
*
12+
* @author Costin Leau
13+
* @author Shaun Elliott
14+
*/
15+
/**
16+
* JThink@JThink
17+
*
18+
* @author JThink
19+
* @version 0.0.1
20+
* @desc copy from spring data hadoop hbase, modified by JThink, remove the unuse interface
21+
* @date 2016-11-15 14:49:52
22+
*/
23+
public interface HbaseOperations {
24+
25+
/**
26+
* Executes the given action against the specified table handling resource management.
27+
* <p>
28+
* Application exceptions thrown by the action object get propagated to the caller (can only be unchecked).
29+
* Allows for returning a result object (typically a domain object or collection of domain objects).
30+
*
31+
* @param tableName the target table
32+
* @param action callback object that specifies the action
33+
* @param <T> action type
34+
* @return the result object of the callback action, or null
35+
*/
36+
<T> T execute(String tableName, TableCallback<T> mapper);
37+
38+
/**
39+
* Scans the target table, using the given column family.
40+
* The content is processed row by row by the given action, returning a list of domain objects.
41+
*
42+
* @param tableName target table
43+
* @param family column family
44+
* @param action row mapper handling the scanner results
45+
* @param <T> action type
46+
* @return a list of objects mapping the scanned rows
47+
*/
48+
<T> List<T> find(String tableName, String family, final RowMapper<T> mapper);
49+
50+
/**
51+
* Scans the target table, using the given column family.
52+
* The content is processed row by row by the given action, returning a list of domain objects.
53+
*
54+
* @param tableName target table
55+
* @param family column family
56+
* @param qualifier column qualifier
57+
* @param action row mapper handling the scanner results
58+
* @param <T> action type
59+
* @return a list of objects mapping the scanned rows
60+
*/
61+
<T> List<T> find(String tableName, String family, String qualifier, final RowMapper<T> mapper);
62+
63+
/**
64+
* Scans the target table using the given {@link Scan} object. Suitable for maximum control over the scanning
65+
* process.
66+
* The content is processed row by row by the given action, returning a list of domain objects.
67+
*
68+
* @param tableName target table
69+
* @param scan table scanner
70+
* @param action row mapper handling the scanner results
71+
* @param <T> action type
72+
* @return a list of objects mapping the scanned rows
73+
*/
74+
<T> List<T> find(String tableName, final Scan scan, final RowMapper<T> mapper);
75+
76+
/**
77+
* Gets an individual row from the given table. The content is mapped by the given action.
78+
*
79+
* @param tableName target table
80+
* @param rowName row name
81+
* @param mapper row mapper
82+
* @param <T> mapper type
83+
* @return object mapping the target row
84+
*/
85+
<T> T get(String tableName, String rowName, final RowMapper<T> mapper);
86+
87+
/**
88+
* Gets an individual row from the given table. The content is mapped by the given action.
89+
*
90+
* @param tableName target table
91+
* @param rowName row name
92+
* @param familyName column family
93+
* @param mapper row mapper
94+
* @param <T> mapper type
95+
* @return object mapping the target row
96+
*/
97+
<T> T get(String tableName, String rowName, String familyName, final RowMapper<T> mapper);
98+
99+
/**
100+
* Gets an individual row from the given table. The content is mapped by the given action.
101+
*
102+
* @param tableName target table
103+
* @param rowName row name
104+
* @param familyName family
105+
* @param qualifier column qualifier
106+
* @param mapper row mapper
107+
* @param <T> mapper type
108+
* @return object mapping the target row
109+
*/
110+
<T> T get(String tableName, final String rowName, final String familyName, final String qualifier, final RowMapper<T> mapper);
111+
112+
/**
113+
* 执行put update or delete
114+
* @param tableName
115+
* @param action
116+
*/
117+
void execute(String tableName, MutatorCallback action);
118+
119+
/**
120+
*
121+
* @param tableName
122+
* @param mutation
123+
*/
124+
void saveOrUpdate(String tableName, Mutation mutation);
125+
126+
/**
127+
*
128+
* @param tableName
129+
* @param mutations
130+
*/
131+
void saveOrUpdates(String tableName, List<Mutation> mutations);
132+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.jthink.spring.boot.starter.hbase.api;
2+
3+
import org.springframework.dao.UncategorizedDataAccessException;
4+
5+
/**
6+
* HBase Data Access exception.
7+
*
8+
* @author Costin Leau
9+
*/
10+
/**
11+
* JThink@JThink
12+
*
13+
* @author JThink
14+
* @version 0.0.1
15+
* @desc copy from spring data hadoop hbase, modified by JThink
16+
* @date 2016-11-15 16:08:41
17+
*/
18+
public class HbaseSystemException extends UncategorizedDataAccessException {
19+
20+
public HbaseSystemException(Exception cause) {
21+
super(cause.getMessage(), cause);
22+
}
23+
24+
public HbaseSystemException(Throwable throwable) {
25+
super(throwable.getMessage(), throwable);
26+
}
27+
}

0 commit comments

Comments
 (0)