Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ops
/
monitor-service
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
wangning
7 years ago
Commit
2d6705a3c4ed6775be9d3b1d1a201bdfcb32b743
1 parent
0c563a8d
update
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
0 deletions
monitor-service-other/src/main/java/com/monitor/other/maliciousip/util/HbasePool.java
monitor-service-other/src/main/java/com/monitor/other/maliciousip/util/HbasePool.java
0 → 100644
View file @
2d6705a
package
com
.
monitor
.
other
.
maliciousip
.
util
;
import
org.apache.hadoop.conf.Configuration
;
import
org.apache.hadoop.hbase.HBaseConfiguration
;
import
org.apache.hadoop.hbase.client.Connection
;
import
org.apache.hadoop.hbase.client.ConnectionFactory
;
import
java.io.IOException
;
/**
* Created by wangning on 2017/9/22.
*/
public
class
HbasePool
{
private
static
final
String
QUORUM
=
"10.66.80.5"
;
private
static
final
String
CLIENTPORT
=
"2181"
;
private
static
Configuration
conf
=
null
;
private
static
Connection
conn
=
null
;
static
{
try
{
conf
=
HBaseConfiguration
.
create
();
conf
.
set
(
"hbase.zookeeper.quorum"
,
QUORUM
);
conf
.
set
(
"hbase.zookeeper.property.clientPort"
,
CLIENTPORT
);
conn
=
ConnectionFactory
.
createConnection
(
conf
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
public
static
synchronized
Connection
getConnection
()
{
try
{
if
(
conn
==
null
||
conn
.
isClosed
())
{
conn
=
ConnectionFactory
.
createConnection
(
conf
);
}
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
return
conn
;
}
}
...
...
Please
register
or
login
to post a comment