Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
SkyWalking
提交
8e5408db
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,体验更适合开发者的 AI 搜索 >>
提交
8e5408db
编写于
12月 02, 2017
作者:
P
peng-yongsheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Define alerting list storage.
上级
dfec23ca
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
509 addition
and
4 deletion
+509
-4
apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/data/CommonTable.java
...a/org/skywalking/apm/collector/core/data/CommonTable.java
+0
-1
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/StorageModule.java
...a/org/skywalking/apm/collector/storage/StorageModule.java
+6
-0
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IAlertingListPersistenceDAO.java
...pm/collector/storage/dao/IAlertingListPersistenceDAO.java
+28
-0
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/alerting/AlertingList.java
...ng/apm/collector/storage/table/alerting/AlertingList.java
+113
-0
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/alerting/AlertingListTable.java
...m/collector/storage/table/alerting/AlertingListTable.java
+35
-0
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/StorageModuleEsProvider.java
...ing/apm/collector/storage/es/StorageModuleEsProvider.java
+8
-1
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/AlertingListEsPersistenceDAO.java
...ollector/storage/es/dao/AlertingListEsPersistenceDAO.java
+103
-0
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/define/AlertingListEsTableDefine.java
...ollector/storage/es/define/AlertingListEsTableDefine.java
+47
-0
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/resources/META-INF/defines/storage.define
...ovider/src/main/resources/META-INF/defines/storage.define
+2
-1
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/StorageModuleH2Provider.java
...ing/apm/collector/storage/h2/StorageModuleH2Provider.java
+7
-0
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/AlertingListH2PersistenceDAO.java
...ollector/storage/h2/dao/AlertingListH2PersistenceDAO.java
+112
-0
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/define/AlertingListH2TableDefine.java
...ollector/storage/h2/define/AlertingListH2TableDefine.java
+46
-0
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/resources/META-INF/defines/storage.define
...ovider/src/main/resources/META-INF/defines/storage.define
+2
-1
未找到文件。
apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/data/CommonTable.java
浏览文件 @
8e5408db
...
...
@@ -24,6 +24,5 @@ package org.skywalking.apm.collector.core.data;
public
abstract
class
CommonTable
{
public
static
final
String
TABLE_TYPE
=
"type"
;
public
static
final
String
COLUMN_ID
=
"id"
;
public
static
final
String
COLUMN_AGG
=
"agg"
;
public
static
final
String
COLUMN_TIME_BUCKET
=
"time_bucket"
;
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/StorageModule.java
浏览文件 @
8e5408db
...
...
@@ -22,6 +22,7 @@ import java.util.ArrayList;
import
java.util.List
;
import
org.skywalking.apm.collector.core.module.Module
;
import
org.skywalking.apm.collector.storage.base.dao.IBatchDAO
;
import
org.skywalking.apm.collector.storage.dao.IAlertingListPersistenceDAO
;
import
org.skywalking.apm.collector.storage.dao.IApplicationCacheDAO
;
import
org.skywalking.apm.collector.storage.dao.IApplicationComponentPersistenceDAO
;
import
org.skywalking.apm.collector.storage.dao.IApplicationComponentUIDAO
;
...
...
@@ -78,6 +79,7 @@ public class StorageModule extends Module {
addRegisterDAO
(
classes
);
addPersistenceDAO
(
classes
);
addUiDAO
(
classes
);
addAlertingDAO
(
classes
);
return
classes
.
toArray
(
new
Class
[]
{});
}
...
...
@@ -133,4 +135,8 @@ public class StorageModule extends Module {
classes
.
add
(
IServiceEntryUIDAO
.
class
);
classes
.
add
(
IServiceReferenceUIDAO
.
class
);
}
private
void
addAlertingDAO
(
List
<
Class
>
classes
)
{
classes
.
add
(
IAlertingListPersistenceDAO
.
class
);
}
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IAlertingListPersistenceDAO.java
0 → 100644
浏览文件 @
8e5408db
/*
* 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.storage.dao
;
import
org.skywalking.apm.collector.core.data.Data
;
import
org.skywalking.apm.collector.storage.base.dao.IPersistenceDAO
;
/**
* @author peng-yongsheng
*/
public
interface
IAlertingListPersistenceDAO
<
Insert
,
Update
,
DataImpl
extends
Data
>
extends
IPersistenceDAO
<
Insert
,
Update
,
DataImpl
>
{
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/alerting/AlertingList.java
0 → 100644
浏览文件 @
8e5408db
/*
* 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.storage.table.alerting
;
import
org.skywalking.apm.collector.core.data.Column
;
import
org.skywalking.apm.collector.core.data.Data
;
import
org.skywalking.apm.collector.core.data.operator.CoverOperation
;
import
org.skywalking.apm.collector.core.data.operator.NonOperation
;
/**
* @author peng-yongsheng
*/
public
class
AlertingList
extends
Data
{
private
static
final
Column
[]
STRING_COLUMNS
=
{
new
Column
(
AlertingListTable
.
COLUMN_ID
,
new
NonOperation
()),
};
private
static
final
Column
[]
LONG_COLUMNS
=
{
new
Column
(
AlertingListTable
.
COLUMN_FIRST_TIME_BUCKET
,
new
NonOperation
()),
new
Column
(
AlertingListTable
.
COLUMN_LAST_TIME_BUCKET
,
new
CoverOperation
()),
};
private
static
final
Column
[]
DOUBLE_COLUMNS
=
{};
private
static
final
Column
[]
INTEGER_COLUMNS
=
{
new
Column
(
AlertingListTable
.
COLUMN_LAYER
,
new
CoverOperation
()),
new
Column
(
AlertingListTable
.
COLUMN_LAYER_ID
,
new
CoverOperation
()),
new
Column
(
AlertingListTable
.
COLUMN_EXPECTED
,
new
CoverOperation
()),
new
Column
(
AlertingListTable
.
COLUMN_ACTUAL
,
new
CoverOperation
()),
};
private
static
final
Column
[]
BOOLEAN_COLUMNS
=
{
new
Column
(
AlertingListTable
.
COLUMN_VALID
,
new
CoverOperation
()),
};
private
static
final
Column
[]
BYTE_COLUMNS
=
{};
public
AlertingList
(
String
id
)
{
super
(
id
,
STRING_COLUMNS
,
LONG_COLUMNS
,
DOUBLE_COLUMNS
,
INTEGER_COLUMNS
,
BOOLEAN_COLUMNS
,
BYTE_COLUMNS
);
}
public
Integer
getLayer
()
{
return
getDataInteger
(
0
);
}
public
void
setLayer
(
Integer
layer
)
{
setDataInteger
(
0
,
layer
);
}
public
Integer
getLayerId
()
{
return
getDataInteger
(
1
);
}
public
void
setLayerId
(
Integer
layerId
)
{
setDataInteger
(
1
,
layerId
);
}
public
Integer
getExpected
()
{
return
getDataInteger
(
2
);
}
public
void
setExpected
(
Integer
expected
)
{
setDataInteger
(
2
,
expected
);
}
public
Integer
getActual
()
{
return
getDataInteger
(
3
);
}
public
void
setActual
(
Integer
actual
)
{
setDataInteger
(
3
,
actual
);
}
public
Long
getFirstTimeBucket
()
{
return
getDataLong
(
0
);
}
public
void
setFirstTimeBucket
(
Long
firstTimeBucket
)
{
setDataLong
(
0
,
firstTimeBucket
);
}
public
Long
getLastTimeBucket
()
{
return
getDataLong
(
1
);
}
public
void
setLastTimeBucket
(
Long
lastTimeBucket
)
{
setDataLong
(
1
,
lastTimeBucket
);
}
public
Boolean
getValid
()
{
return
getDataBoolean
(
0
);
}
public
void
setValid
(
Boolean
valid
)
{
setDataBoolean
(
0
,
valid
);
}
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/alerting/AlertingListTable.java
0 → 100644
浏览文件 @
8e5408db
/*
* 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.storage.table.alerting
;
import
org.skywalking.apm.collector.core.data.CommonTable
;
/**
* @author peng-yongsheng
*/
public
class
AlertingListTable
extends
CommonTable
{
public
static
final
String
TABLE
=
"alerting_list"
;
public
static
final
String
COLUMN_LAYER
=
"layer"
;
public
static
final
String
COLUMN_LAYER_ID
=
"layer_id"
;
public
static
final
String
COLUMN_FIRST_TIME_BUCKET
=
"first_time_bucket"
;
public
static
final
String
COLUMN_LAST_TIME_BUCKET
=
"last_time_bucket"
;
public
static
final
String
COLUMN_EXPECTED
=
"expected"
;
public
static
final
String
COLUMN_ACTUAL
=
"actual"
;
public
static
final
String
COLUMN_VALID
=
"valid"
;
}
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/StorageModuleEsProvider.java
浏览文件 @
8e5408db
...
...
@@ -31,6 +31,7 @@ import org.skywalking.apm.collector.core.module.ServiceNotProvidedException;
import
org.skywalking.apm.collector.storage.StorageException
;
import
org.skywalking.apm.collector.storage.StorageModule
;
import
org.skywalking.apm.collector.storage.base.dao.IBatchDAO
;
import
org.skywalking.apm.collector.storage.dao.IAlertingListPersistenceDAO
;
import
org.skywalking.apm.collector.storage.dao.IApplicationCacheDAO
;
import
org.skywalking.apm.collector.storage.dao.IApplicationComponentPersistenceDAO
;
import
org.skywalking.apm.collector.storage.dao.IApplicationComponentUIDAO
;
...
...
@@ -69,6 +70,7 @@ import org.skywalking.apm.collector.storage.dao.IServiceReferenceMetricPersisten
import
org.skywalking.apm.collector.storage.dao.IServiceReferenceUIDAO
;
import
org.skywalking.apm.collector.storage.es.base.dao.BatchEsDAO
;
import
org.skywalking.apm.collector.storage.es.base.define.ElasticSearchStorageInstaller
;
import
org.skywalking.apm.collector.storage.es.dao.AlertingListEsPersistenceDAO
;
import
org.skywalking.apm.collector.storage.es.dao.ApplicationComponentEsPersistenceDAO
;
import
org.skywalking.apm.collector.storage.es.dao.ApplicationComponentEsUIDAO
;
import
org.skywalking.apm.collector.storage.es.dao.ApplicationEsCacheDAO
;
...
...
@@ -145,6 +147,7 @@ public class StorageModuleEsProvider extends ModuleProvider {
registerRegisterDAO
();
registerPersistenceDAO
();
registerUiDAO
();
registerAlertingDAO
();
}
@Override
public
void
start
(
Properties
config
)
throws
ServiceNotProvidedException
{
...
...
@@ -230,4 +233,8 @@ public class StorageModuleEsProvider extends ModuleProvider {
this
.
registerServiceImplementation
(
IServiceEntryUIDAO
.
class
,
new
ServiceEntryEsUIDAO
(
elasticSearchClient
));
this
.
registerServiceImplementation
(
IServiceReferenceUIDAO
.
class
,
new
ServiceReferenceEsUIDAO
(
elasticSearchClient
));
}
}
private
void
registerAlertingDAO
()
throws
ServiceNotProvidedException
{
this
.
registerServiceImplementation
(
IAlertingListPersistenceDAO
.
class
,
new
AlertingListEsPersistenceDAO
(
elasticSearchClient
));
}
}
\ No newline at end of file
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/AlertingListEsPersistenceDAO.java
0 → 100644
浏览文件 @
8e5408db
/*
* 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.storage.es.dao
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.elasticsearch.action.get.GetResponse
;
import
org.elasticsearch.action.index.IndexRequestBuilder
;
import
org.elasticsearch.action.update.UpdateRequestBuilder
;
import
org.elasticsearch.index.query.QueryBuilders
;
import
org.elasticsearch.index.reindex.BulkByScrollResponse
;
import
org.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient
;
import
org.skywalking.apm.collector.core.util.TimeBucketUtils
;
import
org.skywalking.apm.collector.storage.dao.IAlertingListPersistenceDAO
;
import
org.skywalking.apm.collector.storage.es.base.dao.EsDAO
;
import
org.skywalking.apm.collector.storage.table.alerting.AlertingList
;
import
org.skywalking.apm.collector.storage.table.alerting.AlertingListTable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
AlertingListEsPersistenceDAO
extends
EsDAO
implements
IAlertingListPersistenceDAO
<
IndexRequestBuilder
,
UpdateRequestBuilder
,
AlertingList
>
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
AlertingListEsPersistenceDAO
.
class
);
public
AlertingListEsPersistenceDAO
(
ElasticSearchClient
client
)
{
super
(
client
);
}
@Override
public
AlertingList
get
(
String
id
)
{
GetResponse
getResponse
=
getClient
().
prepareGet
(
AlertingListTable
.
TABLE
,
id
).
get
();
if
(
getResponse
.
isExists
())
{
AlertingList
alertingList
=
new
AlertingList
(
id
);
Map
<
String
,
Object
>
source
=
getResponse
.
getSource
();
alertingList
.
setLayer
(((
Number
)
source
.
get
(
AlertingListTable
.
COLUMN_LAYER
)).
intValue
());
alertingList
.
setLayerId
(((
Number
)
source
.
get
(
AlertingListTable
.
COLUMN_LAYER_ID
)).
intValue
());
alertingList
.
setFirstTimeBucket
(((
Number
)
source
.
get
(
AlertingListTable
.
COLUMN_FIRST_TIME_BUCKET
)).
longValue
());
alertingList
.
setLastTimeBucket
(((
Number
)
source
.
get
(
AlertingListTable
.
COLUMN_LAST_TIME_BUCKET
)).
longValue
());
alertingList
.
setExpected
(((
Number
)
source
.
get
(
AlertingListTable
.
COLUMN_EXPECTED
)).
intValue
());
alertingList
.
setActual
(((
Number
)
source
.
get
(
AlertingListTable
.
COLUMN_ACTUAL
)).
intValue
());
alertingList
.
setValid
((
Boolean
)
source
.
get
(
AlertingListTable
.
COLUMN_VALID
));
return
alertingList
;
}
else
{
return
null
;
}
}
@Override
public
IndexRequestBuilder
prepareBatchInsert
(
AlertingList
data
)
{
Map
<
String
,
Object
>
source
=
new
HashMap
<>();
source
.
put
(
AlertingListTable
.
COLUMN_LAYER
,
data
.
getLayer
());
source
.
put
(
AlertingListTable
.
COLUMN_LAYER_ID
,
data
.
getLayerId
());
source
.
put
(
AlertingListTable
.
COLUMN_FIRST_TIME_BUCKET
,
data
.
getFirstTimeBucket
());
source
.
put
(
AlertingListTable
.
COLUMN_LAST_TIME_BUCKET
,
data
.
getLastTimeBucket
());
source
.
put
(
AlertingListTable
.
COLUMN_EXPECTED
,
data
.
getExpected
());
source
.
put
(
AlertingListTable
.
COLUMN_ACTUAL
,
data
.
getActual
());
source
.
put
(
AlertingListTable
.
COLUMN_VALID
,
data
.
getValid
());
return
getClient
().
prepareIndex
(
AlertingListTable
.
TABLE
,
data
.
getId
()).
setSource
(
source
);
}
@Override
public
UpdateRequestBuilder
prepareBatchUpdate
(
AlertingList
data
)
{
Map
<
String
,
Object
>
source
=
new
HashMap
<>();
source
.
put
(
AlertingListTable
.
COLUMN_LAYER
,
data
.
getLayer
());
source
.
put
(
AlertingListTable
.
COLUMN_LAYER_ID
,
data
.
getLayerId
());
source
.
put
(
AlertingListTable
.
COLUMN_FIRST_TIME_BUCKET
,
data
.
getFirstTimeBucket
());
source
.
put
(
AlertingListTable
.
COLUMN_LAST_TIME_BUCKET
,
data
.
getLastTimeBucket
());
source
.
put
(
AlertingListTable
.
COLUMN_EXPECTED
,
data
.
getExpected
());
source
.
put
(
AlertingListTable
.
COLUMN_ACTUAL
,
data
.
getActual
());
source
.
put
(
AlertingListTable
.
COLUMN_VALID
,
data
.
getValid
());
return
getClient
().
prepareUpdate
(
AlertingListTable
.
TABLE
,
data
.
getId
()).
setDoc
(
source
);
}
@Override
public
void
deleteHistory
(
Long
startTimestamp
,
Long
endTimestamp
)
{
long
startTimeBucket
=
TimeBucketUtils
.
INSTANCE
.
getMinuteTimeBucket
(
startTimestamp
);
long
endTimeBucket
=
TimeBucketUtils
.
INSTANCE
.
getMinuteTimeBucket
(
endTimestamp
);
BulkByScrollResponse
response
=
getClient
().
prepareDelete
()
.
filter
(
QueryBuilders
.
rangeQuery
(
AlertingListTable
.
COLUMN_TIME_BUCKET
).
gte
(
startTimeBucket
).
lte
(
endTimeBucket
))
.
source
(
AlertingListTable
.
TABLE
)
.
get
();
long
deleted
=
response
.
getDeleted
();
logger
.
info
(
"Delete {} rows history from {} index."
,
deleted
,
AlertingListTable
.
TABLE
);
}
}
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/define/AlertingListEsTableDefine.java
0 → 100644
浏览文件 @
8e5408db
/*
* 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.storage.es.define
;
import
org.skywalking.apm.collector.storage.es.base.define.ElasticSearchColumnDefine
;
import
org.skywalking.apm.collector.storage.es.base.define.ElasticSearchTableDefine
;
import
org.skywalking.apm.collector.storage.table.alerting.AlertingListTable
;
/**
* @author peng-yongsheng
*/
public
class
AlertingListEsTableDefine
extends
ElasticSearchTableDefine
{
public
AlertingListEsTableDefine
()
{
super
(
AlertingListTable
.
TABLE
);
}
@Override
public
int
refreshInterval
()
{
return
2
;
}
@Override
public
void
initialize
()
{
addColumn
(
new
ElasticSearchColumnDefine
(
AlertingListTable
.
COLUMN_LAYER
,
ElasticSearchColumnDefine
.
Type
.
Integer
.
name
()));
addColumn
(
new
ElasticSearchColumnDefine
(
AlertingListTable
.
COLUMN_LAYER_ID
,
ElasticSearchColumnDefine
.
Type
.
Integer
.
name
()));
addColumn
(
new
ElasticSearchColumnDefine
(
AlertingListTable
.
COLUMN_FIRST_TIME_BUCKET
,
ElasticSearchColumnDefine
.
Type
.
Long
.
name
()));
addColumn
(
new
ElasticSearchColumnDefine
(
AlertingListTable
.
COLUMN_LAST_TIME_BUCKET
,
ElasticSearchColumnDefine
.
Type
.
Long
.
name
()));
addColumn
(
new
ElasticSearchColumnDefine
(
AlertingListTable
.
COLUMN_EXPECTED
,
ElasticSearchColumnDefine
.
Type
.
Integer
.
name
()));
addColumn
(
new
ElasticSearchColumnDefine
(
AlertingListTable
.
COLUMN_ACTUAL
,
ElasticSearchColumnDefine
.
Type
.
Integer
.
name
()));
addColumn
(
new
ElasticSearchColumnDefine
(
AlertingListTable
.
COLUMN_VALID
,
ElasticSearchColumnDefine
.
Type
.
Boolean
.
name
()));
}
}
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/resources/META-INF/defines/storage.define
浏览文件 @
8e5408db
...
...
@@ -14,4 +14,5 @@ org.skywalking.apm.collector.storage.es.define.SegmentCostEsTableDefine
org.skywalking.apm.collector.storage.es.define.SegmentEsTableDefine
org.skywalking.apm.collector.storage.es.define.ServiceEntryEsTableDefine
org.skywalking.apm.collector.storage.es.define.ServiceMetricEsTableDefine
org.skywalking.apm.collector.storage.es.define.ServiceReferenceMetricEsTableDefine
\ No newline at end of file
org.skywalking.apm.collector.storage.es.define.ServiceReferenceMetricEsTableDefine
org.skywalking.apm.collector.storage.es.define.AlertingListEsTableDefine
\ No newline at end of file
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/StorageModuleH2Provider.java
浏览文件 @
8e5408db
...
...
@@ -26,6 +26,7 @@ import org.skywalking.apm.collector.core.module.ServiceNotProvidedException;
import
org.skywalking.apm.collector.storage.StorageException
;
import
org.skywalking.apm.collector.storage.StorageModule
;
import
org.skywalking.apm.collector.storage.base.dao.IBatchDAO
;
import
org.skywalking.apm.collector.storage.dao.IAlertingListPersistenceDAO
;
import
org.skywalking.apm.collector.storage.dao.IApplicationCacheDAO
;
import
org.skywalking.apm.collector.storage.dao.IApplicationComponentPersistenceDAO
;
import
org.skywalking.apm.collector.storage.dao.IApplicationComponentUIDAO
;
...
...
@@ -64,6 +65,7 @@ import org.skywalking.apm.collector.storage.dao.IServiceReferenceMetricPersisten
import
org.skywalking.apm.collector.storage.dao.IServiceReferenceUIDAO
;
import
org.skywalking.apm.collector.storage.h2.base.dao.BatchH2DAO
;
import
org.skywalking.apm.collector.storage.h2.base.define.H2StorageInstaller
;
import
org.skywalking.apm.collector.storage.h2.dao.AlertingListH2PersistenceDAO
;
import
org.skywalking.apm.collector.storage.h2.dao.ApplicationComponentH2PersistenceDAO
;
import
org.skywalking.apm.collector.storage.h2.dao.ApplicationComponentH2UIDAO
;
import
org.skywalking.apm.collector.storage.h2.dao.ApplicationH2CacheDAO
;
...
...
@@ -135,6 +137,7 @@ public class StorageModuleH2Provider extends ModuleProvider {
registerRegisterDAO
();
registerPersistenceDAO
();
registerUiDAO
();
registerAlertingDAO
();
}
@Override
public
void
start
(
Properties
config
)
throws
ServiceNotProvidedException
{
...
...
@@ -207,4 +210,8 @@ public class StorageModuleH2Provider extends ModuleProvider {
this
.
registerServiceImplementation
(
IServiceEntryUIDAO
.
class
,
new
ServiceEntryH2UIDAO
(
h2Client
));
this
.
registerServiceImplementation
(
IServiceReferenceUIDAO
.
class
,
new
ServiceReferenceH2UIDAO
(
h2Client
));
}
private
void
registerAlertingDAO
()
throws
ServiceNotProvidedException
{
this
.
registerServiceImplementation
(
IAlertingListPersistenceDAO
.
class
,
new
AlertingListH2PersistenceDAO
(
h2Client
));
}
}
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/AlertingListH2PersistenceDAO.java
0 → 100644
浏览文件 @
8e5408db
/*
* 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.storage.h2.dao
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
org.skywalking.apm.collector.client.h2.H2Client
;
import
org.skywalking.apm.collector.client.h2.H2ClientException
;
import
org.skywalking.apm.collector.storage.base.sql.SqlBuilder
;
import
org.skywalking.apm.collector.storage.dao.IAlertingListPersistenceDAO
;
import
org.skywalking.apm.collector.storage.h2.base.dao.H2DAO
;
import
org.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity
;
import
org.skywalking.apm.collector.storage.table.alerting.AlertingList
;
import
org.skywalking.apm.collector.storage.table.alerting.AlertingListTable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
AlertingListH2PersistenceDAO
extends
H2DAO
implements
IAlertingListPersistenceDAO
<
H2SqlEntity
,
H2SqlEntity
,
AlertingList
>
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
AlertingListH2PersistenceDAO
.
class
);
private
static
final
String
GET_SQL
=
"select * from {0} where {1} = ?"
;
public
AlertingListH2PersistenceDAO
(
H2Client
client
)
{
super
(
client
);
}
@Override
public
AlertingList
get
(
String
id
)
{
H2Client
client
=
getClient
();
String
sql
=
SqlBuilder
.
buildSql
(
GET_SQL
,
AlertingListTable
.
TABLE
,
AlertingListTable
.
COLUMN_ID
);
Object
[]
params
=
new
Object
[]
{
id
};
try
(
ResultSet
rs
=
client
.
executeQuery
(
sql
,
params
))
{
if
(
rs
.
next
())
{
AlertingList
alertingList
=
new
AlertingList
(
id
);
alertingList
.
setLayer
(
rs
.
getInt
(
AlertingListTable
.
COLUMN_LAYER
));
alertingList
.
setLayerId
(
rs
.
getInt
(
AlertingListTable
.
COLUMN_LAYER_ID
));
alertingList
.
setFirstTimeBucket
(
rs
.
getLong
(
AlertingListTable
.
COLUMN_FIRST_TIME_BUCKET
));
alertingList
.
setLastTimeBucket
(
rs
.
getLong
(
AlertingListTable
.
COLUMN_LAST_TIME_BUCKET
));
alertingList
.
setExpected
(
rs
.
getInt
(
AlertingListTable
.
COLUMN_EXPECTED
));
alertingList
.
setActual
(
rs
.
getInt
(
AlertingListTable
.
COLUMN_ACTUAL
));
alertingList
.
setValid
(
rs
.
getBoolean
(
AlertingListTable
.
COLUMN_VALID
));
return
alertingList
;
}
}
catch
(
SQLException
|
H2ClientException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
null
;
}
@Override
public
H2SqlEntity
prepareBatchInsert
(
AlertingList
data
)
{
Map
<
String
,
Object
>
source
=
new
HashMap
<>();
H2SqlEntity
entity
=
new
H2SqlEntity
();
source
.
put
(
AlertingListTable
.
COLUMN_LAYER
,
data
.
getLayer
());
source
.
put
(
AlertingListTable
.
COLUMN_LAYER_ID
,
data
.
getLayerId
());
source
.
put
(
AlertingListTable
.
COLUMN_FIRST_TIME_BUCKET
,
data
.
getFirstTimeBucket
());
source
.
put
(
AlertingListTable
.
COLUMN_LAST_TIME_BUCKET
,
data
.
getLastTimeBucket
());
source
.
put
(
AlertingListTable
.
COLUMN_EXPECTED
,
data
.
getExpected
());
source
.
put
(
AlertingListTable
.
COLUMN_ACTUAL
,
data
.
getActual
());
source
.
put
(
AlertingListTable
.
COLUMN_VALID
,
data
.
getValid
());
String
sql
=
SqlBuilder
.
buildBatchInsertSql
(
AlertingListTable
.
TABLE
,
source
.
keySet
());
entity
.
setSql
(
sql
);
entity
.
setParams
(
source
.
values
().
toArray
(
new
Object
[
0
]));
return
entity
;
}
@Override
public
H2SqlEntity
prepareBatchUpdate
(
AlertingList
data
)
{
Map
<
String
,
Object
>
source
=
new
HashMap
<>();
H2SqlEntity
entity
=
new
H2SqlEntity
();
source
.
put
(
AlertingListTable
.
COLUMN_LAYER
,
data
.
getLayer
());
source
.
put
(
AlertingListTable
.
COLUMN_LAYER_ID
,
data
.
getLayerId
());
source
.
put
(
AlertingListTable
.
COLUMN_FIRST_TIME_BUCKET
,
data
.
getFirstTimeBucket
());
source
.
put
(
AlertingListTable
.
COLUMN_LAST_TIME_BUCKET
,
data
.
getLastTimeBucket
());
source
.
put
(
AlertingListTable
.
COLUMN_EXPECTED
,
data
.
getExpected
());
source
.
put
(
AlertingListTable
.
COLUMN_ACTUAL
,
data
.
getActual
());
source
.
put
(
AlertingListTable
.
COLUMN_VALID
,
data
.
getValid
());
String
sql
=
SqlBuilder
.
buildBatchUpdateSql
(
AlertingListTable
.
TABLE
,
source
.
keySet
(),
AlertingListTable
.
COLUMN_ID
);
entity
.
setSql
(
sql
);
List
<
Object
>
values
=
new
ArrayList
<>(
source
.
values
());
values
.
add
(
data
.
getId
());
entity
.
setParams
(
values
.
toArray
(
new
Object
[
0
]));
return
entity
;
}
@Override
public
void
deleteHistory
(
Long
startTimestamp
,
Long
endTimestamp
)
{
}
}
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/define/AlertingListH2TableDefine.java
0 → 100644
浏览文件 @
8e5408db
/*
* 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.storage.h2.define
;
import
org.skywalking.apm.collector.storage.h2.base.define.H2ColumnDefine
;
import
org.skywalking.apm.collector.storage.h2.base.define.H2TableDefine
;
import
org.skywalking.apm.collector.storage.table.alerting.AlertingListTable
;
import
org.skywalking.apm.collector.storage.table.application.ApplicationComponentTable
;
/**
* @author peng-yongsheng
*/
public
class
AlertingListH2TableDefine
extends
H2TableDefine
{
public
AlertingListH2TableDefine
()
{
super
(
AlertingListTable
.
TABLE
);
}
@Override
public
void
initialize
()
{
addColumn
(
new
H2ColumnDefine
(
ApplicationComponentTable
.
COLUMN_ID
,
H2ColumnDefine
.
Type
.
Varchar
.
name
()));
addColumn
(
new
H2ColumnDefine
(
AlertingListTable
.
COLUMN_LAYER
,
H2ColumnDefine
.
Type
.
Int
.
name
()));
addColumn
(
new
H2ColumnDefine
(
AlertingListTable
.
COLUMN_LAYER_ID
,
H2ColumnDefine
.
Type
.
Int
.
name
()));
addColumn
(
new
H2ColumnDefine
(
AlertingListTable
.
COLUMN_FIRST_TIME_BUCKET
,
H2ColumnDefine
.
Type
.
Bigint
.
name
()));
addColumn
(
new
H2ColumnDefine
(
AlertingListTable
.
COLUMN_LAST_TIME_BUCKET
,
H2ColumnDefine
.
Type
.
Bigint
.
name
()));
addColumn
(
new
H2ColumnDefine
(
AlertingListTable
.
COLUMN_EXPECTED
,
H2ColumnDefine
.
Type
.
Int
.
name
()));
addColumn
(
new
H2ColumnDefine
(
AlertingListTable
.
COLUMN_ACTUAL
,
H2ColumnDefine
.
Type
.
Int
.
name
()));
addColumn
(
new
H2ColumnDefine
(
AlertingListTable
.
COLUMN_VALID
,
H2ColumnDefine
.
Type
.
Boolean
.
name
()));
}
}
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/resources/META-INF/defines/storage.define
浏览文件 @
8e5408db
...
...
@@ -14,4 +14,5 @@ org.skywalking.apm.collector.storage.h2.define.SegmentCostH2TableDefine
org.skywalking.apm.collector.storage.h2.define.SegmentH2TableDefine
org.skywalking.apm.collector.storage.h2.define.ServiceEntryH2TableDefine
org.skywalking.apm.collector.storage.h2.define.ServiceMetricH2TableDefine
org.skywalking.apm.collector.storage.h2.define.ServiceReferenceMetricH2TableDefine
\ No newline at end of file
org.skywalking.apm.collector.storage.h2.define.ServiceReferenceMetricH2TableDefine
org.skywalking.apm.collector.storage.h2.define.AlertingListH2TableDefine
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录