Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ACS
Public
Cloud
MAS
clonemap
Commits
8afc46a8
Commit
8afc46a8
authored
Apr 01, 2021
by
Stefan Dähling
Browse files
move df client to new pkg
parent
817ce213
Pipeline
#439420
canceled with stages
Changes
11
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
build/docker/agency/Dockerfile
View file @
8afc46a8
...
...
@@ -49,7 +49,6 @@ RUN go mod download
COPY
cmd/agency cmd/agency
COPY
pkg/agency pkg/agency
COPY
pkg/client pkg/client
COPY
pkg/df/client pkg/df/client
COPY
pkg/schemas pkg/schemas
COPY
pkg/status pkg/status
COPY
pkg/common pkg/common
...
...
build/docker/ams/Dockerfile
View file @
8afc46a8
...
...
@@ -49,7 +49,7 @@ RUN go mod download
COPY
cmd/ams cmd/ams
COPY
pkg/ams pkg/ams
COPY
pkg/agency/client pkg/agency/client
COPY
pkg/
df/
client pkg/
df/
client
COPY
pkg/client pkg/client
COPY
pkg/schemas pkg/schemas
COPY
pkg/status pkg/status
COPY
pkg/common pkg/common
...
...
build/docker/benchmark/Dockerfile
View file @
8afc46a8
...
...
@@ -48,7 +48,6 @@ COPY go.sum .
RUN
go mod download
COPY
pkg/agency pkg/agency
COPY
pkg/client pkg/client
COPY
pkg/df/client pkg/df/client
COPY
pkg/schemas pkg/schemas
COPY
pkg/status pkg/status
COPY
pkg/common pkg/common
...
...
build/docker/frontend/Dockerfile
View file @
8afc46a8
...
...
@@ -50,7 +50,6 @@ COPY cmd/frontend cmd/frontend
COPY
pkg/frontend pkg/frontend
COPY
pkg/common pkg/common
COPY
pkg/schemas pkg/schemas
COPY
pkg/df/client pkg/df/client
COPY
pkg/client pkg/client
COPY
web web
ENV
PATH="/clonemap:${PATH}"
...
...
pkg/agency/agency.go
View file @
8afc46a8
...
...
@@ -60,7 +60,6 @@ import (
agencyclient
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/agency/client"
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/client"
dfclient
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/df/client"
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/schemas"
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/status"
)
...
...
@@ -77,7 +76,7 @@ type Agency struct {
msgIn
chan
[]
schemas
.
ACLMessage
logCollector
*
client
.
LogCollector
mqttClient
*
mqttClient
dfClient
*
df
client
.
Client
dfClient
*
client
.
DF
Client
amsClient
*
client
.
AMSClient
agencyClient
*
agencyclient
.
Client
logInfo
*
log
.
Logger
// logger for info logging
...
...
@@ -93,7 +92,7 @@ func StartAgency(task func(*Agent) error) (err error) {
remoteAgents
:
make
(
map
[
int
]
*
Agent
),
remoteAgencies
:
make
(
map
[
string
]
*
remoteAgency
),
msgIn
:
make
(
chan
[]
schemas
.
ACLMessage
,
1000
),
dfClient
:
df
client
.
New
(
time
.
Second
*
60
,
time
.
Second
*
1
,
4
),
dfClient
:
client
.
New
DFClient
(
time
.
Second
*
60
,
time
.
Second
*
1
,
4
),
amsClient
:
client
.
NewAMSClient
(
time
.
Second
*
60
,
time
.
Second
*
1
,
4
),
agencyClient
:
agencyclient
.
New
(
time
.
Second
*
60
,
time
.
Second
*
1
,
4
),
logError
:
log
.
New
(
os
.
Stderr
,
"[ERROR] "
,
log
.
LstdFlags
),
...
...
pkg/agency/agent.go
View file @
8afc46a8
...
...
@@ -53,7 +53,6 @@ import (
"sync"
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/client"
dfclient
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/df/client"
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/schemas"
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/status"
)
...
...
@@ -82,7 +81,7 @@ type Agent struct {
// newAgent creates a new agent
func
newAgent
(
info
schemas
.
AgentInfo
,
msgIn
chan
schemas
.
ACLMessage
,
aclLookup
func
(
int
)
(
*
ACL
,
error
),
logCol
*
client
.
LogCollector
,
logConfig
schemas
.
LoggerConfig
,
mqtt
*
mqttClient
,
dfClient
*
df
client
.
Client
,
logErr
*
log
.
Logger
,
logInf
*
log
.
Logger
)
(
ag
*
Agent
)
{
mqtt
*
mqttClient
,
dfClient
*
client
.
DF
Client
,
logErr
*
log
.
Logger
,
logInf
*
log
.
Logger
)
(
ag
*
Agent
)
{
ag
=
&
Agent
{
id
:
info
.
ID
,
nodeID
:
info
.
Spec
.
NodeID
,
...
...
pkg/agency/df.go
View file @
8afc46a8
...
...
@@ -51,7 +51,7 @@ import (
"sync"
"time"
dfclient
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/
df/
client"
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/client"
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/schemas"
)
...
...
@@ -63,7 +63,7 @@ type DF struct {
mutex
*
sync
.
Mutex
registeredServices
map
[
string
]
schemas
.
Service
active
bool
// indicates if df is active (switch via env)
dfClient
*
df
client
.
Client
dfClient
*
client
.
DF
Client
logError
*
log
.
Logger
logInfo
*
log
.
Logger
}
...
...
@@ -184,7 +184,7 @@ func (df *DF) DeregisterService(svcID string) (err error) {
}
// newDF creates a new DF object
func
newDF
(
masID
int
,
agentID
int
,
nodeID
int
,
dfCli
*
df
client
.
Client
,
logErr
*
log
.
Logger
,
func
newDF
(
masID
int
,
agentID
int
,
nodeID
int
,
dfCli
*
client
.
DF
Client
,
logErr
*
log
.
Logger
,
logInf
*
log
.
Logger
)
(
df
*
DF
)
{
df
=
&
DF
{
agentID
:
agentID
,
...
...
pkg/ams/ams.go
View file @
8afc46a8
...
...
@@ -57,7 +57,7 @@ import (
"time"
agclient
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/agency/client"
dfclient
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/
df/
client"
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/client"
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/schemas"
)
...
...
@@ -68,7 +68,7 @@ type AMS struct {
logInfo
*
log
.
Logger
// logger for info logging
logError
*
log
.
Logger
// logger for error logging
agencyClient
*
agclient
.
Client
dfClient
*
df
client
.
Client
dfClient
*
client
.
DF
Client
}
// StartAMS starts an AMS instance. It initializes the cluster and storage object and starts API
...
...
@@ -77,7 +77,7 @@ func StartAMS() (err error) {
ams
:=
&
AMS
{
logError
:
log
.
New
(
os
.
Stderr
,
"[ERROR] "
,
log
.
LstdFlags
),
agencyClient
:
agclient
.
New
(
time
.
Second
*
60
,
time
.
Second
*
1
,
4
),
dfClient
:
df
client
.
New
(
time
.
Second
*
60
,
time
.
Second
*
1
,
4
),
dfClient
:
client
.
New
DFClient
(
time
.
Second
*
60
,
time
.
Second
*
1
,
4
),
}
// create storage and deployment object according to specified deployment type
err
=
ams
.
init
()
...
...
pkg/ams/ams_test.go
View file @
8afc46a8
...
...
@@ -56,7 +56,6 @@ import (
agclient
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/agency/client"
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/client"
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/common/httpreply"
dfclient
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/df/client"
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/schemas"
)
...
...
@@ -72,7 +71,7 @@ func TestAMS(t *testing.T) {
logError
:
log
.
New
(
os
.
Stderr
,
"[ERROR] "
,
log
.
LstdFlags
),
logInfo
:
log
.
New
(
os
.
Stdout
,
"[INFO] "
,
log
.
LstdFlags
),
agencyClient
:
agclient
.
New
(
time
.
Second
*
60
,
time
.
Second
*
1
,
4
),
dfClient
:
df
client
.
New
(
time
.
Second
*
60
,
time
.
Second
*
1
,
4
),
dfClient
:
client
.
New
DFClient
(
time
.
Second
*
60
,
time
.
Second
*
1
,
4
),
}
// create storage and deployment object according to specified deployment type
err
:=
ams
.
init
()
...
...
pkg/
df/
client/
client
.go
→
pkg/client/
df
.go
View file @
8afc46a8
...
...
@@ -42,7 +42,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
// Package client implements a df client
package
client
import
(
...
...
@@ -59,8 +58,8 @@ import (
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/schemas"
)
// Client is the ams client
type
Client
struct
{
//
DF
Client is the ams client
type
DF
Client
struct
{
httpClient
*
http
.
Client
// http client
Host
string
// ams host name
Port
int
// ams port
...
...
@@ -69,7 +68,7 @@ type Client struct {
}
// Alive tests if alive
func
(
cli
*
Client
)
Alive
()
(
alive
bool
)
{
func
(
cli
*
DF
Client
)
Alive
()
(
alive
bool
)
{
alive
=
false
_
,
httpStatus
,
err
:=
httpretry
.
Get
(
cli
.
httpClient
,
cli
.
prefix
()
+
"/api/alive"
,
time
.
Second
*
2
,
2
)
if
err
==
nil
&&
httpStatus
==
http
.
StatusOK
{
...
...
@@ -79,7 +78,7 @@ func (cli *Client) Alive() (alive bool) {
}
// PostSvc post an mas
func
(
cli
*
Client
)
PostSvc
(
masID
int
,
svc
schemas
.
Service
)
(
retSvc
schemas
.
Service
,
httpStatus
int
,
func
(
cli
*
DF
Client
)
PostSvc
(
masID
int
,
svc
schemas
.
Service
)
(
retSvc
schemas
.
Service
,
httpStatus
int
,
err
error
)
{
var
body
[]
byte
js
,
_
:=
json
.
Marshal
(
svc
)
...
...
@@ -93,7 +92,7 @@ func (cli *Client) PostSvc(masID int, svc schemas.Service) (retSvc schemas.Servi
}
// GetSvc requests mas information
func
(
cli
*
Client
)
GetSvc
(
masID
int
,
desc
string
)
(
svc
[]
schemas
.
Service
,
httpStatus
int
,
func
(
cli
*
DF
Client
)
GetSvc
(
masID
int
,
desc
string
)
(
svc
[]
schemas
.
Service
,
httpStatus
int
,
err
error
)
{
var
body
[]
byte
body
,
httpStatus
,
err
=
httpretry
.
Get
(
cli
.
httpClient
,
cli
.
prefix
()
+
"/api/df/"
+
...
...
@@ -106,7 +105,7 @@ func (cli *Client) GetSvc(masID int, desc string) (svc []schemas.Service, httpSt
}
// GetLocalSvc requests mas information
func
(
cli
*
Client
)
GetLocalSvc
(
masID
int
,
desc
string
,
nodeID
int
,
func
(
cli
*
DF
Client
)
GetLocalSvc
(
masID
int
,
desc
string
,
nodeID
int
,
dist
float64
)
(
svc
[]
schemas
.
Service
,
httpStatus
int
,
err
error
)
{
var
body
[]
byte
body
,
httpStatus
,
err
=
httpretry
.
Get
(
cli
.
httpClient
,
cli
.
prefix
()
+
"/api/df/"
+
...
...
@@ -120,14 +119,14 @@ func (cli *Client) GetLocalSvc(masID int, desc string, nodeID int,
}
// DeleteSvc removes service from df
func
(
cli
*
Client
)
DeleteSvc
(
masID
int
,
svcID
string
)
(
httpStatus
int
,
err
error
)
{
func
(
cli
*
DF
Client
)
DeleteSvc
(
masID
int
,
svcID
string
)
(
httpStatus
int
,
err
error
)
{
httpStatus
,
err
=
httpretry
.
Delete
(
cli
.
httpClient
,
cli
.
prefix
()
+
"/api/df/"
+
strconv
.
Itoa
(
masID
)
+
"/svc/id/"
+
svcID
,
nil
,
time
.
Second
*
2
,
2
)
return
}
// PostGraph post the graph of a mas
func
(
cli
*
Client
)
PostGraph
(
masID
int
,
gr
schemas
.
Graph
)
(
httpStatus
int
,
err
error
)
{
func
(
cli
*
DF
Client
)
PostGraph
(
masID
int
,
gr
schemas
.
Graph
)
(
httpStatus
int
,
err
error
)
{
js
,
_
:=
json
.
Marshal
(
gr
)
_
,
httpStatus
,
err
=
httpretry
.
Post
(
cli
.
httpClient
,
cli
.
prefix
()
+
"/api/df/"
+
strconv
.
Itoa
(
masID
)
+
"/graph"
,
"application/json"
,
js
,
time
.
Second
*
2
,
2
)
...
...
@@ -135,7 +134,7 @@ func (cli *Client) PostGraph(masID int, gr schemas.Graph) (httpStatus int, err e
}
// GetGraph returns graph of mas
func
(
cli
*
Client
)
GetGraph
(
masID
int
)
(
graph
schemas
.
Graph
,
httpStatus
int
,
err
error
)
{
func
(
cli
*
DF
Client
)
GetGraph
(
masID
int
)
(
graph
schemas
.
Graph
,
httpStatus
int
,
err
error
)
{
var
body
[]
byte
body
,
httpStatus
,
err
=
httpretry
.
Get
(
cli
.
httpClient
,
cli
.
prefix
()
+
"/api/df/"
+
strconv
.
Itoa
(
masID
)
+
"/graph"
,
time
.
Second
*
2
,
2
)
...
...
@@ -146,7 +145,7 @@ func (cli *Client) GetGraph(masID int) (graph schemas.Graph, httpStatus int, err
return
}
func
(
cli
*
Client
)
getIP
()
(
ret
string
)
{
func
(
cli
*
DF
Client
)
getIP
()
(
ret
string
)
{
for
{
ips
,
err
:=
net
.
LookupHost
(
cli
.
Host
)
if
len
(
ips
)
>
0
&&
err
==
nil
{
...
...
@@ -157,14 +156,14 @@ func (cli *Client) getIP() (ret string) {
return
}
func
(
cli
*
Client
)
prefix
()
(
ret
string
)
{
func
(
cli
*
DF
Client
)
prefix
()
(
ret
string
)
{
ret
=
"http://"
+
cli
.
Host
+
":"
+
strconv
.
Itoa
(
cli
.
Port
)
return
}
// New creates a new AMS client
func
New
(
timeout
time
.
Duration
,
del
time
.
Duration
,
numRet
int
)
(
cli
*
Client
)
{
cli
=
&
Client
{
// New
DFClient
creates a new AMS client
func
New
DFClient
(
timeout
time
.
Duration
,
del
time
.
Duration
,
numRet
int
)
(
cli
*
DF
Client
)
{
cli
=
&
DF
Client
{
httpClient
:
&
http
.
Client
{
Timeout
:
timeout
},
Host
:
"df"
,
Port
:
12000
,
...
...
pkg/frontend/frontend.go
View file @
8afc46a8
...
...
@@ -52,14 +52,13 @@ import (
"time"
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/client"
dfclient
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/df/client"
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/schemas"
)
// Frontend frontend
type
Frontend
struct
{
amsClient
*
client
.
AMSClient
dfClient
*
df
client
.
Client
dfClient
*
client
.
DF
Client
logClient
*
client
.
LoggerClient
logInfo
*
log
.
Logger
// logger for info logging
logError
*
log
.
Logger
// logger for error logging
...
...
@@ -69,7 +68,7 @@ type Frontend struct {
func
StartFrontend
()
(
err
error
)
{
fe
:=
&
Frontend
{
amsClient
:
client
.
NewAMSClient
(
time
.
Second
*
60
,
time
.
Second
*
1
,
4
),
dfClient
:
df
client
.
New
(
time
.
Second
*
60
,
time
.
Second
*
1
,
4
),
dfClient
:
client
.
New
DFClient
(
time
.
Second
*
60
,
time
.
Second
*
1
,
4
),
logError
:
log
.
New
(
os
.
Stderr
,
"[ERROR] "
,
log
.
LstdFlags
),
}
fe
.
logClient
,
_
=
client
.
NewLoggerClient
(
"logger"
,
11000
,
time
.
Second
*
60
,
time
.
Second
*
1
,
4
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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