Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
killuaz丶x
SkyWalking
提交
62ca37bc
S
SkyWalking
项目概览
killuaz丶x
/
SkyWalking
与 Fork 源项目一致
Fork自
apache / SkyWalking
通知
1
Star
0
Fork
0
代码
文件
提交
分支
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,发现更多精彩内容 >>
提交
62ca37bc
编写于
7月 20, 2018
作者:
wu-sheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactor codebases for v6, restore modulization back
上级
42072d85
变更
22
显示空白变更内容
内联
并排
Showing
22 changed file
with
274 addition
and
257 deletion
+274
-257
oap-server/server-cluster-plugin/cluster-standalone-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/standalone/ClusterModuleStandaloneProvider.java
...er/plugin/standalone/ClusterModuleStandaloneProvider.java
+12
-8
oap-server/server-cluster-plugin/cluster-standalone-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/standalone/StandaloneManager.java
...p/server/cluster/plugin/standalone/StandaloneManager.java
+52
-0
oap-server/server-cluster-plugin/cluster-standalone-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/standalone/StandaloneModuleRegister.java
...r/cluster/plugin/standalone/StandaloneModuleRegister.java
+0
-38
oap-server/server-cluster-plugin/cluster-standalone-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/standalone/StandaloneRegister.java
.../server/cluster/plugin/standalone/StandaloneRegister.java
+0
-32
oap-server/server-cluster-plugin/cluster-standalone-plugin/src/test/java/org/apache/skywalking/oap/server/cluster/plugin/standalone/StandaloneManagerTest.java
...rver/cluster/plugin/standalone/StandaloneManagerTest.java
+13
-17
oap-server/server-cluster-plugin/cluster-zookeeper-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/zookeeper/ClusterModuleZookeeperProvider.java
...ster/plugin/zookeeper/ClusterModuleZookeeperProvider.java
+34
-16
oap-server/server-cluster-plugin/cluster-zookeeper-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/zookeeper/SWInstanceSerializer.java
...server/cluster/plugin/zookeeper/SWInstanceSerializer.java
+5
-5
oap-server/server-cluster-plugin/cluster-zookeeper-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/zookeeper/ServiceCacheManager.java
.../server/cluster/plugin/zookeeper/ServiceCacheManager.java
+0
-44
oap-server/server-cluster-plugin/cluster-zookeeper-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/zookeeper/ZookeeperModuleQuery.java
...server/cluster/plugin/zookeeper/ZookeeperModuleQuery.java
+11
-10
oap-server/server-cluster-plugin/cluster-zookeeper-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/zookeeper/ZookeeperNodeRegister.java
...erver/cluster/plugin/zookeeper/ZookeeperNodeRegister.java
+60
-0
oap-server/server-cluster-plugin/cluster-zookeeper-plugin/src/test/java/org/apache/skywalking/oap/server/cluster/plugin/zookeeper/ClusterModuleZookeeperProviderTestCase.java
...gin/zookeeper/ClusterModuleZookeeperProviderTestCase.java
+28
-14
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/CoreModuleProvider.java
...apache/skywalking/oap/server/core/CoreModuleProvider.java
+22
-16
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cluster/ClusterModule.java
...che/skywalking/oap/server/core/cluster/ClusterModule.java
+1
-1
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cluster/ClusterNodesQuery.java
...skywalking/oap/server/core/cluster/ClusterNodesQuery.java
+2
-2
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cluster/ClusterRegister.java
...e/skywalking/oap/server/core/cluster/ClusterRegister.java
+2
-3
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cluster/RemoteInstance.java
...he/skywalking/oap/server/core/cluster/RemoteInstance.java
+1
-10
oap-server/server-core/src/main/resources/META-INF/services/org.apache.skywalking.oap.server.library.module.ModuleDefine
....apache.skywalking.oap.server.library.module.ModuleDefine
+21
-0
oap-server/server-library/library-module/src/main/java/org/apache/skywalking/oap/server/library/module/BootstrapFlow.java
...e/skywalking/oap/server/library/module/BootstrapFlow.java
+1
-1
oap-server/server-library/library-module/src/main/java/org/apache/skywalking/oap/server/library/module/ModuleDefine.java
...he/skywalking/oap/server/library/module/ModuleDefine.java
+1
-1
oap-server/server-library/library-module/src/main/java/org/apache/skywalking/oap/server/library/module/ModuleProvider.java
.../skywalking/oap/server/library/module/ModuleProvider.java
+2
-2
oap-server/server-starter/src/main/java/org/apache/skywalking/oap/server/starter/config/ApplicationConfigLoader.java
...ng/oap/server/starter/config/ApplicationConfigLoader.java
+0
-26
oap-server/server-starter/src/main/resources/application.yml
oap-server/server-starter/src/main/resources/application.yml
+6
-11
未找到文件。
oap-server/server-cluster-plugin/cluster-standalone-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/standalone/ClusterModuleStandaloneProvider.java
浏览文件 @
62ca37bc
...
@@ -18,9 +18,15 @@
...
@@ -18,9 +18,15 @@
package
org.apache.skywalking.oap.server.cluster.plugin.standalone
;
package
org.apache.skywalking.oap.server.cluster.plugin.standalone
;
import
org.apache.skywalking.oap.server.core.cluster.*
;
import
org.apache.skywalking.oap.server.core.cluster.ClusterModule
;
import
org.apache.skywalking.oap.server.library.module.*
;
import
org.apache.skywalking.oap.server.core.cluster.ClusterNodesQuery
;
import
org.slf4j.*
;
import
org.apache.skywalking.oap.server.core.cluster.ClusterRegister
;
import
org.apache.skywalking.oap.server.library.module.ModuleConfig
;
import
org.apache.skywalking.oap.server.library.module.ModuleProvider
;
import
org.apache.skywalking.oap.server.library.module.ModuleStartException
;
import
org.apache.skywalking.oap.server.library.module.ServiceNotProvidedException
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
/**
* @author peng-yongsheng
* @author peng-yongsheng
...
@@ -29,11 +35,8 @@ public class ClusterModuleStandaloneProvider extends ModuleProvider {
...
@@ -29,11 +35,8 @@ public class ClusterModuleStandaloneProvider extends ModuleProvider {
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ClusterModuleStandaloneProvider
.
class
);
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ClusterModuleStandaloneProvider
.
class
);
private
final
StandaloneServiceManager
serviceManager
;
public
ClusterModuleStandaloneProvider
()
{
public
ClusterModuleStandaloneProvider
()
{
super
();
super
();
this
.
serviceManager
=
new
StandaloneServiceManager
();
}
}
@Override
public
String
name
()
{
@Override
public
String
name
()
{
...
@@ -49,8 +52,9 @@ public class ClusterModuleStandaloneProvider extends ModuleProvider {
...
@@ -49,8 +52,9 @@ public class ClusterModuleStandaloneProvider extends ModuleProvider {
}
}
@Override
public
void
prepare
()
throws
ServiceNotProvidedException
{
@Override
public
void
prepare
()
throws
ServiceNotProvidedException
{
this
.
registerServiceImplementation
(
ModuleRegister
.
class
,
new
StandaloneModuleRegister
(
serviceManager
));
StandaloneManager
standaloneManager
=
new
StandaloneManager
();
this
.
registerServiceImplementation
(
ModuleQuery
.
class
,
new
StandaloneModuleQuery
(
serviceManager
));
this
.
registerServiceImplementation
(
ClusterRegister
.
class
,
standaloneManager
);
this
.
registerServiceImplementation
(
ClusterNodesQuery
.
class
,
standaloneManager
);
}
}
@Override
public
void
start
()
throws
ModuleStartException
{
@Override
public
void
start
()
throws
ModuleStartException
{
...
...
oap-server/server-cluster-plugin/cluster-standalone-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/standalone/Standalone
Service
Manager.java
→
oap-server/server-cluster-plugin/cluster-standalone-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/standalone/StandaloneManager.java
浏览文件 @
62ca37bc
...
@@ -18,25 +18,35 @@
...
@@ -18,25 +18,35 @@
package
org.apache.skywalking.oap.server.cluster.plugin.standalone
;
package
org.apache.skywalking.oap.server.cluster.plugin.standalone
;
import
java.util.*
;
import
org.apache.skywalking.oap.server.core.cluster.ClusterNodesQuery
;
import
org.apache.skywalking.oap.server.core.cluster.InstanceDetails
;
import
org.apache.skywalking.oap.server.core.cluster.ClusterRegister
;
import
org.apache.skywalking.oap.server.core.cluster.RemoteInstance
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
/**
* @author peng-yongsheng
* A cluster manager simulator. Work in memory only.
* Also return the current instance.
*
* @author peng-yongsheng, Wu Sheng
*/
*/
public
class
Standalone
ServiceManag
er
{
public
class
Standalone
Manager
implements
ClusterNodesQuery
,
ClusterRegist
er
{
private
final
Map
<
String
,
InstanceDetails
>
instanceDetailsMap
;
private
volatile
RemoteInstance
remoteInstance
;
public
StandaloneServiceManager
()
{
this
.
instanceDetailsMap
=
new
HashMap
<>();
}
public
void
put
(
String
moduleName
,
String
providerName
,
InstanceDetails
instanceDetails
)
{
@Override
public
void
registerRemote
(
RemoteInstance
remoteInstance
)
{
instanceDetailsMap
.
put
(
moduleName
+
"/"
+
providerName
,
instanceDetails
)
;
this
.
remoteInstance
=
remoteInstance
;
}
}
public
InstanceDetails
get
(
String
moduleName
,
String
providerName
)
{
@Override
return
instanceDetailsMap
.
get
(
moduleName
+
"/"
+
providerName
);
public
List
<
RemoteInstance
>
queryRemoteNodes
()
{
if
(
remoteInstance
==
null
){
return
new
ArrayList
(
0
);
}
ArrayList
remoteList
=
new
ArrayList
(
1
);
remoteList
.
add
(
remoteInstance
);
return
remoteList
;
}
}
}
}
oap-server/server-cluster-plugin/cluster-standalone-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/standalone/StandaloneModuleRegister.java
已删除
100644 → 0
浏览文件 @
42072d85
/*
* 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.oap.server.cluster.plugin.standalone
;
import
org.apache.skywalking.oap.server.core.cluster.*
;
/**
* @author peng-yongsheng
*/
public
class
StandaloneModuleRegister
implements
ModuleRegister
{
private
final
StandaloneServiceManager
serviceManager
;
StandaloneModuleRegister
(
StandaloneServiceManager
serviceManager
)
{
this
.
serviceManager
=
serviceManager
;
}
@Override
public
void
register
(
String
moduleName
,
String
providerName
,
InstanceDetails
instanceDetails
)
{
serviceManager
.
put
(
moduleName
,
providerName
,
instanceDetails
);
}
}
oap-server/server-cluster-plugin/cluster-standalone-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/standalone/StandaloneRegister.java
已删除
100644 → 0
浏览文件 @
42072d85
/*
* 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.oap.server.cluster.plugin.standalone
;
import
org.apache.skywalking.oap.server.core.cluster.*
;
/**
* @author peng-yongsheng
*/
public
class
StandaloneRegister
implements
ModuleRegister
{
@Override
public
void
register
(
String
moduleName
,
String
providerName
,
InstanceDetails
instanceDetails
)
throws
ServiceRegisterException
{
}
}
oap-server/server-cluster-plugin/cluster-standalone-plugin/src/
main/java/org/apache/skywalking/oap/server/cluster/plugin/standalone/StandaloneModuleQuery
.java
→
oap-server/server-cluster-plugin/cluster-standalone-plugin/src/
test/java/org/apache/skywalking/oap/server/cluster/plugin/standalone/StandaloneManagerTest
.java
浏览文件 @
62ca37bc
...
@@ -18,24 +18,20 @@
...
@@ -18,24 +18,20 @@
package
org.apache.skywalking.oap.server.cluster.plugin.standalone
;
package
org.apache.skywalking.oap.server.cluster.plugin.standalone
;
import
java.util.*
;
import
org.apache.skywalking.oap.server.core.cluster.RemoteInstance
;
import
org.apache.skywalking.oap.server.core.cluster.*
;
import
org.junit.Assert
;
import
org.junit.Test
;
/**
public
class
StandaloneManagerTest
{
* @author peng-yongsheng
@Test
*/
public
void
test
(){
public
class
StandaloneModuleQuery
implements
ModuleQuery
{
StandaloneManager
standaloneManager
=
new
StandaloneManager
();
RemoteInstance
remote1
=
new
RemoteInstance
();
private
final
StandaloneServiceManager
serviceManager
;
RemoteInstance
remote2
=
new
RemoteInstance
();
StandaloneModuleQuery
(
StandaloneServiceManager
serviceManager
)
{
this
.
serviceManager
=
serviceManager
;
}
@Override
standaloneManager
.
registerRemote
(
remote1
);
public
List
<
InstanceDetails
>
query
(
String
moduleName
,
String
providerName
)
{
Assert
.
assertEquals
(
remote1
,
standaloneManager
.
queryRemoteNodes
().
get
(
0
));
List
<
InstanceDetails
>
instanceDetails
=
new
ArrayList
<>(
1
);
standaloneManager
.
registerRemote
(
remote2
);
instanceDetails
.
add
(
serviceManager
.
get
(
moduleName
,
providerName
));
Assert
.
assertEquals
(
remote2
,
standaloneManager
.
queryRemoteNodes
().
get
(
0
));
return
instanceDetails
;
}
}
}
}
oap-server/server-cluster-plugin/cluster-zookeeper-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/zookeeper/ClusterModuleZookeeperProvider.java
浏览文件 @
62ca37bc
...
@@ -19,15 +19,27 @@
...
@@ -19,15 +19,27 @@
package
org.apache.skywalking.oap.server.cluster.plugin.zookeeper
;
package
org.apache.skywalking.oap.server.cluster.plugin.zookeeper
;
import
org.apache.curator.RetryPolicy
;
import
org.apache.curator.RetryPolicy
;
import
org.apache.curator.framework.*
;
import
org.apache.curator.framework.CuratorFramework
;
import
org.apache.curator.framework.CuratorFrameworkFactory
;
import
org.apache.curator.retry.ExponentialBackoffRetry
;
import
org.apache.curator.retry.ExponentialBackoffRetry
;
import
org.apache.curator.x.discovery.*
;
import
org.apache.curator.x.discovery.ServiceCache
;
import
org.apache.skywalking.oap.server.core.cluster.*
;
import
org.apache.curator.x.discovery.ServiceDiscovery
;
import
org.apache.skywalking.oap.server.library.module.*
;
import
org.apache.curator.x.discovery.ServiceDiscoveryBuilder
;
import
org.slf4j.*
;
import
org.apache.skywalking.oap.server.core.cluster.ClusterModule
;
import
org.apache.skywalking.oap.server.core.cluster.ClusterNodesQuery
;
import
org.apache.skywalking.oap.server.core.cluster.ClusterRegister
;
import
org.apache.skywalking.oap.server.core.cluster.RemoteInstance
;
import
org.apache.skywalking.oap.server.library.module.ModuleConfig
;
import
org.apache.skywalking.oap.server.library.module.ModuleProvider
;
import
org.apache.skywalking.oap.server.library.module.ModuleStartException
;
import
org.apache.skywalking.oap.server.library.module.ServiceNotProvidedException
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
/**
* @author peng-yongsheng
* Use Zookeeper to manage all instances in SkyWalking cluster.
*
* @author peng-yongsheng, Wu Sheng
*/
*/
public
class
ClusterModuleZookeeperProvider
extends
ModuleProvider
{
public
class
ClusterModuleZookeeperProvider
extends
ModuleProvider
{
...
@@ -35,15 +47,13 @@ public class ClusterModuleZookeeperProvider extends ModuleProvider {
...
@@ -35,15 +47,13 @@ public class ClusterModuleZookeeperProvider extends ModuleProvider {
private
static
final
String
BASE_PATH
=
"/skywalking"
;
private
static
final
String
BASE_PATH
=
"/skywalking"
;
private
final
ServiceCacheManager
cacheManager
;
private
final
ClusterModuleZookeeperConfig
config
;
private
final
ClusterModuleZookeeperConfig
config
;
private
CuratorFramework
client
;
private
CuratorFramework
client
;
private
ServiceDiscovery
<
InstanceDetails
>
serviceDiscovery
;
private
ServiceDiscovery
<
RemoteInstance
>
serviceDiscovery
;
public
ClusterModuleZookeeperProvider
()
{
public
ClusterModuleZookeeperProvider
()
{
super
();
super
();
this
.
config
=
new
ClusterModuleZookeeperConfig
();
this
.
config
=
new
ClusterModuleZookeeperConfig
();
this
.
cacheManager
=
new
ServiceCacheManager
();
}
}
@Override
public
String
name
()
{
@Override
public
String
name
()
{
...
@@ -58,27 +68,35 @@ public class ClusterModuleZookeeperProvider extends ModuleProvider {
...
@@ -58,27 +68,35 @@ public class ClusterModuleZookeeperProvider extends ModuleProvider {
return
config
;
return
config
;
}
}
@Override
public
void
prepare
()
throws
ServiceNotProvidedException
{
@Override
public
void
prepare
()
throws
ServiceNotProvidedException
,
ModuleStartException
{
RetryPolicy
retryPolicy
=
new
ExponentialBackoffRetry
(
config
.
getBaseSleepTimeMs
(),
config
.
getMaxRetries
());
RetryPolicy
retryPolicy
=
new
ExponentialBackoffRetry
(
config
.
getBaseSleepTimeMs
(),
config
.
getMaxRetries
());
client
=
CuratorFrameworkFactory
.
newClient
(
config
.
getHostPort
(),
retryPolicy
);
client
=
CuratorFrameworkFactory
.
newClient
(
config
.
getHostPort
(),
retryPolicy
);
serviceDiscovery
=
ServiceDiscoveryBuilder
.
builder
(
InstanceDetails
.
class
).
client
(
client
)
serviceDiscovery
=
ServiceDiscoveryBuilder
.
builder
(
RemoteInstance
.
class
).
client
(
client
)
.
basePath
(
BASE_PATH
)
.
basePath
(
BASE_PATH
)
.
watchInstances
(
true
)
.
watchInstances
(
true
)
.
serializer
(
new
SWInstanceSerializer
()).
build
();
.
serializer
(
new
SWInstanceSerializer
()).
build
();
this
.
registerServiceImplementation
(
ModuleRegister
.
class
,
new
ZookeeperModuleRegister
(
serviceDiscovery
,
cacheManager
));
String
remoteName
=
"remote"
;
this
.
registerServiceImplementation
(
ModuleQuery
.
class
,
new
ZookeeperModuleQuery
(
cacheManager
));
ServiceCache
<
RemoteInstance
>
serviceCache
=
serviceDiscovery
.
serviceCacheBuilder
()
}
.
name
(
remoteName
)
.
build
();
@Override
public
void
start
()
throws
ModuleStartException
{
try
{
try
{
client
.
start
();
client
.
start
();
client
.
blockUntilConnected
();
client
.
blockUntilConnected
();
serviceDiscovery
.
start
();
serviceDiscovery
.
start
();
serviceCache
.
start
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
throw
new
ModuleStartException
(
e
.
getMessage
(),
e
);
throw
new
ModuleStartException
(
e
.
getMessage
(),
e
);
}
}
this
.
registerServiceImplementation
(
ClusterRegister
.
class
,
new
ZookeeperNodeRegister
(
serviceDiscovery
,
remoteName
));
this
.
registerServiceImplementation
(
ClusterNodesQuery
.
class
,
new
ZookeeperModuleQuery
(
serviceCache
));
}
@Override
public
void
start
()
{
}
}
@Override
public
void
notifyAfterCompleted
()
{
@Override
public
void
notifyAfterCompleted
()
{
...
...
oap-server/server-cluster-plugin/cluster-zookeeper-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/zookeeper/SWInstanceSerializer.java
浏览文件 @
62ca37bc
...
@@ -22,21 +22,21 @@ import com.google.gson.Gson;
...
@@ -22,21 +22,21 @@ import com.google.gson.Gson;
import
com.google.gson.reflect.TypeToken
;
import
com.google.gson.reflect.TypeToken
;
import
org.apache.curator.x.discovery.ServiceInstance
;
import
org.apache.curator.x.discovery.ServiceInstance
;
import
org.apache.curator.x.discovery.details.InstanceSerializer
;
import
org.apache.curator.x.discovery.details.InstanceSerializer
;
import
org.apache.skywalking.oap.server.core.cluster.
InstanceDetails
;
import
org.apache.skywalking.oap.server.core.cluster.
RemoteInstance
;
/**
/**
* @author peng-yongsheng
* @author peng-yongsheng
*/
*/
public
class
SWInstanceSerializer
implements
InstanceSerializer
<
InstanceDetails
>
{
public
class
SWInstanceSerializer
implements
InstanceSerializer
<
RemoteInstance
>
{
private
final
Gson
gson
=
new
Gson
();
private
final
Gson
gson
=
new
Gson
();
@Override
public
byte
[]
serialize
(
ServiceInstance
<
InstanceDetails
>
instance
)
throws
Exception
{
@Override
public
byte
[]
serialize
(
ServiceInstance
<
RemoteInstance
>
instance
)
throws
Exception
{
return
gson
.
toJson
(
instance
).
getBytes
();
return
gson
.
toJson
(
instance
).
getBytes
();
}
}
@Override
public
ServiceInstance
<
InstanceDetails
>
deserialize
(
byte
[]
bytes
)
throws
Exception
{
@Override
public
ServiceInstance
<
RemoteInstance
>
deserialize
(
byte
[]
bytes
)
throws
Exception
{
return
gson
.
fromJson
(
new
String
(
bytes
),
new
TypeToken
<
ServiceInstance
<
InstanceDetails
>>()
{
return
gson
.
fromJson
(
new
String
(
bytes
),
new
TypeToken
<
ServiceInstance
<
RemoteInstance
>>()
{
}.
getType
());
}.
getType
());
}
}
}
}
oap-server/server-cluster-plugin/cluster-zookeeper-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/zookeeper/ServiceCacheManager.java
已删除
100644 → 0
浏览文件 @
42072d85
/*
* 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.oap.server.cluster.plugin.zookeeper
;
import
java.util.*
;
import
java.util.concurrent.ConcurrentHashMap
;
import
org.apache.curator.x.discovery.ServiceCache
;
import
org.apache.skywalking.oap.server.core.cluster.InstanceDetails
;
/**
* @author peng-yongsheng
*/
public
class
ServiceCacheManager
{
private
final
Map
<
String
,
ServiceCache
<
InstanceDetails
>>
serviceCacheMap
;
public
ServiceCacheManager
()
{
this
.
serviceCacheMap
=
new
ConcurrentHashMap
<>();
}
public
void
put
(
String
name
,
ServiceCache
<
InstanceDetails
>
cache
)
{
serviceCacheMap
.
put
(
name
,
cache
);
}
public
ServiceCache
<
InstanceDetails
>
get
(
String
name
)
{
return
serviceCacheMap
.
get
(
name
);
}
}
oap-server/server-cluster-plugin/cluster-zookeeper-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/zookeeper/ZookeeperModuleQuery.java
浏览文件 @
62ca37bc
...
@@ -19,26 +19,27 @@
...
@@ -19,26 +19,27 @@
package
org.apache.skywalking.oap.server.cluster.plugin.zookeeper
;
package
org.apache.skywalking.oap.server.cluster.plugin.zookeeper
;
import
java.util.*
;
import
java.util.*
;
import
org.apache.curator.x.discovery.ServiceCache
;
import
org.apache.curator.x.discovery.ServiceInstance
;
import
org.apache.curator.x.discovery.ServiceInstance
;
import
org.apache.skywalking.oap.server.core.cluster.*
;
import
org.apache.skywalking.oap.server.core.cluster.*
;
/**
/**
* @author peng-yongsheng
* @author peng-yongsheng
, Wu Sheng
*/
*/
public
class
ZookeeperModuleQuery
implements
Module
Query
{
public
class
ZookeeperModuleQuery
implements
ClusterNodes
Query
{
private
final
ServiceCache
Manager
cacheManager
;
private
final
ServiceCache
<
RemoteInstance
>
serviceCache
;
ZookeeperModuleQuery
(
ServiceCache
Manager
cacheManager
)
{
ZookeeperModuleQuery
(
ServiceCache
<
RemoteInstance
>
serviceCache
)
{
this
.
cacheManager
=
cacheManager
;
this
.
serviceCache
=
serviceCache
;
}
}
@Override
@Override
public
List
<
InstanceDetails
>
query
(
String
moduleName
,
String
providerName
)
throws
ServiceRegisterException
{
public
List
<
RemoteInstance
>
queryRemoteNodes
(
)
throws
ServiceRegisterException
{
List
<
ServiceInstance
<
InstanceDetails
>>
serviceInstances
=
cacheManager
.
get
(
NodeNameBuilder
.
build
(
moduleName
,
providerName
))
.
getInstances
();
List
<
ServiceInstance
<
RemoteInstance
>>
serviceInstances
=
serviceCache
.
getInstances
();
List
<
InstanceDetails
>
i
nstanceDetails
=
new
ArrayList
<>(
serviceInstances
.
size
());
List
<
RemoteInstance
>
remoteI
nstanceDetails
=
new
ArrayList
<>(
serviceInstances
.
size
());
serviceInstances
.
forEach
(
serviceInstance
->
i
nstanceDetails
.
add
(
serviceInstance
.
getPayload
()));
serviceInstances
.
forEach
(
serviceInstance
->
remoteI
nstanceDetails
.
add
(
serviceInstance
.
getPayload
()));
return
i
nstanceDetails
;
return
remoteI
nstanceDetails
;
}
}
}
}
oap-server/server-cluster-plugin/cluster-zookeeper-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/zookeeper/Zookeeper
Modul
eRegister.java
→
oap-server/server-cluster-plugin/cluster-zookeeper-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/zookeeper/Zookeeper
Nod
eRegister.java
浏览文件 @
62ca37bc
...
@@ -19,47 +19,41 @@
...
@@ -19,47 +19,41 @@
package
org.apache.skywalking.oap.server.cluster.plugin.zookeeper
;
package
org.apache.skywalking.oap.server.cluster.plugin.zookeeper
;
import
java.util.UUID
;
import
java.util.UUID
;
import
org.apache.curator.x.discovery.*
;
import
org.apache.curator.x.discovery.ServiceDiscovery
;
import
org.apache.skywalking.oap.server.core.cluster.*
;
import
org.apache.curator.x.discovery.ServiceInstance
;
import
org.apache.skywalking.oap.server.core.cluster.ClusterRegister
;
import
org.apache.skywalking.oap.server.core.cluster.RemoteInstance
;
import
org.apache.skywalking.oap.server.core.cluster.ServiceRegisterException
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
/**
* @author peng-yongsheng
* @author peng-yongsheng
*/
*/
public
class
ZookeeperModuleRegister
implements
ModuleRegister
{
public
class
ZookeeperNodeRegister
implements
ClusterRegister
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ZookeeperNodeRegister
.
class
);
private
final
ServiceDiscovery
<
InstanceDetails
>
serviceDiscovery
;
private
final
ServiceDiscovery
<
RemoteInstance
>
serviceDiscovery
;
private
final
S
erviceCacheManager
cacheManager
;
private
final
S
tring
nodeName
;
ZookeeperModuleRegister
(
ServiceDiscovery
<
InstanceDetails
>
serviceDiscovery
,
ZookeeperNodeRegister
(
ServiceDiscovery
<
RemoteInstance
>
serviceDiscovery
,
String
nodeName
)
{
ServiceCacheManager
cacheManager
)
{
this
.
serviceDiscovery
=
serviceDiscovery
;
this
.
serviceDiscovery
=
serviceDiscovery
;
this
.
cacheManager
=
cacheManager
;
this
.
nodeName
=
nodeName
;
}
}
@Override
public
synchronized
void
register
(
String
moduleName
,
String
providerName
,
@Override
public
synchronized
void
registerRemote
(
RemoteInstance
remoteInstance
)
throws
ServiceRegisterException
{
InstanceDetails
instanceDetails
)
throws
ServiceRegisterException
{
try
{
try
{
String
name
=
NodeNameBuilder
.
build
(
moduleName
,
providerName
);
ServiceInstance
<
RemoteInstance
>
thisInstance
=
ServiceInstance
.<
RemoteInstance
>
builder
()
.
name
(
nodeName
)
ServiceInstance
<
InstanceDetails
>
thisInstance
=
ServiceInstance
.<
InstanceDetails
>
builder
()
.
name
(
NodeNameBuilder
.
build
(
moduleName
,
providerName
))
.
id
(
UUID
.
randomUUID
().
toString
())
.
id
(
UUID
.
randomUUID
().
toString
())
.
address
(
instanceDetails
.
getHost
())
.
address
(
remoteInstance
.
getHost
())
.
port
(
instanceDetails
.
getPort
())
.
port
(
remoteInstance
.
getPort
())
// .uriSpec(new UriSpec(StringUtils.isEmpty(instanceDetails.getContextPath()) ? StringUtils.EMPTY_STRING : instanceDetails.getContextPath()))
.
payload
(
remoteInstance
)
.
payload
(
instanceDetails
)
.
build
();
.
build
();
serviceDiscovery
.
registerService
(
thisInstance
);
serviceDiscovery
.
registerService
(
thisInstance
);
ServiceCache
<
InstanceDetails
>
serviceCache
=
serviceDiscovery
.
serviceCacheBuilder
()
.
name
(
name
)
.
build
();
serviceCache
.
start
();
cacheManager
.
put
(
name
,
serviceCache
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
(
);
logger
.
error
(
e
.
getMessage
(),
e
);
throw
new
ServiceRegisterException
(
e
.
getMessage
());
throw
new
ServiceRegisterException
(
e
.
getMessage
());
}
}
}
}
...
...
oap-server/server-cluster-plugin/cluster-zookeeper-plugin/src/test/java/org/apache/skywalking/oap/server/cluster/plugin/zookeeper/ClusterModuleZookeeperProviderTestCase.java
浏览文件 @
62ca37bc
...
@@ -21,9 +21,16 @@ package org.apache.skywalking.oap.server.cluster.plugin.zookeeper;
...
@@ -21,9 +21,16 @@ package org.apache.skywalking.oap.server.cluster.plugin.zookeeper;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.List
;
import
org.apache.curator.test.TestingServer
;
import
org.apache.curator.test.TestingServer
;
import
org.apache.skywalking.oap.server.core.cluster.*
;
import
org.apache.skywalking.oap.server.core.cluster.ClusterNodesQuery
;
import
org.apache.skywalking.oap.server.library.module.*
;
import
org.apache.skywalking.oap.server.core.cluster.ClusterRegister
;
import
org.junit.*
;
import
org.apache.skywalking.oap.server.core.cluster.RemoteInstance
;
import
org.apache.skywalking.oap.server.core.cluster.ServiceRegisterException
;
import
org.apache.skywalking.oap.server.library.module.ModuleStartException
;
import
org.apache.skywalking.oap.server.library.module.ServiceNotProvidedException
;
import
org.junit.After
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Test
;
/**
/**
* @author peng-yongsheng
* @author peng-yongsheng
...
@@ -39,7 +46,7 @@ public class ClusterModuleZookeeperProviderTestCase {
...
@@ -39,7 +46,7 @@ public class ClusterModuleZookeeperProviderTestCase {
}
}
@Test
@Test
public
void
testStart
()
throws
ServiceNotProvidedException
,
ModuleStartException
,
ServiceRegisterException
{
public
void
testStart
()
throws
ServiceNotProvidedException
,
ModuleStartException
,
ServiceRegisterException
,
InterruptedException
{
ClusterModuleZookeeperProvider
provider
=
new
ClusterModuleZookeeperProvider
();
ClusterModuleZookeeperProvider
provider
=
new
ClusterModuleZookeeperProvider
();
ClusterModuleZookeeperConfig
moduleConfig
=
(
ClusterModuleZookeeperConfig
)
provider
.
createConfigBeanIfAbsent
();
ClusterModuleZookeeperConfig
moduleConfig
=
(
ClusterModuleZookeeperConfig
)
provider
.
createConfigBeanIfAbsent
();
moduleConfig
.
setHostPort
(
server
.
getConnectString
());
moduleConfig
.
setHostPort
(
server
.
getConnectString
());
...
@@ -49,21 +56,28 @@ public class ClusterModuleZookeeperProviderTestCase {
...
@@ -49,21 +56,28 @@ public class ClusterModuleZookeeperProviderTestCase {
provider
.
prepare
();
provider
.
prepare
();
provider
.
start
();
provider
.
start
();
ModuleRegister
moduleRegister
=
provider
.
getService
(
Module
Register
.
class
);
ClusterRegister
moduleRegister
=
provider
.
getService
(
Cluster
Register
.
class
);
ModuleQuery
moduleQuery
=
provider
.
getService
(
Module
Query
.
class
);
ClusterNodesQuery
clusterNodesQuery
=
provider
.
getService
(
ClusterNodes
Query
.
class
);
InstanceDetails
instanceDetails
=
new
InstanceDetails
();
RemoteInstance
remoteInstance
=
new
RemoteInstance
();
instanceDetails
.
setHost
(
"ProviderAHost"
);
remoteInstance
.
setHost
(
"ProviderAHost"
);
instanceDetails
.
setPort
(
1000
);
remoteInstance
.
setPort
(
1000
);
moduleRegister
.
register
(
"ModuleA"
,
"ProviderA"
,
instanceDetails
);
moduleRegister
.
register
Remote
(
remoteInstance
);
List
<
InstanceDetails
>
detailsList
=
moduleQuery
.
query
(
"ModuleA"
,
"ProviderA"
);
for
(
int
i
=
0
;
i
<
20
;
i
++)
{
List
<
RemoteInstance
>
detailsList
=
clusterNodesQuery
.
queryRemoteNodes
();
if
(
detailsList
.
size
()
==
0
){
Thread
.
sleep
(
500
);
continue
;
}
Assert
.
assertEquals
(
1
,
detailsList
.
size
());
Assert
.
assertEquals
(
1
,
detailsList
.
size
());
Assert
.
assertEquals
(
"ProviderAHost"
,
detailsList
.
get
(
0
).
getHost
());
Assert
.
assertEquals
(
"ProviderAHost"
,
detailsList
.
get
(
0
).
getHost
());
Assert
.
assertEquals
(
1000
,
detailsList
.
get
(
0
).
getPort
());
Assert
.
assertEquals
(
1000
,
detailsList
.
get
(
0
).
getPort
());
}
}
}
@After
@After
public
void
after
()
throws
IOException
{
public
void
after
()
throws
IOException
{
server
.
stop
();
server
.
stop
();
...
...
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/CoreModuleProvider.java
浏览文件 @
62ca37bc
...
@@ -18,14 +18,24 @@
...
@@ -18,14 +18,24 @@
package
org.apache.skywalking.oap.server.core
;
package
org.apache.skywalking.oap.server.core
;
import
org.apache.skywalking.oap.server.core.cluster.*
;
import
org.apache.skywalking.oap.server.core.cluster.ClusterModule
;
import
org.apache.skywalking.oap.server.core.receiver.*
;
import
org.apache.skywalking.oap.server.core.cluster.ClusterRegister
;
import
org.apache.skywalking.oap.server.core.server.*
;
import
org.apache.skywalking.oap.server.core.cluster.RemoteInstance
;
import
org.apache.skywalking.oap.server.library.module.*
;
import
org.apache.skywalking.oap.server.core.receiver.SourceReceiver
;
import
org.apache.skywalking.oap.server.core.receiver.SourceReceiverImpl
;
import
org.apache.skywalking.oap.server.core.server.GRPCHandlerRegister
;
import
org.apache.skywalking.oap.server.core.server.GRPCHandlerRegisterImpl
;
import
org.apache.skywalking.oap.server.core.server.JettyHandlerRegister
;
import
org.apache.skywalking.oap.server.core.server.JettyHandlerRegisterImpl
;
import
org.apache.skywalking.oap.server.library.module.ModuleConfig
;
import
org.apache.skywalking.oap.server.library.module.ModuleProvider
;
import
org.apache.skywalking.oap.server.library.module.ModuleStartException
;
import
org.apache.skywalking.oap.server.library.module.ServiceNotProvidedException
;
import
org.apache.skywalking.oap.server.library.server.ServerException
;
import
org.apache.skywalking.oap.server.library.server.ServerException
;
import
org.apache.skywalking.oap.server.library.server.grpc.GRPCServer
;
import
org.apache.skywalking.oap.server.library.server.grpc.GRPCServer
;
import
org.apache.skywalking.oap.server.library.server.jetty.JettyServer
;
import
org.apache.skywalking.oap.server.library.server.jetty.JettyServer
;
import
org.slf4j.*
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
/**
* @author peng-yongsheng
* @author peng-yongsheng
...
@@ -68,26 +78,22 @@ public class CoreModuleProvider extends ModuleProvider {
...
@@ -68,26 +78,22 @@ public class CoreModuleProvider extends ModuleProvider {
this
.
registerServiceImplementation
(
SourceReceiver
.
class
,
new
SourceReceiverImpl
());
this
.
registerServiceImplementation
(
SourceReceiver
.
class
,
new
SourceReceiverImpl
());
}
}
@Override
public
void
start
()
throws
ModuleStartException
{
@Override
public
void
start
()
{
}
@Override
public
void
notifyAfterCompleted
()
throws
ModuleStartException
{
try
{
try
{
grpcServer
.
start
();
grpcServer
.
start
();
jettyServer
.
start
();
jettyServer
.
start
();
}
catch
(
ServerException
e
)
{
}
catch
(
ServerException
e
)
{
throw
new
ModuleStartException
(
e
.
getMessage
(),
e
);
throw
new
ModuleStartException
(
e
.
getMessage
(),
e
);
}
}
}
@Override
public
void
notifyAfterCompleted
()
{
RemoteInstance
gRPCServerInstance
=
new
RemoteInstance
();
InstanceDetails
gRPCServerInstance
=
new
InstanceDetails
();
gRPCServerInstance
.
setHost
(
moduleConfig
.
getGRPCHost
());
gRPCServerInstance
.
setHost
(
moduleConfig
.
getGRPCHost
());
gRPCServerInstance
.
setPort
(
moduleConfig
.
getGRPCPort
());
gRPCServerInstance
.
setPort
(
moduleConfig
.
getGRPCPort
());
this
.
getManager
().
find
(
ClusterModule
.
NAME
).
getService
(
ModuleRegister
.
class
).
register
(
CoreModule
.
NAME
,
"gRPC"
,
gRPCServerInstance
);
this
.
getManager
().
find
(
ClusterModule
.
NAME
).
getService
(
ClusterRegister
.
class
).
registerRemote
(
gRPCServerInstance
);
InstanceDetails
restServerInstance
=
new
InstanceDetails
();
restServerInstance
.
setHost
(
moduleConfig
.
getRestHost
());
restServerInstance
.
setPort
(
moduleConfig
.
getRestPort
());
restServerInstance
.
setContextPath
(
moduleConfig
.
getRestContextPath
());
this
.
getManager
().
find
(
ClusterModule
.
NAME
).
getService
(
ModuleRegister
.
class
).
register
(
CoreModule
.
NAME
,
"rest"
,
restServerInstance
);
}
}
@Override
@Override
...
...
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cluster/ClusterModule.java
浏览文件 @
62ca37bc
...
@@ -32,6 +32,6 @@ public class ClusterModule extends ModuleDefine {
...
@@ -32,6 +32,6 @@ public class ClusterModule extends ModuleDefine {
}
}
@Override
public
Class
[]
services
()
{
@Override
public
Class
[]
services
()
{
return
new
Class
[]
{
ModuleRegister
.
class
,
Module
Query
.
class
};
return
new
Class
[]
{
ClusterRegister
.
class
,
ClusterNodes
Query
.
class
};
}
}
}
}
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cluster/
Module
Query.java
→
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cluster/
ClusterNodes
Query.java
浏览文件 @
62ca37bc
...
@@ -25,7 +25,7 @@ import java.util.List;
...
@@ -25,7 +25,7 @@ import java.util.List;
/**
/**
* @author peng-yongsheng
* @author peng-yongsheng
*/
*/
public
interface
Module
Query
extends
Service
{
public
interface
ClusterNodes
Query
extends
Service
{
List
<
InstanceDetails
>
query
(
String
moduleName
,
String
providerName
)
throws
ServiceRegisterException
;
List
<
RemoteInstance
>
queryRemoteNodes
()
;
}
}
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cluster/
Module
Register.java
→
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cluster/
Cluster
Register.java
浏览文件 @
62ca37bc
...
@@ -23,8 +23,7 @@ import org.apache.skywalking.oap.server.library.module.Service;
...
@@ -23,8 +23,7 @@ import org.apache.skywalking.oap.server.library.module.Service;
/**
/**
* @author peng-yongsheng
* @author peng-yongsheng
*/
*/
public
interface
Module
Register
extends
Service
{
public
interface
Cluster
Register
extends
Service
{
void
register
(
String
moduleName
,
String
providerName
,
void
registerRemote
(
RemoteInstance
remoteInstance
)
throws
ServiceRegisterException
;
InstanceDetails
instanceDetails
)
throws
ServiceRegisterException
;
}
}
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cluster/
InstanceDetails
.java
→
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cluster/
RemoteInstance
.java
浏览文件 @
62ca37bc
...
@@ -21,11 +21,10 @@ package org.apache.skywalking.oap.server.core.cluster;
...
@@ -21,11 +21,10 @@ package org.apache.skywalking.oap.server.core.cluster;
/**
/**
* @author peng-yongsheng
* @author peng-yongsheng
*/
*/
public
class
InstanceDetails
{
public
class
RemoteInstance
{
private
String
host
;
private
String
host
;
private
int
port
;
private
int
port
;
private
String
contextPath
;
public
String
getHost
()
{
public
String
getHost
()
{
return
host
;
return
host
;
...
@@ -42,12 +41,4 @@ public class InstanceDetails {
...
@@ -42,12 +41,4 @@ public class InstanceDetails {
public
void
setPort
(
int
port
)
{
public
void
setPort
(
int
port
)
{
this
.
port
=
port
;
this
.
port
=
port
;
}
}
public
String
getContextPath
()
{
return
contextPath
;
}
public
void
setContextPath
(
String
contextPath
)
{
this
.
contextPath
=
contextPath
;
}
}
}
oap-server/server-core/src/main/resources/META-INF/services/org.apache.skywalking.oap.server.library.module.ModuleDefine
0 → 100644
浏览文件 @
62ca37bc
#
# 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.
#
#
org.apache.skywalking.oap.server.core.storage.StorageModule
org.apache.skywalking.oap.server.core.cluster.ClusterModule
org.apache.skywalking.oap.server.core.CoreModule
\ No newline at end of file
oap-server/server-library/library-module/src/main/java/org/apache/skywalking/oap/server/library/module/BootstrapFlow.java
浏览文件 @
62ca37bc
...
@@ -63,7 +63,7 @@ class BootstrapFlow {
...
@@ -63,7 +63,7 @@ class BootstrapFlow {
}
}
}
}
void
notifyAfterCompleted
()
throws
ServiceNotProvidedException
{
void
notifyAfterCompleted
()
throws
ServiceNotProvidedException
,
ModuleStartException
{
for
(
ModuleProvider
provider
:
startupSequence
)
{
for
(
ModuleProvider
provider
:
startupSequence
)
{
provider
.
notifyAfterCompleted
();
provider
.
notifyAfterCompleted
();
}
}
...
...
oap-server/server-library/library-module/src/main/java/org/apache/skywalking/oap/server/library/module/ModuleDefine.java
浏览文件 @
62ca37bc
...
@@ -53,7 +53,7 @@ public abstract class ModuleDefine {
...
@@ -53,7 +53,7 @@ public abstract class ModuleDefine {
* @throws ProviderNotFoundException when even don't find a single one providers.
* @throws ProviderNotFoundException when even don't find a single one providers.
*/
*/
void
prepare
(
ModuleManager
moduleManager
,
void
prepare
(
ModuleManager
moduleManager
,
ApplicationConfiguration
.
ModuleConfiguration
configuration
)
throws
ProviderNotFoundException
,
ServiceNotProvidedException
,
ModuleConfigException
{
ApplicationConfiguration
.
ModuleConfiguration
configuration
)
throws
ProviderNotFoundException
,
ServiceNotProvidedException
,
ModuleConfigException
,
ModuleStartException
{
ServiceLoader
<
ModuleProvider
>
moduleProviderLoader
=
ServiceLoader
.
load
(
ModuleProvider
.
class
);
ServiceLoader
<
ModuleProvider
>
moduleProviderLoader
=
ServiceLoader
.
load
(
ModuleProvider
.
class
);
boolean
providerExist
=
false
;
boolean
providerExist
=
false
;
for
(
ModuleProvider
provider
:
moduleProviderLoader
)
{
for
(
ModuleProvider
provider
:
moduleProviderLoader
)
{
...
...
oap-server/server-library/library-module/src/main/java/org/apache/skywalking/oap/server/library/module/ModuleProvider.java
浏览文件 @
62ca37bc
...
@@ -66,7 +66,7 @@ public abstract class ModuleProvider {
...
@@ -66,7 +66,7 @@ public abstract class ModuleProvider {
/**
/**
* In prepare stage, the module should initialize things which are irrelative other modules.
* In prepare stage, the module should initialize things which are irrelative other modules.
*/
*/
public
abstract
void
prepare
()
throws
ServiceNotProvidedException
;
public
abstract
void
prepare
()
throws
ServiceNotProvidedException
,
ModuleStartException
;
/**
/**
* In start stage, the module has been ready for interop.
* In start stage, the module has been ready for interop.
...
@@ -76,7 +76,7 @@ public abstract class ModuleProvider {
...
@@ -76,7 +76,7 @@ public abstract class ModuleProvider {
/**
/**
* This callback executes after all modules start up successfully.
* This callback executes after all modules start up successfully.
*/
*/
public
abstract
void
notifyAfterCompleted
()
throws
ServiceNotProvidedException
;
public
abstract
void
notifyAfterCompleted
()
throws
ServiceNotProvidedException
,
ModuleStartException
;
/**
/**
* @return module names which does this module require?
* @return module names which does this module require?
...
...
oap-server/server-starter/src/main/java/org/apache/skywalking/oap/server/starter/config/ApplicationConfigLoader.java
浏览文件 @
62ca37bc
...
@@ -48,7 +48,6 @@ public class ApplicationConfigLoader implements ConfigLoader<ApplicationConfigur
...
@@ -48,7 +48,6 @@ public class ApplicationConfigLoader implements ConfigLoader<ApplicationConfigur
@Override
public
ApplicationConfiguration
load
()
throws
ConfigFileNotFoundException
{
@Override
public
ApplicationConfiguration
load
()
throws
ConfigFileNotFoundException
{
ApplicationConfiguration
configuration
=
new
ApplicationConfiguration
();
ApplicationConfiguration
configuration
=
new
ApplicationConfiguration
();
this
.
loadConfig
(
configuration
);
this
.
loadConfig
(
configuration
);
this
.
loadDefaultConfig
(
configuration
);
this
.
overrideConfigBySystemEnv
(
configuration
);
this
.
overrideConfigBySystemEnv
(
configuration
);
return
configuration
;
return
configuration
;
}
}
...
@@ -84,31 +83,6 @@ public class ApplicationConfigLoader implements ConfigLoader<ApplicationConfigur
...
@@ -84,31 +83,6 @@ public class ApplicationConfigLoader implements ConfigLoader<ApplicationConfigur
}
}
}
}
@SuppressWarnings
(
"unchecked"
)
private
void
loadDefaultConfig
(
ApplicationConfiguration
configuration
)
throws
ConfigFileNotFoundException
{
try
{
Reader
applicationReader
=
ResourceUtils
.
read
(
"application-default.yml"
);
Map
<
String
,
Map
<
String
,
Map
<
String
,
?>>>
moduleConfig
=
yaml
.
loadAs
(
applicationReader
,
Map
.
class
);
if
(
CollectionUtils
.
isNotEmpty
(
moduleConfig
))
{
moduleConfig
.
forEach
((
moduleName
,
providerConfig
)
->
{
if
(!
configuration
.
has
(
moduleName
))
{
logger
.
warn
(
"The {} module did't define in application.yml, use default"
,
moduleName
);
ApplicationConfiguration
.
ModuleConfiguration
moduleConfiguration
=
configuration
.
addModule
(
moduleName
);
providerConfig
.
forEach
((
name
,
propertiesConfig
)
->
{
Properties
properties
=
new
Properties
();
if
(
propertiesConfig
!=
null
)
{
propertiesConfig
.
forEach
(
properties:
:
put
);
}
moduleConfiguration
.
addProviderConfiguration
(
name
,
properties
);
});
}
});
}
}
catch
(
FileNotFoundException
e
)
{
throw
new
ConfigFileNotFoundException
(
e
.
getMessage
(),
e
);
}
}
private
void
overrideConfigBySystemEnv
(
ApplicationConfiguration
configuration
)
{
private
void
overrideConfigBySystemEnv
(
ApplicationConfiguration
configuration
)
{
for
(
Map
.
Entry
<
Object
,
Object
>
prop
:
System
.
getProperties
().
entrySet
())
{
for
(
Map
.
Entry
<
Object
,
Object
>
prop
:
System
.
getProperties
().
entrySet
())
{
overrideModuleSettings
(
configuration
,
prop
.
getKey
().
toString
(),
prop
.
getValue
().
toString
());
overrideModuleSettings
(
configuration
,
prop
.
getKey
().
toString
(),
prop
.
getValue
().
toString
());
...
...
oap-server/server-starter/src/main/resources/application.yml
浏览文件 @
62ca37bc
...
@@ -15,17 +15,12 @@
...
@@ -15,17 +15,12 @@
# limitations under the License.
# limitations under the License.
cluster
:
cluster
:
zookeeper
:
standalone
:
hostPort
:
localhost:2181
# zookeeper:
# Retry Policy
# hostPort: localhost:2181
baseSleepTimeMs
:
1000
# initial amount of time to wait between retries
# # Retry Policy
maxRetries
:
3
# max number of times to retry
# baseSleepTimeMs: 1000 # initial amount of time to wait between retries
#naming:
# maxRetries: 3 # max number of times to retry
# jetty:
# #OS real network IP(binding required), for agent to find collector cluster
# host: localhost
# port: 10800
# contextPath: /
core
:
core
:
default
:
default
:
restHost
:
localhost
restHost
:
localhost
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录