Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
山不在高_有仙则灵
SkyWalking
提交
bece77e2
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,发现更多精彩内容 >>
提交
bece77e2
编写于
2月 27, 2018
作者:
P
peng-yongsheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TPS calculate.
上级
3c8eaa8f
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
136 addition
and
4 deletion
+136
-4
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IInstanceUIDAO.java
...ywalking/apm/collector/storage/dao/ui/IInstanceUIDAO.java
+4
-0
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/InstanceEsUIDAO.java
...king/apm/collector/storage/es/dao/ui/InstanceEsUIDAO.java
+42
-1
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/InstanceH2UIDAO.java
...king/apm/collector/storage/h2/dao/ui/InstanceH2UIDAO.java
+10
-0
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/SecondBetweenService.java
...alking/apm/collector/ui/service/SecondBetweenService.java
+58
-0
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TopologyBuilder.java
.../skywalking/apm/collector/ui/service/TopologyBuilder.java
+22
-3
未找到文件。
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IInstanceUIDAO.java
浏览文件 @
bece77e2
...
...
@@ -39,4 +39,8 @@ public interface IInstanceUIDAO extends DAO {
List
<
AppServerInfo
>
searchServer
(
String
keyword
,
long
start
,
long
end
);
List
<
AppServerInfo
>
getAllServer
(
int
applicationId
,
long
startSecondTimeBucket
,
long
endSecondTimeBucket
);
long
getEarliestRegisterTime
(
int
applicationId
);
long
getLatestHeartBeatTime
(
int
applicationId
);
}
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/InstanceEsUIDAO.java
浏览文件 @
bece77e2
...
...
@@ -171,7 +171,8 @@ public class InstanceEsUIDAO extends EsDAO implements IInstanceUIDAO {
return
buildAppServerInfo
(
searchHits
);
}
@Override
public
List
<
AppServerInfo
>
getAllServer
(
int
applicationId
,
long
startSecondTimeBucket
,
long
endSecondTimeBucket
)
{
@Override
public
List
<
AppServerInfo
>
getAllServer
(
int
applicationId
,
long
startSecondTimeBucket
,
long
endSecondTimeBucket
)
{
logger
.
debug
(
"get instances info, applicationId: {}, start: {}, end: {}"
,
applicationId
,
startSecondTimeBucket
,
endSecondTimeBucket
);
SearchRequestBuilder
searchRequestBuilder
=
getClient
().
prepareSearch
(
InstanceTable
.
TABLE
);
searchRequestBuilder
.
setTypes
(
InstanceTable
.
TABLE_TYPE
);
...
...
@@ -192,6 +193,46 @@ public class InstanceEsUIDAO extends EsDAO implements IInstanceUIDAO {
return
buildAppServerInfo
(
searchHits
);
}
@Override
public
long
getEarliestRegisterTime
(
int
applicationId
)
{
SearchRequestBuilder
searchRequestBuilder
=
getClient
().
prepareSearch
(
InstanceTable
.
TABLE
);
searchRequestBuilder
.
setTypes
(
InstanceTable
.
TABLE_TYPE
);
searchRequestBuilder
.
setSearchType
(
SearchType
.
DFS_QUERY_THEN_FETCH
);
searchRequestBuilder
.
setSize
(
1
);
searchRequestBuilder
.
setQuery
(
QueryBuilders
.
termQuery
(
InstanceTable
.
COLUMN_APPLICATION_ID
,
applicationId
));
searchRequestBuilder
.
addSort
(
SortBuilders
.
fieldSort
(
InstanceTable
.
COLUMN_REGISTER_TIME
).
sortMode
(
SortMode
.
MIN
));
SearchResponse
searchResponse
=
searchRequestBuilder
.
execute
().
actionGet
();
SearchHit
[]
searchHits
=
searchResponse
.
getHits
().
getHits
();
if
(
searchHits
.
length
>
0
)
{
return
((
Number
)
searchHits
[
0
].
getSource
().
get
(
InstanceTable
.
COLUMN_REGISTER_TIME
)).
longValue
();
}
return
Long
.
MIN_VALUE
;
}
@Override
public
long
getLatestHeartBeatTime
(
int
applicationId
)
{
SearchRequestBuilder
searchRequestBuilder
=
getClient
().
prepareSearch
(
InstanceTable
.
TABLE
);
searchRequestBuilder
.
setTypes
(
InstanceTable
.
TABLE_TYPE
);
searchRequestBuilder
.
setSearchType
(
SearchType
.
DFS_QUERY_THEN_FETCH
);
searchRequestBuilder
.
setSize
(
1
);
searchRequestBuilder
.
setQuery
(
QueryBuilders
.
termQuery
(
InstanceTable
.
COLUMN_APPLICATION_ID
,
applicationId
));
searchRequestBuilder
.
addSort
(
SortBuilders
.
fieldSort
(
InstanceTable
.
COLUMN_HEARTBEAT_TIME
).
sortMode
(
SortMode
.
MAX
));
SearchResponse
searchResponse
=
searchRequestBuilder
.
execute
().
actionGet
();
SearchHit
[]
searchHits
=
searchResponse
.
getHits
().
getHits
();
if
(
searchHits
.
length
>
0
)
{
return
((
Number
)
searchHits
[
0
].
getSource
().
get
(
InstanceTable
.
COLUMN_HEARTBEAT_TIME
)).
longValue
();
}
return
Long
.
MAX_VALUE
;
}
private
List
<
AppServerInfo
>
buildAppServerInfo
(
SearchHit
[]
searchHits
)
{
List
<
AppServerInfo
>
appServerInfos
=
new
LinkedList
<>();
for
(
SearchHit
searchHit
:
searchHits
)
{
...
...
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/InstanceH2UIDAO.java
浏览文件 @
bece77e2
...
...
@@ -164,4 +164,14 @@ public class InstanceH2UIDAO extends H2DAO implements IInstanceUIDAO {
}
return
appServerInfos
;
}
//TODO
@Override
public
long
getEarliestRegisterTime
(
int
applicationId
)
{
return
0
;
}
//TODO
@Override
public
long
getLatestHeartBeatTime
(
int
applicationId
)
{
return
0
;
}
}
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/SecondBetweenService.java
0 → 100644
浏览文件 @
bece77e2
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*
*/
package
org.apache.skywalking.apm.collector.ui.service
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
org.apache.skywalking.apm.collector.core.module.ModuleManager
;
import
org.apache.skywalking.apm.collector.storage.StorageModule
;
import
org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceUIDAO
;
import
org.joda.time.DateTime
;
import
org.joda.time.Seconds
;
/**
* @author peng-yongsheng
*/
class
SecondBetweenService
{
private
final
IInstanceUIDAO
instanceUIDAO
;
SecondBetweenService
(
ModuleManager
moduleManager
)
{
this
.
instanceUIDAO
=
moduleManager
.
find
(
StorageModule
.
NAME
).
getService
(
IInstanceUIDAO
.
class
);
}
int
calculate
(
int
applicationId
,
long
startSecondTimeBucket
,
long
endSecondTimeBucket
)
throws
ParseException
{
long
registerTime
=
instanceUIDAO
.
getEarliestRegisterTime
(
applicationId
);
if
(
startSecondTimeBucket
<
registerTime
)
{
startSecondTimeBucket
=
registerTime
;
}
long
heartBeatTime
=
instanceUIDAO
.
getLatestHeartBeatTime
(
applicationId
);
if
(
endSecondTimeBucket
>
heartBeatTime
)
{
endSecondTimeBucket
=
heartBeatTime
;
}
Date
startDate
=
new
SimpleDateFormat
(
"yyyyMMddHHmmss"
).
parse
(
String
.
valueOf
(
startSecondTimeBucket
));
Date
endDate
=
new
SimpleDateFormat
(
"yyyyMMddHHmmss"
).
parse
(
String
.
valueOf
(
endSecondTimeBucket
));
return
Seconds
.
secondsBetween
(
new
DateTime
(
startDate
),
new
DateTime
(
endDate
)).
getSeconds
();
}
}
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TopologyBuilder.java
浏览文件 @
bece77e2
...
...
@@ -18,6 +18,7 @@
package
org.apache.skywalking.apm.collector.ui.service
;
import
java.text.ParseException
;
import
java.util.HashMap
;
import
java.util.LinkedList
;
import
java.util.List
;
...
...
@@ -41,18 +42,24 @@ import org.apache.skywalking.apm.collector.storage.ui.common.VisualUserNode;
import
org.apache.skywalking.apm.collector.ui.utils.ApdexCalculator
;
import
org.apache.skywalking.apm.collector.ui.utils.SLACalculator
;
import
org.apache.skywalking.apm.network.trace.component.ComponentsDefine
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
class
TopologyBuilder
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
TopologyBuilder
.
class
);
private
final
ApplicationCacheService
applicationCacheService
;
private
final
ServerService
serverService
;
private
final
SecondBetweenService
secondBetweenService
;
TopologyBuilder
(
ModuleManager
moduleManager
)
{
this
.
applicationCacheService
=
moduleManager
.
find
(
CacheModule
.
NAME
).
getService
(
ApplicationCacheService
.
class
);
this
.
serverService
=
new
ServerService
(
moduleManager
);
this
.
secondBetweenService
=
new
SecondBetweenService
(
moduleManager
);
}
Topology
build
(
List
<
IApplicationComponentUIDAO
.
ApplicationComponent
>
applicationComponents
,
...
...
@@ -76,7 +83,11 @@ class TopologyBuilder {
applicationNode
.
setType
(
components
.
getOrDefault
(
application
.
getApplicationId
(),
Const
.
UNKNOWN
));
applicationNode
.
setSla
(
SLACalculator
.
INSTANCE
.
calculate
(
applicationMetric
.
getErrorCalls
(),
applicationMetric
.
getCalls
()));
applicationNode
.
setCallsPerSec
(
100L
);
try
{
applicationNode
.
setCallsPerSec
(
applicationMetric
.
getCalls
()
/
secondBetweenService
.
calculate
(
applicationId
,
startSecondTimeBucket
,
endSecondTimeBucket
));
}
catch
(
ParseException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
applicationNode
.
setAvgResponseTime
((
applicationMetric
.
getDurations
()
-
applicationMetric
.
getErrorDurations
())
/
(
applicationMetric
.
getCalls
()
-
applicationMetric
.
getErrorCalls
()));
applicationNode
.
setApdex
(
ApdexCalculator
.
INSTANCE
.
calculate
(
applicationMetric
.
getSatisfiedCount
(),
applicationMetric
.
getToleratingCount
(),
applicationMetric
.
getFrustratedCount
()));
applicationNode
.
setAlarm
(
false
);
...
...
@@ -108,7 +119,11 @@ class TopologyBuilder {
call
.
setTargetName
(
applicationCacheService
.
getApplicationById
(
actualTargetId
).
getApplicationCode
());
call
.
setAlert
(
true
);
call
.
setCallType
(
components
.
get
(
referenceMetric
.
getTarget
()));
call
.
setCallsPerSec
(
1
);
try
{
call
.
setCallsPerSec
(
referenceMetric
.
getCalls
()
/
secondBetweenService
.
calculate
(
source
.
getApplicationId
(),
startSecondTimeBucket
,
endSecondTimeBucket
));
}
catch
(
ParseException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
call
.
setAvgResponseTime
((
referenceMetric
.
getDurations
()
-
referenceMetric
.
getErrorDurations
())
/
(
referenceMetric
.
getCalls
()
-
referenceMetric
.
getErrorCalls
()));
calls
.
add
(
call
);
});
...
...
@@ -145,7 +160,11 @@ class TopologyBuilder {
}
else
{
call
.
setCallType
(
components
.
get
(
referenceMetric
.
getTarget
()));
}
call
.
setCallsPerSec
(
1
);
try
{
call
.
setCallsPerSec
(
referenceMetric
.
getCalls
()
/
secondBetweenService
.
calculate
(
target
.
getApplicationId
(),
startSecondTimeBucket
,
endSecondTimeBucket
));
}
catch
(
ParseException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
call
.
setAvgResponseTime
((
referenceMetric
.
getDurations
()
-
referenceMetric
.
getErrorDurations
())
/
(
referenceMetric
.
getCalls
()
-
referenceMetric
.
getErrorCalls
()));
calls
.
add
(
call
);
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录