Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
SkyWalking
提交
fcea41f9
S
SkyWalking
项目概览
apache
/
SkyWalking
上一次同步 1 年多
通知
302
Star
21345
Fork
6091
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SkyWalking
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
fcea41f9
编写于
10月 26, 2017
作者:
P
peng-yongsheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add client component
上级
f3ecaec0
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
856 addition
and
0 deletion
+856
-0
apm-collector/apm-collector-component/client-component/pom.xml
...ollector/apm-collector-component/client-component/pom.xml
+43
-0
apm-collector/apm-collector-component/client-component/src/main/java/org/skywalking/apm/collector/client/elasticsearch/ElasticSearchClient.java
...m/collector/client/elasticsearch/ElasticSearchClient.java
+164
-0
apm-collector/apm-collector-component/client-component/src/main/java/org/skywalking/apm/collector/client/elasticsearch/ElasticSearchClientException.java
...or/client/elasticsearch/ElasticSearchClientException.java
+34
-0
apm-collector/apm-collector-component/client-component/src/main/java/org/skywalking/apm/collector/client/grpc/GRPCClient.java
.../org/skywalking/apm/collector/client/grpc/GRPCClient.java
+57
-0
apm-collector/apm-collector-component/client-component/src/main/java/org/skywalking/apm/collector/client/grpc/GRPCClientException.java
...alking/apm/collector/client/grpc/GRPCClientException.java
+35
-0
apm-collector/apm-collector-component/client-component/src/main/java/org/skywalking/apm/collector/client/h2/H2Client.java
...java/org/skywalking/apm/collector/client/h2/H2Client.java
+119
-0
apm-collector/apm-collector-component/client-component/src/main/java/org/skywalking/apm/collector/client/h2/H2ClientException.java
...skywalking/apm/collector/client/h2/H2ClientException.java
+35
-0
apm-collector/apm-collector-component/client-component/src/main/java/org/skywalking/apm/collector/client/redis/RedisClient.java
...rg/skywalking/apm/collector/client/redis/RedisClient.java
+51
-0
apm-collector/apm-collector-component/client-component/src/main/java/org/skywalking/apm/collector/client/redis/RedisClientException.java
...king/apm/collector/client/redis/RedisClientException.java
+35
-0
apm-collector/apm-collector-component/client-component/src/main/java/org/skywalking/apm/collector/client/zookeeper/ZookeeperClient.java
...lking/apm/collector/client/zookeeper/ZookeeperClient.java
+112
-0
apm-collector/apm-collector-component/client-component/src/main/java/org/skywalking/apm/collector/client/zookeeper/ZookeeperClientException.java
.../collector/client/zookeeper/ZookeeperClientException.java
+34
-0
apm-collector/apm-collector-component/client-component/src/main/java/org/skywalking/apm/collector/client/zookeeper/util/PathUtils.java
...alking/apm/collector/client/zookeeper/util/PathUtils.java
+34
-0
apm-collector/apm-collector-component/pom.xml
apm-collector/apm-collector-component/pom.xml
+8
-0
apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/CollectorException.java
...org/skywalking/apm/collector/core/CollectorException.java
+33
-0
apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/client/Client.java
...java/org/skywalking/apm/collector/core/client/Client.java
+28
-0
apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/client/ClientException.java
...skywalking/apm/collector/core/client/ClientException.java
+34
-0
未找到文件。
apm-collector/apm-collector-component/client-component/pom.xml
浏览文件 @
fcea41f9
...
...
@@ -12,4 +12,47 @@
<artifactId>
client-component
</artifactId>
<packaging>
jar
</packaging>
<dependencies>
<dependency>
<groupId>
com.h2database
</groupId>
<artifactId>
h2
</artifactId>
<version>
1.4.196
</version>
</dependency>
<dependency>
<groupId>
redis.clients
</groupId>
<artifactId>
jedis
</artifactId>
<version>
2.9.0
</version>
</dependency>
<dependency>
<groupId>
org.elasticsearch.client
</groupId>
<artifactId>
transport
</artifactId>
<version>
5.5.0
</version>
<exclusions>
<exclusion>
<artifactId>
snakeyaml
</artifactId>
<groupId>
org.yaml
</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>
org.apache.zookeeper
</groupId>
<artifactId>
zookeeper
</artifactId>
<version>
3.4.10
</version>
<exclusions>
<exclusion>
<artifactId>
slf4j-api
</artifactId>
<groupId>
org.slf4j
</groupId>
</exclusion>
<exclusion>
<artifactId>
slf4j-log4j12
</artifactId>
<groupId>
org.slf4j
</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>
io.grpc
</groupId>
<artifactId>
grpc-core
</artifactId>
<version>
1.4.0
</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
apm-collector/apm-collector-component/client-component/src/main/java/org/skywalking/apm/collector/client/elasticsearch/ElasticSearchClient.java
0 → 100644
浏览文件 @
fcea41f9
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.client.elasticsearch
;
import
java.net.InetAddress
;
import
java.net.UnknownHostException
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.concurrent.ExecutionException
;
import
org.elasticsearch.action.admin.indices.create.CreateIndexResponse
;
import
org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse
;
import
org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse
;
import
org.elasticsearch.action.bulk.BulkRequestBuilder
;
import
org.elasticsearch.action.get.GetRequestBuilder
;
import
org.elasticsearch.action.get.MultiGetRequestBuilder
;
import
org.elasticsearch.action.index.IndexRequestBuilder
;
import
org.elasticsearch.action.search.SearchRequestBuilder
;
import
org.elasticsearch.action.update.UpdateRequest
;
import
org.elasticsearch.action.update.UpdateRequestBuilder
;
import
org.elasticsearch.client.IndicesAdminClient
;
import
org.elasticsearch.common.settings.Settings
;
import
org.elasticsearch.common.transport.InetSocketTransportAddress
;
import
org.elasticsearch.common.xcontent.XContentBuilder
;
import
org.elasticsearch.transport.client.PreBuiltTransportClient
;
import
org.skywalking.apm.collector.core.client.Client
;
import
org.skywalking.apm.collector.core.client.ClientException
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
ElasticSearchClient
implements
Client
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ElasticSearchClient
.
class
);
private
org
.
elasticsearch
.
client
.
Client
client
;
private
final
String
clusterName
;
private
final
Boolean
clusterTransportSniffer
;
private
final
String
clusterNodes
;
public
ElasticSearchClient
(
String
clusterName
,
Boolean
clusterTransportSniffer
,
String
clusterNodes
)
{
this
.
clusterName
=
clusterName
;
this
.
clusterTransportSniffer
=
clusterTransportSniffer
;
this
.
clusterNodes
=
clusterNodes
;
}
@Override
public
void
initialize
()
throws
ClientException
{
Settings
settings
=
Settings
.
builder
()
.
put
(
"cluster.name"
,
clusterName
)
.
put
(
"client.transport.sniff"
,
clusterTransportSniffer
)
.
build
();
client
=
new
PreBuiltTransportClient
(
settings
);
List
<
AddressPairs
>
pairsList
=
parseClusterNodes
(
clusterNodes
);
for
(
AddressPairs
pairs
:
pairsList
)
{
try
{
((
PreBuiltTransportClient
)
client
).
addTransportAddress
(
new
InetSocketTransportAddress
(
InetAddress
.
getByName
(
pairs
.
host
),
pairs
.
port
));
}
catch
(
UnknownHostException
e
)
{
throw
new
ElasticSearchClientException
(
e
.
getMessage
(),
e
);
}
}
}
@Override
public
void
shutdown
()
{
}
private
List
<
AddressPairs
>
parseClusterNodes
(
String
nodes
)
{
List
<
AddressPairs
>
pairsList
=
new
LinkedList
<>();
logger
.
info
(
"elasticsearch cluster nodes: {}"
,
nodes
);
String
[]
nodesSplit
=
nodes
.
split
(
","
);
for
(
int
i
=
0
;
i
<
nodesSplit
.
length
;
i
++)
{
String
node
=
nodesSplit
[
i
];
String
host
=
node
.
split
(
":"
)[
0
];
String
port
=
node
.
split
(
":"
)[
1
];
pairsList
.
add
(
new
AddressPairs
(
host
,
Integer
.
valueOf
(
port
)));
}
return
pairsList
;
}
class
AddressPairs
{
private
String
host
;
private
Integer
port
;
public
AddressPairs
(
String
host
,
Integer
port
)
{
this
.
host
=
host
;
this
.
port
=
port
;
}
}
public
boolean
createIndex
(
String
indexName
,
String
indexType
,
Settings
settings
,
XContentBuilder
mappingBuilder
)
{
IndicesAdminClient
adminClient
=
client
.
admin
().
indices
();
CreateIndexResponse
response
=
adminClient
.
prepareCreate
(
indexName
).
setSettings
(
settings
).
addMapping
(
indexType
,
mappingBuilder
).
get
();
logger
.
info
(
"create {} index with type of {} finished, isAcknowledged: {}"
,
indexName
,
indexType
,
response
.
isAcknowledged
());
return
response
.
isShardsAcked
();
}
public
boolean
deleteIndex
(
String
indexName
)
{
IndicesAdminClient
adminClient
=
client
.
admin
().
indices
();
DeleteIndexResponse
response
=
adminClient
.
prepareDelete
(
indexName
).
get
();
logger
.
info
(
"delete {} index finished, isAcknowledged: {}"
,
indexName
,
response
.
isAcknowledged
());
return
response
.
isAcknowledged
();
}
public
boolean
isExistsIndex
(
String
indexName
)
{
IndicesAdminClient
adminClient
=
client
.
admin
().
indices
();
IndicesExistsResponse
response
=
adminClient
.
prepareExists
(
indexName
).
get
();
return
response
.
isExists
();
}
public
SearchRequestBuilder
prepareSearch
(
String
indexName
)
{
return
client
.
prepareSearch
(
indexName
);
}
public
IndexRequestBuilder
prepareIndex
(
String
indexName
,
String
id
)
{
return
client
.
prepareIndex
(
indexName
,
"type"
,
id
);
}
public
UpdateRequestBuilder
prepareUpdate
(
String
indexName
,
String
id
)
{
return
client
.
prepareUpdate
(
indexName
,
"type"
,
id
);
}
public
GetRequestBuilder
prepareGet
(
String
indexName
,
String
id
)
{
return
client
.
prepareGet
(
indexName
,
"type"
,
id
);
}
public
MultiGetRequestBuilder
prepareMultiGet
()
{
return
client
.
prepareMultiGet
();
}
public
BulkRequestBuilder
prepareBulk
()
{
return
client
.
prepareBulk
();
}
public
void
update
(
UpdateRequest
updateRequest
)
{
try
{
client
.
update
(
updateRequest
).
get
();
}
catch
(
InterruptedException
|
ExecutionException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
}
}
apm-collector/apm-collector-component/client-component/src/main/java/org/skywalking/apm/collector/client/elasticsearch/ElasticSearchClientException.java
0 → 100644
浏览文件 @
fcea41f9
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.client.elasticsearch
;
import
org.skywalking.apm.collector.core.client.ClientException
;
/**
* @author peng-yongsheng
*/
public
class
ElasticSearchClientException
extends
ClientException
{
public
ElasticSearchClientException
(
String
message
)
{
super
(
message
);
}
public
ElasticSearchClientException
(
String
message
,
Throwable
cause
)
{
super
(
message
,
cause
);
}
}
apm-collector/apm-collector-component/client-component/src/main/java/org/skywalking/apm/collector/client/grpc/GRPCClient.java
0 → 100644
浏览文件 @
fcea41f9
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.client.grpc
;
import
io.grpc.ManagedChannel
;
import
io.grpc.ManagedChannelBuilder
;
import
org.skywalking.apm.collector.core.client.Client
;
import
org.skywalking.apm.collector.core.client.ClientException
;
/**
* @author peng-yongsheng
*/
public
class
GRPCClient
implements
Client
{
private
final
String
host
;
private
final
int
port
;
private
ManagedChannel
channel
;
public
GRPCClient
(
String
host
,
int
port
)
{
this
.
host
=
host
;
this
.
port
=
port
;
}
@Override
public
void
initialize
()
throws
ClientException
{
channel
=
ManagedChannelBuilder
.
forAddress
(
host
,
port
).
usePlaintext
(
true
).
build
();
}
@Override
public
void
shutdown
()
{
channel
.
shutdownNow
();
}
public
ManagedChannel
getChannel
()
{
return
channel
;
}
@Override
public
String
toString
()
{
return
host
+
":"
+
port
;
}
}
apm-collector/apm-collector-component/client-component/src/main/java/org/skywalking/apm/collector/client/grpc/GRPCClientException.java
0 → 100644
浏览文件 @
fcea41f9
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.client.grpc
;
import
org.skywalking.apm.collector.core.client.ClientException
;
/**
* @author peng-yongsheng
*/
public
class
GRPCClientException
extends
ClientException
{
public
GRPCClientException
(
String
message
)
{
super
(
message
);
}
public
GRPCClientException
(
String
message
,
Throwable
cause
)
{
super
(
message
,
cause
);
}
}
apm-collector/apm-collector-component/client-component/src/main/java/org/skywalking/apm/collector/client/h2/H2Client.java
0 → 100644
浏览文件 @
fcea41f9
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.client.h2
;
import
java.sql.Connection
;
import
java.sql.DriverManager
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
org.h2.util.IOUtils
;
import
org.skywalking.apm.collector.core.client.Client
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
H2Client
implements
Client
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
H2Client
.
class
);
private
Connection
conn
;
private
String
url
;
private
String
userName
;
private
String
password
;
public
H2Client
()
{
this
.
url
=
"jdbc:h2:mem:collector"
;
this
.
userName
=
""
;
this
.
password
=
""
;
}
public
H2Client
(
String
url
,
String
userName
,
String
password
)
{
this
.
url
=
url
;
this
.
userName
=
userName
;
this
.
password
=
password
;
}
@Override
public
void
initialize
()
throws
H2ClientException
{
try
{
Class
.
forName
(
"org.h2.Driver"
);
conn
=
DriverManager
.
getConnection
(
this
.
url
,
this
.
userName
,
this
.
password
);
}
catch
(
Exception
e
)
{
throw
new
H2ClientException
(
e
.
getMessage
(),
e
);
}
}
@Override
public
void
shutdown
()
{
IOUtils
.
closeSilently
(
conn
);
}
public
Connection
getConnection
()
throws
H2ClientException
{
return
conn
;
}
public
void
execute
(
String
sql
)
throws
H2ClientException
{
try
(
Statement
statement
=
getConnection
().
createStatement
())
{
statement
.
execute
(
sql
);
statement
.
closeOnCompletion
();
}
catch
(
SQLException
e
)
{
throw
new
H2ClientException
(
e
.
getMessage
(),
e
);
}
}
public
ResultSet
executeQuery
(
String
sql
,
Object
[]
params
)
throws
H2ClientException
{
logger
.
debug
(
"execute query with result: {}"
,
sql
);
ResultSet
rs
;
PreparedStatement
statement
;
try
{
statement
=
getConnection
().
prepareStatement
(
sql
);
if
(
params
!=
null
)
{
for
(
int
i
=
0
;
i
<
params
.
length
;
i
++)
{
statement
.
setObject
(
i
+
1
,
params
[
i
]);
}
}
rs
=
statement
.
executeQuery
();
statement
.
closeOnCompletion
();
}
catch
(
SQLException
e
)
{
throw
new
H2ClientException
(
e
.
getMessage
(),
e
);
}
return
rs
;
}
public
boolean
execute
(
String
sql
,
Object
[]
params
)
throws
H2ClientException
{
logger
.
debug
(
"execute insert/update/delete: {}"
,
sql
);
boolean
flag
;
Connection
conn
=
getConnection
();
try
(
PreparedStatement
statement
=
conn
.
prepareStatement
(
sql
))
{
conn
.
setAutoCommit
(
true
);
if
(
params
!=
null
)
{
for
(
int
i
=
0
;
i
<
params
.
length
;
i
++)
{
statement
.
setObject
(
i
+
1
,
params
[
i
]);
}
}
flag
=
statement
.
execute
();
}
catch
(
SQLException
e
)
{
throw
new
H2ClientException
(
e
.
getMessage
(),
e
);
}
return
flag
;
}
}
apm-collector/apm-collector-component/client-component/src/main/java/org/skywalking/apm/collector/client/h2/H2ClientException.java
0 → 100644
浏览文件 @
fcea41f9
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.client.h2
;
import
org.skywalking.apm.collector.core.client.ClientException
;
/**
* @author peng-yongsheng
*/
public
class
H2ClientException
extends
ClientException
{
public
H2ClientException
(
String
message
)
{
super
(
message
);
}
public
H2ClientException
(
String
message
,
Throwable
cause
)
{
super
(
message
,
cause
);
}
}
apm-collector/apm-collector-component/client-component/src/main/java/org/skywalking/apm/collector/client/redis/RedisClient.java
0 → 100644
浏览文件 @
fcea41f9
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.client.redis
;
import
org.skywalking.apm.collector.core.client.Client
;
import
org.skywalking.apm.collector.core.client.ClientException
;
import
redis.clients.jedis.Jedis
;
/**
* @author peng-yongsheng
*/
public
class
RedisClient
implements
Client
{
private
Jedis
jedis
;
private
final
String
host
;
private
final
int
port
;
public
RedisClient
(
String
host
,
int
port
)
{
this
.
host
=
host
;
this
.
port
=
port
;
}
@Override
public
void
initialize
()
throws
ClientException
{
jedis
=
new
Jedis
(
host
,
port
);
}
@Override
public
void
shutdown
()
{
}
public
void
setex
(
String
key
,
int
seconds
,
String
value
)
{
jedis
.
setex
(
key
,
seconds
,
value
);
}
}
apm-collector/apm-collector-component/client-component/src/main/java/org/skywalking/apm/collector/client/redis/RedisClientException.java
0 → 100644
浏览文件 @
fcea41f9
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.client.redis
;
import
org.skywalking.apm.collector.core.client.ClientException
;
/**
* @author peng-yongsheng
*/
public
class
RedisClientException
extends
ClientException
{
public
RedisClientException
(
String
message
)
{
super
(
message
);
}
public
RedisClientException
(
String
message
,
Throwable
cause
)
{
super
(
message
,
cause
);
}
}
apm-collector/apm-collector-component/client-component/src/main/java/org/skywalking/apm/collector/client/zookeeper/ZookeeperClient.java
0 → 100644
浏览文件 @
fcea41f9
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.client.zookeeper
;
import
java.io.IOException
;
import
java.util.List
;
import
org.apache.zookeeper.CreateMode
;
import
org.apache.zookeeper.KeeperException
;
import
org.apache.zookeeper.Watcher
;
import
org.apache.zookeeper.ZooKeeper
;
import
org.apache.zookeeper.data.ACL
;
import
org.apache.zookeeper.data.Stat
;
import
org.skywalking.apm.collector.core.client.Client
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
ZookeeperClient
implements
Client
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ZookeeperClient
.
class
);
private
ZooKeeper
zk
;
private
final
String
hostPort
;
private
final
int
sessionTimeout
;
private
final
Watcher
watcher
;
public
ZookeeperClient
(
String
hostPort
,
int
sessionTimeout
,
Watcher
watcher
)
{
this
.
hostPort
=
hostPort
;
this
.
sessionTimeout
=
sessionTimeout
;
this
.
watcher
=
watcher
;
}
@Override
public
void
initialize
()
throws
ZookeeperClientException
{
try
{
zk
=
new
ZooKeeper
(
hostPort
,
sessionTimeout
,
watcher
);
}
catch
(
IOException
e
)
{
throw
new
ZookeeperClientException
(
e
.
getMessage
(),
e
);
}
}
@Override
public
void
shutdown
()
{
}
public
void
create
(
final
String
path
,
byte
data
[],
List
<
ACL
>
acl
,
CreateMode
createMode
)
throws
ZookeeperClientException
{
try
{
zk
.
create
(
path
,
data
,
acl
,
createMode
);
}
catch
(
KeeperException
|
InterruptedException
e
)
{
throw
new
ZookeeperClientException
(
e
.
getMessage
(),
e
);
}
}
public
Stat
exists
(
final
String
path
,
boolean
watch
)
throws
ZookeeperClientException
{
try
{
return
zk
.
exists
(
path
,
watch
);
}
catch
(
KeeperException
|
InterruptedException
e
)
{
throw
new
ZookeeperClientException
(
e
.
getMessage
(),
e
);
}
}
public
void
delete
(
final
String
path
,
int
version
)
throws
ZookeeperClientException
{
try
{
zk
.
delete
(
path
,
version
);
}
catch
(
KeeperException
|
InterruptedException
e
)
{
throw
new
ZookeeperClientException
(
e
.
getMessage
(),
e
);
}
}
public
byte
[]
getData
(
String
path
,
boolean
watch
,
Stat
stat
)
throws
ZookeeperClientException
{
try
{
return
zk
.
getData
(
path
,
watch
,
stat
);
}
catch
(
KeeperException
|
InterruptedException
e
)
{
throw
new
ZookeeperClientException
(
e
.
getMessage
(),
e
);
}
}
public
Stat
setData
(
final
String
path
,
byte
data
[],
int
version
)
throws
ZookeeperClientException
{
try
{
return
zk
.
setData
(
path
,
data
,
version
);
}
catch
(
KeeperException
|
InterruptedException
e
)
{
throw
new
ZookeeperClientException
(
e
.
getMessage
(),
e
);
}
}
public
List
<
String
>
getChildren
(
final
String
path
,
boolean
watch
)
throws
ZookeeperClientException
{
try
{
return
zk
.
getChildren
(
path
,
watch
);
}
catch
(
KeeperException
|
InterruptedException
e
)
{
throw
new
ZookeeperClientException
(
e
.
getMessage
(),
e
);
}
}
}
apm-collector/apm-collector-component/client-component/src/main/java/org/skywalking/apm/collector/client/zookeeper/ZookeeperClientException.java
0 → 100644
浏览文件 @
fcea41f9
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.client.zookeeper
;
import
org.skywalking.apm.collector.core.client.ClientException
;
/**
* @author peng-yongsheng
*/
public
class
ZookeeperClientException
extends
ClientException
{
public
ZookeeperClientException
(
String
message
)
{
super
(
message
);
}
public
ZookeeperClientException
(
String
message
,
Throwable
cause
)
{
super
(
message
,
cause
);
}
}
apm-collector/apm-collector-component/client-component/src/main/java/org/skywalking/apm/collector/client/zookeeper/util/PathUtils.java
0 → 100644
浏览文件 @
fcea41f9
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.client.zookeeper.util
;
/**
* @author peng-yongsheng
*/
public
class
PathUtils
{
public
static
String
convertKey2Path
(
String
key
)
{
String
[]
keys
=
key
.
split
(
"\\."
);
StringBuilder
pathBuilder
=
new
StringBuilder
();
for
(
String
subPath
:
keys
)
{
pathBuilder
.
append
(
"/"
).
append
(
subPath
);
}
return
pathBuilder
.
toString
();
}
}
apm-collector/apm-collector-component/pom.xml
浏览文件 @
fcea41f9
...
...
@@ -19,4 +19,12 @@
<module>
stream-component
</module>
<module>
remote-component
</module>
</modules>
<dependencies>
<dependency>
<groupId>
org.skywalking
</groupId>
<artifactId>
apm-collector-core
</artifactId>
<version>
${project.version}
</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/CollectorException.java
0 → 100644
浏览文件 @
fcea41f9
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.core
;
/**
* @author peng-yongsheng
*/
public
class
CollectorException
extends
Exception
{
public
CollectorException
(
String
message
)
{
super
(
message
);
}
public
CollectorException
(
String
message
,
Throwable
cause
)
{
super
(
message
,
cause
);
}
}
apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/client/Client.java
0 → 100644
浏览文件 @
fcea41f9
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.core.client
;
/**
* @author peng-yongsheng
*/
public
interface
Client
{
void
initialize
()
throws
ClientException
;
void
shutdown
();
}
apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/client/ClientException.java
0 → 100644
浏览文件 @
fcea41f9
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.core.client
;
import
org.skywalking.apm.collector.core.CollectorException
;
/**
* @author peng-yongsheng
*/
public
abstract
class
ClientException
extends
CollectorException
{
public
ClientException
(
String
message
)
{
super
(
message
);
}
public
ClientException
(
String
message
,
Throwable
cause
)
{
super
(
message
,
cause
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录