Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
SkyWalking
提交
b1e2ebd4
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,发现更多精彩内容 >>
提交
b1e2ebd4
编写于
11月 09, 2017
作者:
P
peng-yongsheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactor cache module to provide cache services.
上级
737e9c53
变更
25
隐藏空白更改
内联
并排
Showing
25 changed file
with
458 addition
and
64 deletion
+458
-64
apm-collector/apm-collector-agent/collector-agent-stream/src/main/java/org/skywalking/apm/collector/agent/stream/worker/jvm/CpuMetricPersistenceWorker.java
...r/agent/stream/worker/jvm/CpuMetricPersistenceWorker.java
+2
-2
apm-collector/apm-collector-boot/pom.xml
apm-collector/apm-collector-boot/pom.xml
+7
-0
apm-collector/apm-collector-cache/collector-cache-define/pom.xml
...lector/apm-collector-cache/collector-cache-define/pom.xml
+33
-0
apm-collector/apm-collector-cache/collector-cache-define/src/main/java/org/skywalking/apm/collector/cache/CacheModule.java
.../java/org/skywalking/apm/collector/cache/CacheModule.java
+41
-0
apm-collector/apm-collector-cache/collector-cache-define/src/main/java/org/skywalking/apm/collector/cache/service/ApplicationCacheService.java
.../apm/collector/cache/service/ApplicationCacheService.java
+30
-0
apm-collector/apm-collector-cache/collector-cache-define/src/main/java/org/skywalking/apm/collector/cache/service/InstanceCacheService.java
...ing/apm/collector/cache/service/InstanceCacheService.java
+28
-0
apm-collector/apm-collector-cache/collector-cache-define/src/main/java/org/skywalking/apm/collector/cache/service/ServiceIdCacheService.java
...ng/apm/collector/cache/service/ServiceIdCacheService.java
+28
-0
apm-collector/apm-collector-cache/collector-cache-define/src/main/java/org/skywalking/apm/collector/cache/service/ServiceNameCacheService.java
.../apm/collector/cache/service/ServiceNameCacheService.java
+30
-0
apm-collector/apm-collector-cache/collector-cache-define/src/main/resources/META-INF/services/org.skywalking.apm.collector.core.module.Module
.../services/org.skywalking.apm.collector.core.module.Module
+19
-0
apm-collector/apm-collector-cache/collector-cache-guava-provider/pom.xml
...pm-collector-cache/collector-cache-guava-provider/pom.xml
+40
-0
apm-collector/apm-collector-cache/collector-cache-guava-provider/src/main/java/org/skywalking/apm/collector/cache/guava/CacheModuleGuavaProvider.java
...g/apm/collector/cache/guava/CacheModuleGuavaProvider.java
+74
-0
apm-collector/apm-collector-cache/collector-cache-guava-provider/src/main/java/org/skywalking/apm/collector/cache/guava/service/ApplicationCacheGuavaService.java
...tor/cache/guava/service/ApplicationCacheGuavaService.java
+17
-10
apm-collector/apm-collector-cache/collector-cache-guava-provider/src/main/java/org/skywalking/apm/collector/cache/guava/service/InstanceCacheGuavaService.java
...lector/cache/guava/service/InstanceCacheGuavaService.java
+14
-7
apm-collector/apm-collector-cache/collector-cache-guava-provider/src/main/java/org/skywalking/apm/collector/cache/guava/service/ServiceIdCacheGuavaService.java
...ector/cache/guava/service/ServiceIdCacheGuavaService.java
+14
-8
apm-collector/apm-collector-cache/collector-cache-guava-provider/src/main/java/org/skywalking/apm/collector/cache/guava/service/ServiceNameCacheGuavaService.java
...tor/cache/guava/service/ServiceNameCacheGuavaService.java
+15
-9
apm-collector/apm-collector-cache/collector-cache-guava-provider/src/main/resources/META-INF/services/org.skywalking.apm.collector.core.module.ModuleProvider
...s/org.skywalking.apm.collector.core.module.ModuleProvider
+19
-0
apm-collector/apm-collector-cache/pom.xml
apm-collector/apm-collector-cache/pom.xml
+5
-1
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/base/dao/DAOContainer.java
...ywalking/apm/collector/storage/base/dao/DAOContainer.java
+19
-5
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/base/dao/IPersistenceDAO.java
...lking/apm/collector/storage/base/dao/IPersistenceDAO.java
+1
-1
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IInstanceCacheDAO.java
...ywalking/apm/collector/storage/dao/IInstanceCacheDAO.java
+3
-1
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IServiceNameCacheDAO.java
...lking/apm/collector/storage/dao/IServiceNameCacheDAO.java
+3
-1
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/service/ElasticSearchDAOService.java
...collector/storage/es/service/ElasticSearchDAOService.java
+7
-2
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/InstanceH2UIDAO.java
...walking/apm/collector/storage/h2/dao/InstanceH2UIDAO.java
+1
-2
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/service/H2DAOService.java
...alking/apm/collector/storage/h2/service/H2DAOService.java
+7
-2
apm-collector/apm-collector-stream/collector-stream-define/pom.xml
...ctor/apm-collector-stream/collector-stream-define/pom.xml
+1
-13
未找到文件。
apm-collector/apm-collector-agent/collector-agent-stream/src/main/java/org/skywalking/apm/collector/agent/stream/worker/jvm/CpuMetricPersistenceWorker.java
浏览文件 @
b1e2ebd4
...
...
@@ -50,9 +50,9 @@ public class CpuMetricPersistenceWorker extends PersistenceWorker<CpuMetric, Cpu
return
daoService
.
getPersistenceDAO
(
ICpuMetricStreamDAO
.
class
);
}
public
static
class
Factory
extends
AbstractLocalAsyncWorkerProvider
<
CpuMetricPersistenceWorker
>
{
public
static
class
Factory
extends
AbstractLocalAsyncWorkerProvider
<
CpuMetric
,
CpuMetric
,
CpuMetric
PersistenceWorker
>
{
public
Factory
(
DAOService
daoService
,
QueueCreatorService
queueCreatorService
)
{
public
Factory
(
DAOService
daoService
,
QueueCreatorService
<
CpuMetric
>
queueCreatorService
)
{
super
(
daoService
,
queueCreatorService
);
}
...
...
apm-collector/apm-collector-boot/pom.xml
浏览文件 @
b1e2ebd4
...
...
@@ -136,5 +136,12 @@
<version>
${project.version}
</version>
</dependency>
<!-- stream provider -->
<!-- cache provider -->
<dependency>
<groupId>
org.skywalking
</groupId>
<artifactId>
collector-cache-guava-provider
</artifactId>
<version>
${project.version}
</version>
</dependency>
<!-- cache provider -->
</dependencies>
</project>
\ No newline at end of file
apm-collector/apm-collector-cache/collector-cache-define/pom.xml
0 → 100644
浏览文件 @
b1e2ebd4
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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
-->
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<artifactId>
apm-collector-cache
</artifactId>
<groupId>
org.skywalking
</groupId>
<version>
3.2.4-2017
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
collector-cache-define
</artifactId>
<packaging>
jar
</packaging>
</project>
\ No newline at end of file
apm-collector/apm-collector-cache/collector-cache-define/src/main/java/org/skywalking/apm/collector/cache/CacheModule.java
0 → 100644
浏览文件 @
b1e2ebd4
/*
* 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.cache
;
import
org.skywalking.apm.collector.cache.service.ApplicationCacheService
;
import
org.skywalking.apm.collector.cache.service.InstanceCacheService
;
import
org.skywalking.apm.collector.cache.service.ServiceIdCacheService
;
import
org.skywalking.apm.collector.cache.service.ServiceNameCacheService
;
import
org.skywalking.apm.collector.core.module.Module
;
/**
* @author peng-yongsheng
*/
public
class
CacheModule
extends
Module
{
public
static
final
String
NAME
=
"cache"
;
@Override
public
String
name
()
{
return
NAME
;
}
@Override
public
Class
[]
services
()
{
return
new
Class
[]
{
ApplicationCacheService
.
class
,
InstanceCacheService
.
class
,
ServiceIdCacheService
.
class
,
ServiceNameCacheService
.
class
};
}
}
apm-collector/apm-collector-cache/collector-cache-define/src/main/java/org/skywalking/apm/collector/cache/service/ApplicationCacheService.java
0 → 100644
浏览文件 @
b1e2ebd4
/*
* 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.cache.service
;
import
org.skywalking.apm.collector.core.module.Service
;
/**
* @author peng-yongsheng
*/
public
interface
ApplicationCacheService
extends
Service
{
int
get
(
String
applicationCode
);
String
get
(
int
applicationId
);
}
apm-collector/apm-collector-cache/collector-cache-define/src/main/java/org/skywalking/apm/collector/cache/service/InstanceCacheService.java
0 → 100644
浏览文件 @
b1e2ebd4
/*
* 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.cache.service
;
import
org.skywalking.apm.collector.core.module.Service
;
/**
* @author peng-yongsheng
*/
public
interface
InstanceCacheService
extends
Service
{
int
get
(
int
applicationInstanceId
);
}
apm-collector/apm-collector-cache/collector-cache-define/src/main/java/org/skywalking/apm/collector/cache/service/ServiceIdCacheService.java
0 → 100644
浏览文件 @
b1e2ebd4
/*
* 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.cache.service
;
import
org.skywalking.apm.collector.core.module.Service
;
/**
* @author peng-yongsheng
*/
public
interface
ServiceIdCacheService
extends
Service
{
int
get
(
int
applicationId
,
String
serviceName
);
}
apm-collector/apm-collector-cache/collector-cache-define/src/main/java/org/skywalking/apm/collector/cache/service/ServiceNameCacheService.java
0 → 100644
浏览文件 @
b1e2ebd4
/*
* 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.cache.service
;
import
org.skywalking.apm.collector.core.module.Service
;
/**
* @author peng-yongsheng
*/
public
interface
ServiceNameCacheService
extends
Service
{
String
get
(
int
serviceId
);
String
getSplitServiceName
(
String
serviceName
);
}
apm-collector/apm-collector-cache/collector-cache-define/src/main/resources/META-INF/services/org.skywalking.apm.collector.core.module.Module
0 → 100644
浏览文件 @
b1e2ebd4
#
# 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
#
org
.
skywalking
.
apm
.
collector
.
cache
.
CacheModule
\ No newline at end of file
apm-collector/apm-collector-cache/collector-cache-guava-provider/pom.xml
0 → 100644
浏览文件 @
b1e2ebd4
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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
-->
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<artifactId>
apm-collector-cache
</artifactId>
<groupId>
org.skywalking
</groupId>
<version>
3.2.4-2017
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
collector-cache-guava-provider
</artifactId>
<packaging>
jar
</packaging>
<dependencies>
<dependency>
<groupId>
org.skywalking
</groupId>
<artifactId>
collector-cache-define
</artifactId>
<version>
${project.version}
</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
apm-collector/apm-collector-cache/collector-cache-guava-provider/src/main/java/org/skywalking/apm/collector/cache/guava/CacheModuleGuavaProvider.java
0 → 100644
浏览文件 @
b1e2ebd4
/*
* 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.cache.guava
;
import
java.util.Properties
;
import
org.skywalking.apm.collector.cache.CacheModule
;
import
org.skywalking.apm.collector.cache.guava.service.ApplicationCacheGuavaService
;
import
org.skywalking.apm.collector.cache.guava.service.InstanceCacheGuavaService
;
import
org.skywalking.apm.collector.cache.guava.service.ServiceIdCacheGuavaService
;
import
org.skywalking.apm.collector.cache.guava.service.ServiceNameCacheGuavaService
;
import
org.skywalking.apm.collector.cache.service.ApplicationCacheService
;
import
org.skywalking.apm.collector.cache.service.InstanceCacheService
;
import
org.skywalking.apm.collector.cache.service.ServiceIdCacheService
;
import
org.skywalking.apm.collector.cache.service.ServiceNameCacheService
;
import
org.skywalking.apm.collector.core.module.Module
;
import
org.skywalking.apm.collector.core.module.ModuleNotFoundException
;
import
org.skywalking.apm.collector.core.module.ModuleProvider
;
import
org.skywalking.apm.collector.core.module.ServiceNotProvidedException
;
import
org.skywalking.apm.collector.storage.StorageModule
;
import
org.skywalking.apm.collector.storage.service.DAOService
;
/**
* @author peng-yongsheng
*/
public
class
CacheModuleGuavaProvider
extends
ModuleProvider
{
@Override
public
String
name
()
{
return
"guava"
;
}
@Override
public
Class
<?
extends
Module
>
module
()
{
return
CacheModule
.
class
;
}
@Override
public
void
prepare
(
Properties
config
)
throws
ServiceNotProvidedException
{
}
@Override
public
void
start
(
Properties
config
)
throws
ServiceNotProvidedException
{
try
{
DAOService
daoService
=
getManager
().
find
(
StorageModule
.
NAME
).
getService
(
DAOService
.
class
);
this
.
registerServiceImplementation
(
ApplicationCacheService
.
class
,
new
ApplicationCacheGuavaService
(
daoService
));
this
.
registerServiceImplementation
(
InstanceCacheService
.
class
,
new
InstanceCacheGuavaService
(
daoService
));
this
.
registerServiceImplementation
(
ServiceIdCacheService
.
class
,
new
ServiceIdCacheGuavaService
(
daoService
));
this
.
registerServiceImplementation
(
ServiceNameCacheService
.
class
,
new
ServiceNameCacheGuavaService
(
daoService
));
}
catch
(
ModuleNotFoundException
e
)
{
throw
new
ServiceNotProvidedException
(
e
.
getMessage
());
}
}
@Override
public
void
notifyAfterCompleted
()
throws
ServiceNotProvidedException
{
}
@Override
public
String
[]
requiredModules
()
{
return
new
String
[]
{
StorageModule
.
NAME
};
}
}
apm-collector/apm-collector-cache/
src/main/java/org/skywalking/apm/collector/cache/ApplicationCach
e.java
→
apm-collector/apm-collector-cache/
collector-cache-guava-provider/src/main/java/org/skywalking/apm/collector/cache/guava/service/ApplicationCacheGuavaServic
e.java
浏览文件 @
b1e2ebd4
...
...
@@ -16,28 +16,35 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.cache
;
package
org.skywalking.apm.collector.cache
.guava.service
;
import
com.google.common.cache.Cache
;
import
com.google.common.cache.CacheBuilder
;
import
org.skywalking.apm.collector.cache.service.ApplicationCacheService
;
import
org.skywalking.apm.collector.core.util.Const
;
import
org.skywalking.apm.collector.core.util.StringUtils
;
import
org.skywalking.apm.collector.storage.base.dao.DAOContainer
;
import
org.skywalking.apm.collector.storage.dao.IApplicationCacheDAO
;
import
org.skywalking.apm.collector.storage.service.DAOService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
ApplicationCache
{
public
class
ApplicationCache
GuavaService
implements
ApplicationCacheService
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ApplicationCach
e
.
class
);
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ApplicationCacheGuavaServic
e
.
class
);
private
static
Cache
<
String
,
Integer
>
CODE_CACHE
=
CacheBuilder
.
newBuilder
().
initialCapacity
(
100
).
maximumSize
(
1000
).
build
();
private
final
Cache
<
String
,
Integer
>
CODE_CACHE
=
CacheBuilder
.
newBuilder
().
initialCapacity
(
100
).
maximumSize
(
1000
).
build
();
public
static
int
get
(
String
applicationCode
)
{
IApplicationCacheDAO
dao
=
(
IApplicationCacheDAO
)
DAOContainer
.
INSTANCE
.
get
(
IApplicationCacheDAO
.
class
.
getName
());
private
final
DAOService
daoService
;
public
ApplicationCacheGuavaService
(
DAOService
daoService
)
{
this
.
daoService
=
daoService
;
}
public
int
get
(
String
applicationCode
)
{
IApplicationCacheDAO
dao
=
(
IApplicationCacheDAO
)
daoService
.
get
(
IApplicationCacheDAO
.
class
);
int
applicationId
=
0
;
try
{
...
...
@@ -55,10 +62,10 @@ public class ApplicationCache {
return
applicationId
;
}
private
static
Cache
<
Integer
,
String
>
ID_CACHE
=
CacheBuilder
.
newBuilder
().
maximumSize
(
1000
).
build
();
private
final
Cache
<
Integer
,
String
>
ID_CACHE
=
CacheBuilder
.
newBuilder
().
maximumSize
(
1000
).
build
();
public
static
String
get
(
int
applicationId
)
{
IApplicationCacheDAO
dao
=
(
IApplicationCacheDAO
)
DAOContainer
.
INSTANCE
.
get
(
IApplicationCacheDAO
.
class
.
getName
()
);
public
String
get
(
int
applicationId
)
{
IApplicationCacheDAO
dao
=
(
IApplicationCacheDAO
)
daoService
.
get
(
IApplicationCacheDAO
.
class
);
String
applicationCode
=
Const
.
EMPTY_STRING
;
try
{
...
...
apm-collector/apm-collector-cache/
src/main/java/org/skywalking/apm/collector/cache/InstanceCach
e.java
→
apm-collector/apm-collector-cache/
collector-cache-guava-provider/src/main/java/org/skywalking/apm/collector/cache/guava/service/InstanceCacheGuavaServic
e.java
浏览文件 @
b1e2ebd4
...
...
@@ -16,26 +16,33 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.cache
;
package
org.skywalking.apm.collector.cache
.guava.service
;
import
com.google.common.cache.Cache
;
import
com.google.common.cache.CacheBuilder
;
import
org.skywalking.apm.collector.
storage.base.dao.DAOContainer
;
import
org.skywalking.apm.collector.
cache.service.InstanceCacheService
;
import
org.skywalking.apm.collector.storage.dao.IInstanceCacheDAO
;
import
org.skywalking.apm.collector.storage.service.DAOService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
InstanceCache
{
public
class
InstanceCache
GuavaService
implements
InstanceCacheService
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
InstanceCach
e
.
class
);
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
InstanceCacheGuavaServic
e
.
class
);
private
static
Cache
<
Integer
,
Integer
>
INSTANCE_CACHE
=
CacheBuilder
.
newBuilder
().
initialCapacity
(
100
).
maximumSize
(
5000
).
build
();
private
final
Cache
<
Integer
,
Integer
>
INSTANCE_CACHE
=
CacheBuilder
.
newBuilder
().
initialCapacity
(
100
).
maximumSize
(
5000
).
build
();
public
static
int
get
(
int
applicationInstanceId
)
{
IInstanceCacheDAO
dao
=
(
IInstanceCacheDAO
)
DAOContainer
.
INSTANCE
.
get
(
IInstanceCacheDAO
.
class
.
getName
());
private
final
DAOService
daoService
;
public
InstanceCacheGuavaService
(
DAOService
daoService
)
{
this
.
daoService
=
daoService
;
}
public
int
get
(
int
applicationInstanceId
)
{
IInstanceCacheDAO
dao
=
(
IInstanceCacheDAO
)
daoService
.
get
(
IInstanceCacheDAO
.
class
);
int
applicationId
=
0
;
try
{
...
...
apm-collector/apm-collector-cache/
src/main/java/org/skywalking/apm/collector/cache/ServiceIdCach
e.java
→
apm-collector/apm-collector-cache/
collector-cache-guava-provider/src/main/java/org/skywalking/apm/collector/cache/guava/service/ServiceIdCacheGuavaServic
e.java
浏览文件 @
b1e2ebd4
...
...
@@ -16,28 +16,34 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.cache
;
package
org.skywalking.apm.collector.cache
.guava.service
;
import
com.google.common.cache.Cache
;
import
com.google.common.cache.CacheBuilder
;
import
org.skywalking.apm.collector.cache.service.ServiceIdCacheService
;
import
org.skywalking.apm.collector.core.util.Const
;
import
org.skywalking.apm.collector.storage.base.dao.DAOContainer
;
import
org.skywalking.apm.collector.storage.dao.IServiceNameCacheDAO
;
import
org.skywalking.apm.collector.storage.service.DAOService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
ServiceIdCache
{
public
class
ServiceIdCache
GuavaService
implements
ServiceIdCacheService
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ServiceIdCach
e
.
class
);
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ServiceIdCacheGuavaServic
e
.
class
);
//TODO size configuration
private
static
Cache
<
String
,
Integer
>
SERVICE_CACHE
=
CacheBuilder
.
newBuilder
().
maximumSize
(
1000
).
build
();
private
final
Cache
<
String
,
Integer
>
SERVICE_CACHE
=
CacheBuilder
.
newBuilder
().
maximumSize
(
1000
).
build
();
public
static
int
get
(
int
applicationId
,
String
serviceName
)
{
IServiceNameCacheDAO
dao
=
(
IServiceNameCacheDAO
)
DAOContainer
.
INSTANCE
.
get
(
IServiceNameCacheDAO
.
class
.
getName
());
private
final
DAOService
daoService
;
public
ServiceIdCacheGuavaService
(
DAOService
daoService
)
{
this
.
daoService
=
daoService
;
}
public
int
get
(
int
applicationId
,
String
serviceName
)
{
IServiceNameCacheDAO
dao
=
(
IServiceNameCacheDAO
)
daoService
.
get
(
IServiceNameCacheDAO
.
class
);
int
serviceId
=
0
;
try
{
...
...
apm-collector/apm-collector-cache/
src/main/java/org/skywalking/apm/collector/cache/ServiceNameCach
e.java
→
apm-collector/apm-collector-cache/
collector-cache-guava-provider/src/main/java/org/skywalking/apm/collector/cache/guava/service/ServiceNameCacheGuavaServic
e.java
浏览文件 @
b1e2ebd4
...
...
@@ -16,29 +16,35 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.cache
;
package
org.skywalking.apm.collector.cache
.guava.service
;
import
com.google.common.cache.Cache
;
import
com.google.common.cache.CacheBuilder
;
import
org.skywalking.apm.collector.cache.service.ServiceNameCacheService
;
import
org.skywalking.apm.collector.core.util.Const
;
import
org.skywalking.apm.collector.core.util.StringUtils
;
import
org.skywalking.apm.collector.storage.base.dao.DAOContainer
;
import
org.skywalking.apm.collector.storage.dao.IServiceNameCacheDAO
;
import
org.skywalking.apm.collector.storage.service.DAOService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
ServiceNameCache
{
public
class
ServiceNameCache
GuavaService
implements
ServiceNameCacheService
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ServiceNameCach
e
.
class
);
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ServiceNameCacheGuavaServic
e
.
class
);
//TODO size configuration
private
static
Cache
<
Integer
,
String
>
CACHE
=
CacheBuilder
.
newBuilder
().
maximumSize
(
10000
).
build
();
private
final
Cache
<
Integer
,
String
>
CACHE
=
CacheBuilder
.
newBuilder
().
maximumSize
(
10000
).
build
();
public
static
String
get
(
int
serviceId
)
{
IServiceNameCacheDAO
dao
=
(
IServiceNameCacheDAO
)
DAOContainer
.
INSTANCE
.
get
(
IServiceNameCacheDAO
.
class
.
getName
());
private
final
DAOService
daoService
;
public
ServiceNameCacheGuavaService
(
DAOService
daoService
)
{
this
.
daoService
=
daoService
;
}
public
String
get
(
int
serviceId
)
{
IServiceNameCacheDAO
dao
=
(
IServiceNameCacheDAO
)
daoService
.
get
(
IServiceNameCacheDAO
.
class
);
String
serviceName
=
Const
.
EMPTY_STRING
;
try
{
...
...
@@ -57,7 +63,7 @@ public class ServiceNameCache {
return
serviceName
;
}
public
static
String
getSplitServiceName
(
String
serviceName
)
{
public
String
getSplitServiceName
(
String
serviceName
)
{
if
(
StringUtils
.
isNotEmpty
(
serviceName
))
{
String
[]
serviceNames
=
serviceName
.
split
(
Const
.
ID_SPLIT
);
if
(
serviceNames
.
length
==
2
)
{
...
...
apm-collector/apm-collector-cache/collector-cache-guava-provider/src/main/resources/META-INF/services/org.skywalking.apm.collector.core.module.ModuleProvider
0 → 100644
浏览文件 @
b1e2ebd4
#
# 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
#
org.skywalking.apm.collector.cache.guava.CacheModuleGuavaProvider
\ No newline at end of file
apm-collector/apm-collector-cache/pom.xml
浏览文件 @
b1e2ebd4
...
...
@@ -10,7 +10,11 @@
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
apm-collector-cache
</artifactId>
<packaging>
jar
</packaging>
<packaging>
pom
</packaging>
<modules>
<module>
collector-cache-define
</module>
<module>
collector-cache-guava-provider
</module>
</modules>
<dependencies>
<dependency>
...
...
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/base/dao/DAOContainer.java
浏览文件 @
b1e2ebd4
...
...
@@ -25,13 +25,27 @@ import java.util.Map;
* @author peng-yongsheng
*/
public
class
DAOContainer
{
private
Map
<
String
,
AbstractDAO
>
daos
=
new
HashMap
<>();
private
Map
<
String
,
DAO
>
daoImplMap
;
private
Map
<
String
,
IPersistenceDAO
>
persistenceDaoImpl
;
public
void
put
(
String
interfaceName
,
AbstractDAO
abstractDao
)
{
daos
.
put
(
interfaceName
,
abstractDao
);
public
DAOContainer
()
{
daoImplMap
=
new
HashMap
<>();
persistenceDaoImpl
=
new
HashMap
<>();
}
public
AbstractDAO
get
(
String
interfaceName
)
{
return
daos
.
get
(
interfaceName
);
public
void
put
(
String
interfaceName
,
DAO
daoImpl
)
{
if
(
daoImpl
instanceof
IPersistenceDAO
)
{
persistenceDaoImpl
.
put
(
interfaceName
,
(
IPersistenceDAO
)
daoImpl
);
}
else
{
daoImplMap
.
put
(
interfaceName
,
daoImpl
);
}
}
public
DAO
get
(
String
interfaceName
)
{
return
daoImplMap
.
get
(
interfaceName
);
}
public
IPersistenceDAO
getPersistenceDAO
(
String
interfaceName
)
{
return
persistenceDaoImpl
.
get
(
interfaceName
);
}
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/base/dao/IPersistenceDAO.java
浏览文件 @
b1e2ebd4
...
...
@@ -23,7 +23,7 @@ import org.skywalking.apm.collector.core.data.Data;
/**
* @author peng-yongsheng
*/
public
interface
IPersistenceDAO
<
Insert
,
Update
,
DataImpl
extends
Data
>
{
public
interface
IPersistenceDAO
<
Insert
,
Update
,
DataImpl
extends
Data
>
extends
DAO
{
DataImpl
get
(
String
id
);
Insert
prepareBatchInsert
(
DataImpl
data
);
...
...
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IInstanceCacheDAO.java
浏览文件 @
b1e2ebd4
...
...
@@ -18,9 +18,11 @@
package
org.skywalking.apm.collector.storage.dao
;
import
org.skywalking.apm.collector.storage.base.dao.DAO
;
/**
* @author peng-yongsheng
*/
public
interface
IInstanceCacheDAO
{
public
interface
IInstanceCacheDAO
extends
DAO
{
int
getApplicationId
(
int
applicationInstanceId
);
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IServiceNameCacheDAO.java
浏览文件 @
b1e2ebd4
...
...
@@ -18,10 +18,12 @@
package
org.skywalking.apm.collector.storage.dao
;
import
org.skywalking.apm.collector.storage.base.dao.DAO
;
/**
* @author peng-yongsheng
*/
public
interface
IServiceNameCacheDAO
{
public
interface
IServiceNameCacheDAO
extends
DAO
{
String
getServiceName
(
int
serviceId
);
int
getServiceId
(
int
applicationId
,
String
serviceName
);
...
...
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/service/ElasticSearchDAOService.java
浏览文件 @
b1e2ebd4
...
...
@@ -18,8 +18,9 @@
package
org.skywalking.apm.collector.storage.es.service
;
import
org.skywalking.apm.collector.storage.base.dao.
Abstract
DAO
;
import
org.skywalking.apm.collector.storage.base.dao.DAO
;
import
org.skywalking.apm.collector.storage.base.dao.DAOContainer
;
import
org.skywalking.apm.collector.storage.base.dao.IPersistenceDAO
;
import
org.skywalking.apm.collector.storage.service.DAOService
;
/**
...
...
@@ -33,7 +34,11 @@ public class ElasticSearchDAOService implements DAOService {
this
.
daoContainer
=
daoContainer
;
}
@Override
public
AbstractDAO
get
(
Class
<
Abstract
DAO
>
daoInterfaceClass
)
{
@Override
public
DAO
get
(
Class
<?
extends
DAO
>
daoInterfaceClass
)
{
return
daoContainer
.
get
(
daoInterfaceClass
.
getName
());
}
@Override
public
IPersistenceDAO
getPersistenceDAO
(
Class
<?
extends
IPersistenceDAO
>
daoInterfaceClass
)
{
return
daoContainer
.
getPersistenceDAO
(
daoInterfaceClass
.
getName
());
}
}
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/InstanceH2UIDAO.java
浏览文件 @
b1e2ebd4
...
...
@@ -41,7 +41,7 @@ import org.slf4j.LoggerFactory;
public
class
InstanceH2UIDAO
extends
H2DAO
implements
IInstanceUIDAO
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
InstanceH2UIDAO
.
class
);
private
static
final
String
GET_LAST_HEARTBEAT_TIME_SQL
=
"select {0} from {1} where {2} > ? limit 1"
;
private
static
final
String
GET_INST_LAST_HEARTBEAT_TIME_SQL
=
"select {0} from {1} where {2} > ? and {3} = ? limit 1"
;
private
static
final
String
GET_INSTANCE_SQL
=
"select * from {0} where {1} = ?"
;
...
...
@@ -96,7 +96,6 @@ public class InstanceH2UIDAO extends H2DAO implements IInstanceUIDAO {
logger
.
debug
(
"applicationId: {}"
,
applicationId
);
JsonObject
application
=
new
JsonObject
();
application
.
addProperty
(
"applicationId"
,
applicationId
);
application
.
addProperty
(
"applicationCode"
,
ApplicationCache
.
get
(
applicationId
));
application
.
addProperty
(
"instanceCount"
,
rs
.
getInt
(
"cnt"
));
applications
.
add
(
application
);
}
...
...
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/service/H2DAOService.java
浏览文件 @
b1e2ebd4
...
...
@@ -18,8 +18,9 @@
package
org.skywalking.apm.collector.storage.h2.service
;
import
org.skywalking.apm.collector.storage.base.dao.
Abstract
DAO
;
import
org.skywalking.apm.collector.storage.base.dao.DAO
;
import
org.skywalking.apm.collector.storage.base.dao.DAOContainer
;
import
org.skywalking.apm.collector.storage.base.dao.IPersistenceDAO
;
import
org.skywalking.apm.collector.storage.service.DAOService
;
/**
...
...
@@ -33,7 +34,11 @@ public class H2DAOService implements DAOService {
this
.
daoContainer
=
daoContainer
;
}
@Override
public
AbstractDAO
get
(
Class
<
Abstract
DAO
>
daoInterfaceClass
)
{
@Override
public
DAO
get
(
Class
<?
extends
DAO
>
daoInterfaceClass
)
{
return
daoContainer
.
get
(
daoInterfaceClass
.
getName
());
}
@Override
public
IPersistenceDAO
getPersistenceDAO
(
Class
<?
extends
IPersistenceDAO
>
daoInterfaceClass
)
{
return
daoContainer
.
getPersistenceDAO
(
daoInterfaceClass
.
getName
());
}
}
apm-collector/apm-collector-stream/collector-stream-define/pom.xml
浏览文件 @
b1e2ebd4
...
...
@@ -29,16 +29,4 @@
<artifactId>
collector-stream-define
</artifactId>
<packaging>
jar
</packaging>
<<<<<<
< HEAD
</project
>
=======
<dependencies>
<dependency>
<groupId>
org.skywalking
</groupId>
<artifactId>
queue-component
</artifactId>
<version>
${project.version}
</version>
</dependency>
</dependencies>
</project>
>>>>>>> 406c4f52d8251eb81aa868ec38f17789e18e0dc0
</project>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录