Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
山不在高_有仙则灵
SkyWalking
提交
e4f56ab1
S
SkyWalking
项目概览
山不在高_有仙则灵
/
SkyWalking
与 Fork 源项目一致
Fork自
apache / SkyWalking
通知
12
Star
0
Fork
2
代码
文件
提交
分支
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,发现更多精彩内容 >>
提交
e4f56ab1
编写于
7月 25, 2017
作者:
P
pengys5
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add Dao container to cache Dao
上级
5bd5a69b
变更
13
显示空白变更内容
内联
并排
Showing
13 changed file
with
88 addition
and
23 deletion
+88
-23
apm-collector/apm-collector-agentregister/src/main/java/org/skywalking/apm/collector/agentregister/application/ApplicationEsDAO.java
...collector/agentregister/application/ApplicationEsDAO.java
+16
-0
apm-collector/apm-collector-agentregister/src/main/java/org/skywalking/apm/collector/agentregister/application/ApplicationH2DAO.java
...collector/agentregister/application/ApplicationH2DAO.java
+1
-1
apm-collector/apm-collector-agentregister/src/main/java/org/skywalking/apm/collector/agentregister/application/ApplicationIDGetOrCreate.java
...r/agentregister/application/ApplicationIDGetOrCreate.java
+4
-3
apm-collector/apm-collector-agentregister/src/main/java/org/skywalking/apm/collector/agentregister/grpc/handler/ApplicationRegisterServiceHandler.java
...ister/grpc/handler/ApplicationRegisterServiceHandler.java
+6
-1
apm-collector/apm-collector-agentregister/src/main/resources/META-INF/defines/es_dao.define
...egister/src/main/resources/META-INF/defines/es_dao.define
+1
-0
apm-collector/apm-collector-agentregister/src/main/resources/META-INF/defines/h2_dao.define
...egister/src/main/resources/META-INF/defines/h2_dao.define
+1
-0
apm-collector/apm-collector-agentregister/src/test/java/org/skywalking/apm/collector/agentregister/grpc/handler/ApplicationRegisterServiceHandlerTestCase.java
...pc/handler/ApplicationRegisterServiceHandlerTestCase.java
+26
-0
apm-collector/apm-collector-client/src/main/java/org/skywalking/apm/collector/client/elasticsearch/ElasticSearchClient.java
...m/collector/client/elasticsearch/ElasticSearchClient.java
+5
-0
apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/config/ModuleConfigLoaderTestCase.java
...apm/collector/core/config/ModuleConfigLoaderTestCase.java
+0
-17
apm-collector/apm-collector-server/src/main/java/org/skywalking/apm/collector/server/grpc/GRPCServer.java
.../org/skywalking/apm/collector/server/grpc/GRPCServer.java
+1
-1
apm-collector/apm-collector-storage/src/main/java/org/skywalking/apm/collector/storage/dao/DAOContainer.java
...rg/skywalking/apm/collector/storage/dao/DAOContainer.java
+21
-0
apm-collector/apm-collector-storage/src/main/java/org/skywalking/apm/collector/storage/elasticsearch/StorageElasticSearchModuleDefine.java
...orage/elasticsearch/StorageElasticSearchModuleDefine.java
+3
-0
apm-collector/apm-collector-storage/src/main/java/org/skywalking/apm/collector/storage/h2/StorageH2ModuleDefine.java
...lking/apm/collector/storage/h2/StorageH2ModuleDefine.java
+3
-0
未找到文件。
apm-collector/apm-collector-agentregister/src/main/java/org/skywalking/apm/collector/agentregister/application/ApplicationEsDAO.java
浏览文件 @
e4f56ab1
package
org.skywalking.apm.collector.agentregister.application
;
import
org.elasticsearch.action.search.SearchRequestBuilder
;
import
org.elasticsearch.action.search.SearchResponse
;
import
org.elasticsearch.action.search.SearchType
;
import
org.elasticsearch.index.query.QueryBuilders
;
import
org.skywalking.apm.collector.agentstream.worker.register.application.ApplicationRegisterTable
;
import
org.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient
;
import
org.skywalking.apm.collector.storage.elasticsearch.dao.EsDAO
;
...
...
@@ -10,6 +15,17 @@ public class ApplicationEsDAO extends EsDAO implements IApplicationDAO {
@Override
public
int
getApplicationId
(
String
applicationCode
)
{
ElasticSearchClient
client
=
getClient
();
SearchRequestBuilder
searchRequestBuilder
=
client
.
prepareSearch
(
ApplicationRegisterTable
.
TABLE
);
searchRequestBuilder
.
setTypes
(
"type"
);
searchRequestBuilder
.
setSearchType
(
SearchType
.
QUERY_THEN_FETCH
);
searchRequestBuilder
.
setQuery
(
QueryBuilders
.
termQuery
(
ApplicationRegisterTable
.
COLUMN_APPLICATION_CODE
,
applicationCode
));
searchRequestBuilder
.
setSize
(
10
);
SearchResponse
searchResponse
=
searchRequestBuilder
.
execute
().
actionGet
();
if
(
searchResponse
.
getHits
().
totalHits
>
0
)
{
return
searchResponse
.
getHits
().
getAt
(
0
).
getField
(
ApplicationRegisterTable
.
COLUMN_APPLICATION_ID
).
getValue
();
}
return
0
;
}
}
apm-collector/apm-collector-agentregister/src/main/java/org/skywalking/apm/collector/agentregister/application/ApplicationH2DAO.java
浏览文件 @
e4f56ab1
...
...
@@ -10,6 +10,6 @@ public class ApplicationH2DAO extends H2DAO implements IApplicationDAO {
@Override
public
int
getApplicationId
(
String
applicationCode
)
{
H2Client
client
=
getClient
();
return
0
;
return
10
0
;
}
}
apm-collector/apm-collector-agentregister/src/main/java/org/skywalking/apm/collector/agentregister/application/ApplicationIDGetOrCreate.java
浏览文件 @
e4f56ab1
package
org.skywalking.apm.collector.agentregister.application
;
import
org.skywalking.apm.collector.storage.dao.DAOContainer
;
/**
* @author pengys5
*/
public
class
ApplicationIDGetOrCreate
{
private
IApplicationDAO
applicationDAO
;
public
int
getOrCreate
(
String
applicationCode
)
{
return
0
;
IApplicationDAO
dao
=
(
IApplicationDAO
)
DAOContainer
.
INSTANCE
.
get
(
IApplicationDAO
.
class
.
getName
());
return
dao
.
getApplicationId
(
applicationCode
);
}
}
apm-collector/apm-collector-agentregister/src/main/java/org/skywalking/apm/collector/agentregister/grpc/handler/ApplicationRegisterServiceHandler.java
浏览文件 @
e4f56ab1
...
...
@@ -8,22 +8,27 @@ import org.skywalking.apm.network.proto.Application;
import
org.skywalking.apm.network.proto.ApplicationMapping
;
import
org.skywalking.apm.network.proto.ApplicationRegisterServiceGrpc
;
import
org.skywalking.apm.network.proto.KeyWithIntegerValue
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author pengys5
*/
public
class
ApplicationRegisterServiceHandler
extends
ApplicationRegisterServiceGrpc
.
ApplicationRegisterServiceImplBase
implements
GRPCHandler
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ApplicationRegisterServiceHandler
.
class
);
private
ApplicationIDGetOrCreate
applicationIDGetOrCreate
=
new
ApplicationIDGetOrCreate
();
@Override
public
void
register
(
Application
request
,
StreamObserver
<
ApplicationMapping
>
responseObserver
)
{
logger
.
debug
(
"register application"
);
ProtocolStringList
applicationCodes
=
request
.
getApplicationCodeList
();
for
(
int
i
=
0
;
i
<
applicationCodes
.
size
();
i
++)
{
String
applicationCode
=
applicationCodes
.
get
(
i
);
int
applicationId
=
applicationIDGetOrCreate
.
getOrCreate
(
applicationCode
);
KeyWithIntegerValue
value
=
KeyWithIntegerValue
.
newBuilder
().
setKey
(
applicationCode
).
setValue
(
applicationId
).
build
();
ApplicationMapping
mapping
=
ApplicationMapping
.
newBuilder
().
set
Application
(
i
,
value
).
build
();
ApplicationMapping
mapping
=
ApplicationMapping
.
newBuilder
().
add
Application
(
i
,
value
).
build
();
responseObserver
.
onNext
(
mapping
);
}
responseObserver
.
onCompleted
();
...
...
apm-collector/apm-collector-agentregister/src/main/resources/META-INF/defines/es_dao.define
0 → 100644
浏览文件 @
e4f56ab1
org.skywalking.apm.collector.agentregister.application.ApplicationEsDAO
\ No newline at end of file
apm-collector/apm-collector-agentregister/src/main/resources/META-INF/defines/h2_dao.define
0 → 100644
浏览文件 @
e4f56ab1
org.skywalking.apm.collector.agentregister.application.ApplicationH2DAO
\ No newline at end of file
apm-collector/apm-collector-agentregister/src/test/java/org/skywalking/apm/collector/agentregister/grpc/handler/ApplicationRegisterServiceHandlerTestCase.java
0 → 100644
浏览文件 @
e4f56ab1
package
org.skywalking.apm.collector.agentregister.grpc.handler
;
import
io.grpc.ManagedChannel
;
import
io.grpc.ManagedChannelBuilder
;
import
org.junit.Test
;
import
org.skywalking.apm.network.proto.Application
;
import
org.skywalking.apm.network.proto.ApplicationMapping
;
import
org.skywalking.apm.network.proto.ApplicationRegisterServiceGrpc
;
/**
* @author pengys5
*/
public
class
ApplicationRegisterServiceHandlerTestCase
{
private
ApplicationRegisterServiceGrpc
.
ApplicationRegisterServiceBlockingStub
stub
;
@Test
public
void
testRegister
()
{
ManagedChannel
channel
=
ManagedChannelBuilder
.
forAddress
(
"localhost"
,
11800
).
usePlaintext
(
true
).
build
();
stub
=
ApplicationRegisterServiceGrpc
.
newBlockingStub
(
channel
);
Application
application
=
Application
.
newBuilder
().
addApplicationCode
(
"test"
).
build
();
ApplicationMapping
mapping
=
stub
.
register
(
application
);
System
.
out
.
println
(
mapping
.
getApplication
(
0
).
getKey
()
+
", "
+
mapping
.
getApplication
(
0
).
getValue
());
}
}
apm-collector/apm-collector-client/src/main/java/org/skywalking/apm/collector/client/elasticsearch/ElasticSearchClient.java
浏览文件 @
e4f56ab1
...
...
@@ -8,6 +8,7 @@ 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.index.IndexRequestBuilder
;
import
org.elasticsearch.action.search.SearchRequestBuilder
;
import
org.elasticsearch.client.IndicesAdminClient
;
import
org.elasticsearch.common.settings.Settings
;
import
org.elasticsearch.common.transport.InetSocketTransportAddress
;
...
...
@@ -101,6 +102,10 @@ public class ElasticSearchClient implements Client {
return
response
.
isExists
();
}
public
SearchRequestBuilder
prepareSearch
(
String
indexName
)
{
return
client
.
prepareSearch
(
indexName
);
}
public
IndexRequestBuilder
prepareIndex
(
String
indexName
)
{
return
null
;
}
...
...
apm-collector/apm-collector-core/src/test/java/org/skywalking/apm/collector/core/config/ModuleConfigLoaderTestCase.java
已删除
100644 → 0
浏览文件 @
5bd5a69b
package
org.skywalking.apm.collector.core.config
;
import
org.junit.Test
;
import
org.skywalking.apm.collector.core.module.ModuleConfigLoader
;
import
org.skywalking.apm.collector.core.module.ModuleDefineException
;
/**
* @author pengys5
*/
public
class
ModuleConfigLoaderTestCase
{
@Test
public
void
testLoad
()
throws
ModuleDefineException
{
ModuleConfigLoader
loader
=
new
ModuleConfigLoader
();
loader
.
load
();
}
}
apm-collector/apm-collector-server/src/main/java/org/skywalking/apm/collector/server/grpc/GRPCServer.java
浏览文件 @
e4f56ab1
...
...
@@ -37,12 +37,12 @@ public class GRPCServer implements Server {
@Override
public
void
initialize
()
throws
ServerException
{
InetSocketAddress
address
=
new
InetSocketAddress
(
host
,
port
);
nettyServerBuilder
=
NettyServerBuilder
.
forAddress
(
address
);
server
=
nettyServerBuilder
.
build
();
logger
.
info
(
"Server started, host {} listening on {}"
,
host
,
port
);
}
@Override
public
void
start
()
throws
ServerException
{
try
{
server
=
nettyServerBuilder
.
build
();
server
.
start
();
}
catch
(
IOException
e
)
{
throw
new
GRPCServerException
(
e
.
getMessage
(),
e
);
...
...
apm-collector/apm-collector-storage/src/main/java/org/skywalking/apm/collector/storage/dao/DAOContainer.java
0 → 100644
浏览文件 @
e4f56ab1
package
org.skywalking.apm.collector.storage.dao
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* @author pengys5
*/
public
enum
DAOContainer
{
INSTANCE
;
private
Map
<
String
,
DAO
>
daos
=
new
HashMap
<>();
public
void
put
(
String
interfaceName
,
DAO
dao
)
{
daos
.
put
(
interfaceName
,
dao
);
}
public
DAO
get
(
String
interfaceName
)
{
return
daos
.
get
(
interfaceName
);
}
}
apm-collector/apm-collector-storage/src/main/java/org/skywalking/apm/collector/storage/elasticsearch/StorageElasticSearchModuleDefine.java
浏览文件 @
e4f56ab1
...
...
@@ -9,6 +9,7 @@ import org.skywalking.apm.collector.core.module.ModuleConfigParser;
import
org.skywalking.apm.collector.core.storage.StorageInstaller
;
import
org.skywalking.apm.collector.storage.StorageModuleDefine
;
import
org.skywalking.apm.collector.storage.StorageModuleGroupDefine
;
import
org.skywalking.apm.collector.storage.dao.DAOContainer
;
import
org.skywalking.apm.collector.storage.elasticsearch.dao.EsDAO
;
import
org.skywalking.apm.collector.storage.elasticsearch.dao.EsDAODefineLoader
;
import
org.skywalking.apm.collector.storage.elasticsearch.define.ElasticSearchStorageInstaller
;
...
...
@@ -45,6 +46,8 @@ public class StorageElasticSearchModuleDefine extends StorageModuleDefine {
List
<
EsDAO
>
esDAOs
=
loader
.
load
();
esDAOs
.
forEach
(
esDAO
->
{
esDAO
.
setClient
((
ElasticSearchClient
)
client
);
String
interFaceName
=
esDAO
.
getClass
().
getInterfaces
()[
0
].
getName
();
DAOContainer
.
INSTANCE
.
put
(
interFaceName
,
esDAO
);
});
}
}
apm-collector/apm-collector-storage/src/main/java/org/skywalking/apm/collector/storage/h2/StorageH2ModuleDefine.java
浏览文件 @
e4f56ab1
...
...
@@ -9,6 +9,7 @@ import org.skywalking.apm.collector.core.module.ModuleConfigParser;
import
org.skywalking.apm.collector.core.storage.StorageInstaller
;
import
org.skywalking.apm.collector.storage.StorageModuleDefine
;
import
org.skywalking.apm.collector.storage.StorageModuleGroupDefine
;
import
org.skywalking.apm.collector.storage.dao.DAOContainer
;
import
org.skywalking.apm.collector.storage.h2.dao.H2DAO
;
import
org.skywalking.apm.collector.storage.h2.dao.H2DAODefineLoader
;
import
org.skywalking.apm.collector.storage.h2.define.H2StorageInstaller
;
...
...
@@ -45,6 +46,8 @@ public class StorageH2ModuleDefine extends StorageModuleDefine {
List
<
H2DAO
>
h2DAOs
=
loader
.
load
();
h2DAOs
.
forEach
(
h2DAO
->
{
h2DAO
.
setClient
((
H2Client
)
client
);
String
interFaceName
=
h2DAO
.
getClass
().
getInterfaces
()[
0
].
getName
();
DAOContainer
.
INSTANCE
.
put
(
interFaceName
,
h2DAO
);
});
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录