Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
CAP
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
CAP
Commits
98a1c0d7
Commit
98a1c0d7
authored
Apr 15, 2018
by
Liuhaoyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor ApplicationService
parent
1e847fad
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
172 additions
and
2 deletions
+172
-2
CollectorConfig.cs
src/SkyWalking.Abstractions/Config/CollectorConfig.cs
+15
-0
RemoteDownstreamConfig.cs
src/SkyWalking.Abstractions/Config/RemoteDownstreamConfig.cs
+7
-1
ServiceManager.cs
src/SkyWalking.Core/Boot/ServiceManager.cs
+2
-1
ContextManager.cs
src/SkyWalking.Core/Context/ContextManager.cs
+2
-0
GrpcApplicationService.cs
src/SkyWalking.Core/Remote/GrpcApplicationService.cs
+94
-0
GrpcChannelManager.cs
src/SkyWalking.Core/Remote/GrpcChannelManager.cs
+52
-0
No files found.
src/SkyWalking.Abstractions/Config/CollectorConfig.cs
View file @
98a1c0d7
...
...
@@ -20,5 +20,20 @@ namespace SkyWalking.Config
{
public
class
CollectorConfig
{
/// <summary>
/// service registry check interval
/// </summary>
public
static
long
ServiceRegisterCheckInterval
{
get
;
set
;
}
=
3
;
/// <summary>
/// Collector agent_gRPC/grpc service addresses.
/// By using this, no discovery mechanism provided. The agent only uses these addresses to uplink data.
/// Recommend to use this only when collector cluster IPs are unreachable from agent side. Such as:
/// 1. Agent and collector cluster are in different VPC in Cloud.
/// 2. Agent uplinks data to collector cluster through Internet.
/// Single collector:DirectServers="127.0.0.1:11800"
/// Collector cluster:DirectServers="10.2.45.126:11800,10.2.45.127:11800"
/// </summary>
public
static
string
DirectServers
{
get
;
set
;
}
}
}
\ No newline at end of file
src/SkyWalking.Abstractions/Config/RemoteDownstreamConfig.cs
View file @
98a1c0d7
...
...
@@ -17,6 +17,7 @@
*/
using
System.Collections.Generic
;
using
System.Linq
;
using
SkyWalking.Dictionarys
;
namespace
SkyWalking.Config
...
...
@@ -36,10 +37,15 @@ namespace SkyWalking.Config
public
static
class
Collector
{
private
static
IList
<
string
>
_grpcServers
;
/// <summary>
/// Collector GRPC-Service address.
/// </summary>
public
static
IList
<
string
>
gRPCServers
=
new
List
<
string
>();
public
static
IList
<
string
>
gRPCServers
{
get
=>
_grpcServers
??
CollectorConfig
.
DirectServers
.
Split
(
','
).
ToList
();
set
=>
_grpcServers
=
value
;
}
}
}
}
src/SkyWalking.Core/Boot/ServiceManager.cs
View file @
98a1c0d7
...
...
@@ -40,7 +40,8 @@ namespace SkyWalking.Boot
private
Type
[]
FindServiceTypes
()
{
return
typeof
(
ServiceManager
).
Assembly
.
GetTypes
().
Where
(
x
=>
typeof
(
IBootService
).
IsAssignableFrom
(
x
))
return
typeof
(
ServiceManager
).
Assembly
.
GetTypes
().
Where
(
x
=>
x
.
IsClass
&&
!
x
.
IsAbstract
&&
typeof
(
IBootService
).
IsAssignableFrom
(
x
))
.
ToArray
();
}
...
...
src/SkyWalking.Core/Context/ContextManager.cs
View file @
98a1c0d7
...
...
@@ -179,6 +179,8 @@ namespace SkyWalking.Context
{
}
public
int
Order
{
get
;
}
=
1
;
public
Task
Initialize
(
CancellationToken
token
)
{
TracingContext
.
ListenerManager
.
Add
(
this
);
...
...
src/SkyWalking.Core/Remote/GrpcApplicationService.cs
0 → 100644
View file @
98a1c0d7
/*
* 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.
*
*/
using
System
;
using
System.Diagnostics
;
using
System.Linq
;
using
System.Net
;
using
System.Net.Sockets
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
SkyWalking.Boot
;
using
SkyWalking.Config
;
using
SkyWalking.Context
;
using
SkyWalking.NetworkProtocol
;
namespace
SkyWalking.Remote
{
public
class
GrpcApplicationService
:
TimerService
{
public
override
int
Order
{
get
;
}
=
-
1
;
protected
override
async
Task
Initializing
(
CancellationToken
token
)
{
var
application
=
new
Application
{
ApplicationCode
=
AgentConfig
.
ApplicationCode
};
var
applicationRegisterService
=
new
ApplicationRegisterService
.
ApplicationRegisterServiceClient
(
GrpcChannelManager
.
Instance
.
Channel
);
var
applicationMapping
=
await
applicationRegisterService
.
applicationCodeRegisterAsync
(
application
);
RemoteDownstreamConfig
.
Agent
.
ApplicationId
=
applicationMapping
.
Application
.
Value
;
var
instanceDiscoveryService
=
new
InstanceDiscoveryService
.
InstanceDiscoveryServiceClient
(
GrpcChannelManager
.
Instance
.
Channel
);
var
agentUUID
=
Guid
.
NewGuid
().
ToString
().
Replace
(
"-"
,
""
);
var
registerTime
=
DateTime
.
UtcNow
.
GetTimeMillis
();
var
hostName
=
Dns
.
GetHostName
();
// var ipv4s = Dns.GetHostAddresses(hostName);
var
osInfo
=
new
OSInfo
{
Hostname
=
hostName
,
OsName
=
Environment
.
OSVersion
.
ToString
(),
ProcessNo
=
Process
.
GetCurrentProcess
().
Id
};
// foreach (var ipAddress in ipv4s.Where(x => x.AddressFamily == AddressFamily.InterNetwork))
// osInfo.Ipv4S.Add(ipAddress.ToString());
var
applicationInstance
=
new
ApplicationInstance
{
ApplicationId
=
applicationMapping
.
Application
.
Value
,
AgentUUID
=
agentUUID
,
RegisterTime
=
registerTime
,
Osinfo
=
osInfo
};
var
applicationInstanceMapping
=
await
instanceDiscoveryService
.
registerInstanceAsync
(
applicationInstance
);
RemoteDownstreamConfig
.
Agent
.
ApplicationInstanceId
=
applicationInstanceMapping
.
ApplicationInstanceId
;
}
protected
override
TimeSpan
Interval
{
get
;
}
=
TimeSpan
.
FromMinutes
(
1
);
protected
override
async
Task
Execute
(
CancellationToken
token
)
{
var
instanceDiscoveryService
=
new
InstanceDiscoveryService
.
InstanceDiscoveryServiceClient
(
GrpcChannelManager
.
Instance
.
Channel
);
var
heartbeat
=
new
ApplicationInstanceHeartbeat
{
ApplicationInstanceId
=
RemoteDownstreamConfig
.
Agent
.
ApplicationInstanceId
,
HeartbeatTime
=
DateTime
.
UtcNow
.
GetTimeMillis
()
};
await
instanceDiscoveryService
.
heartbeatAsync
(
heartbeat
);
}
}
}
\ No newline at end of file
src/SkyWalking.Core/Remote/GrpcChannelManager.cs
0 → 100644
View file @
98a1c0d7
/*
* 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.
*
*/
using
System.Linq
;
using
System.Threading.Tasks
;
using
Grpc.Core
;
using
SkyWalking.Boot
;
using
SkyWalking.Config
;
namespace
SkyWalking.Remote
{
public
class
GrpcChannelManager
{
private
static
readonly
GrpcChannelManager
_client
=
new
GrpcChannelManager
();
public
static
GrpcChannelManager
Instance
=>
_client
;
private
Channel
_channel
;
public
Channel
Channel
=>
_channel
;
private
GrpcChannelManager
()
{
_channel
=
new
Channel
(
RemoteDownstreamConfig
.
Collector
.
gRPCServers
.
First
(),
ChannelCredentials
.
Insecure
);
}
public
Task
ConnectAsync
()
{
return
_channel
.
ConnectAsync
();
}
public
Task
ShutdownAsync
()
{
return
_channel
.
ShutdownAsync
();
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment