Commit 77d38c75 authored by Qianwen's avatar Qianwen
Browse files

refine log series

parent a903bfeb
Pipeline #467043 passed with stages
in 2 minutes and 40 seconds
......@@ -76,10 +76,12 @@ func task(ag *agency.Agent) (err error) {
if err != nil {
fmt.Println(err)
}
for i := 0; i < 20; i++ {
for i := 0; i < 5; i++ {
time.Sleep(2 * time.Second)
idx := rand.Intn(4) + 1
ag.Logger.NewLogSeries("type"+strconv.Itoa(idx), rand.Intn(100))
/* idx := rand.Intn(4) + 1 */
for idx := 1; idx < 5; idx++ {
ag.Logger.NewLogSeries("type"+strconv.Itoa(idx), rand.Float64())
}
}
return
}
......@@ -19,7 +19,7 @@
"imagegroups":[
{
"config":{
"image":"qianwen12/agency"
"image":"registry.git.rwth-aachen.de/acs/public/cloud/mas/clonemap/agency"
},
"agents":[
{
......
......@@ -125,11 +125,11 @@ func (cli *LoggerClient) PostLogSeries(masID int, logs []schemas.LogSeries) (htt
return
}
// GetLogSeries gets log series with its name
func (cli *LoggerClient) GetLogSeries(masID int, agentID int) (series []schemas.LogSeries, httpStatus int, err error) {
// GetLogSeriesByName gets log series by its name
func (cli *LoggerClient) GetLogSeriesByName(masID int, agentID int, name string, start string, end string) (series []schemas.LogSeries, httpStatus int, err error) {
var body []byte
body, httpStatus, err = httpretry.Get(cli.httpClient, cli.prefix()+"/api/series/"+
strconv.Itoa(masID)+"/"+strconv.Itoa(agentID), time.Second*2, 4)
strconv.Itoa(masID)+"/"+strconv.Itoa(agentID)+"/"+name+"/time/"+start+"/"+end, time.Second*2, 4)
if err != nil {
return
}
......@@ -140,6 +140,21 @@ func (cli *LoggerClient) GetLogSeries(masID int, agentID int) (series []schemas.
return
}
// GetLogSeriesNames gets log series by its name
func (cli *LoggerClient) GetLogSeriesNames(masID int, agentID int) (names []string, httpStatus int, err error) {
var body []byte
body, httpStatus, err = httpretry.Get(cli.httpClient, cli.prefix()+"/api/series/"+
strconv.Itoa(masID)+"/"+strconv.Itoa(agentID)+"/names", time.Second*2, 4)
if err != nil {
return
}
err = json.Unmarshal(body, &names)
if err != nil {
names = []string{}
}
return
}
// PutState updates the state
func (cli *LoggerClient) PutState(state schemas.State) (httpStatus int, err error) {
js, _ := json.Marshal(state)
......@@ -196,6 +211,7 @@ func NewLoggerClient(host string, port int, timeout time.Duration, del time.Dura
type LogCollector struct {
masID int
logIn chan schemas.LogMessage // logging inbox
seriesName string
logSeriesIn chan schemas.LogSeries
stateIn chan schemas.State
client *LoggerClient
......@@ -391,7 +407,7 @@ func (agLog *AgentLogger) NewLog(topic string, message string, data string) (err
}
// NewLogSeries sends a new logging series to
func (agLog *AgentLogger) NewLogSeries(name string, value int) (err error) {
func (agLog *AgentLogger) NewLogSeries(name string, value float64) (err error) {
if agLog == nil {
return
}
......@@ -403,13 +419,13 @@ func (agLog *AgentLogger) NewLogSeries(name string, value int) (err error) {
time.Sleep(time.Millisecond * 5)
tStamp := time.Now()
agLog.mutex.Unlock()
logSeries := schemas.LogSeries{
seriesItem := schemas.LogSeries{
AgentID: agLog.agentID,
Timestamp: tStamp,
Name: name,
Timestamp: tStamp,
Value: value,
}
agLog.logSeriesOut <- logSeries
agLog.logSeriesOut <- seriesItem
return
}
......
......@@ -162,25 +162,6 @@ func getNLogs(r *http.Request) (masID int, agentid int, topic string, num int, e
return
}
// getRange return the masid, agentid, topic and start and end
func getLogsTime(r *http.Request) (masID int, agentid int, topic string, start string, end string, err error) {
vars := mux.Vars(r)
masID, err = strconv.Atoi(vars["masid"])
if err != nil {
return
}
agentid, err = strconv.Atoi(vars["agentid"])
if err != nil {
return
}
topic = vars["topic"]
start = vars["start"]
end = vars["end"]
return
}
// loggingMiddleware logs request before calling final handler
func (fe *Frontend) loggingMiddleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
......@@ -221,7 +202,8 @@ func (fe *Frontend) server(port int) (serv *http.Server) {
s.Path("/df/{masid}/svc/desc/{desc}/node/{nodeid}/dist/{dist}").Methods("Get").HandlerFunc(fe.handleSvcWithDist)
// api for logger
s.Path("/logging/series/{masid}/{agentid}").Methods("GET").HandlerFunc(fe.handleGetLogSeries)
s.Path("/logging/series/{masid}/{agentid}/names").Methods("GET").HandlerFunc(fe.handleGetLogSeriesNames)
s.Path("/logging/series/{masid}/{agentid}/{name}/time/{start}/{end}").Methods("GET").HandlerFunc(fe.handleGetLogSeriesByName)
s.Path("/logging/{masid}/{agentid}/{topic}/latest/{num}").Methods("GET").HandlerFunc(fe.handleGetNLatestLogs)
s.Path("/logging/{masid}/list").Methods("POST").HandlerFunc(fe.handlePostLogs)
s.Path("/logging/{masid}/{agentid}/{topic}/time/{start}/{end}").Methods("GET").HandlerFunc(fe.handleGetLogsInRange)
......
......@@ -141,7 +141,11 @@ func (fe *Frontend) handleGetNLatestLogs(w http.ResponseWriter, r *http.Request)
// handleGetLogsTime is the handler to /api/logging/{masid}/{agentid}/{topic}/time/{start}/{end}
func (fe *Frontend) handleGetLogsInRange(w http.ResponseWriter, r *http.Request) {
var cmapErr, httpErr error
masid, agentid, topic, start, end, cmapErr := getLogsTime(r)
masid, agentid, cmapErr := getAgentID(r)
vars := mux.Vars(r)
topic := vars["topic"]
start := vars["start"]
end := vars["end"]
if cmapErr != nil {
httpErr = httpreply.NotFoundError(w)
fe.logErrors(r.URL.Path, cmapErr, httpErr)
......@@ -161,8 +165,30 @@ func (fe *Frontend) handleGetLogsInRange(w http.ResponseWriter, r *http.Request)
return
}
// handleGetLogSeries is the handler to /api/logging/series/{masid}/{agentid}
func (fe *Frontend) handleGetLogSeries(w http.ResponseWriter, r *http.Request) {
// handleGetLogSeriesNames is the handler to api/logging/series/{masid}/{agentid}/names
func (fe *Frontend) handleGetLogSeriesNames(w http.ResponseWriter, r *http.Request) {
var cmapErr, httpErr error
masID, agentID, cmapErr := getAgentID(r)
if cmapErr != nil {
httpErr = httpreply.NotFoundError(w)
fe.logErrors(r.URL.Path, cmapErr, httpErr)
return
}
var names []string
names, _, cmapErr = fe.logClient.GetLogSeriesNames(masID, agentID)
if cmapErr != nil {
httpErr = httpreply.CMAPError(w, cmapErr.Error())
fe.logErrors(r.URL.Path, cmapErr, httpErr)
return
}
httpErr = httpreply.Resource(w, names, cmapErr)
fe.logErrors(r.URL.Path, cmapErr, httpErr)
return
}
// handleGetLogSeriesByName is the handler to /api/logging/series/{masid}/{agentid}/{name}/time/{start}/{end}
func (fe *Frontend) handleGetLogSeriesByName(w http.ResponseWriter, r *http.Request) {
var cmapErr, httpErr error
masID, agentID, cmapErr := getAgentID(r)
......@@ -171,8 +197,12 @@ func (fe *Frontend) handleGetLogSeries(w http.ResponseWriter, r *http.Request) {
fe.logErrors(r.URL.Path, cmapErr, httpErr)
return
}
vars := mux.Vars(r)
name := vars["name"]
start := vars["start"]
end := vars["end"]
var series []schemas.LogSeries
series, _, cmapErr = fe.logClient.GetLogSeries(masID, agentID)
series, _, cmapErr = fe.logClient.GetLogSeriesByName(masID, agentID, name, start, end)
if cmapErr != nil {
httpErr = httpreply.CMAPError(w, cmapErr.Error())
fe.logErrors(r.URL.Path, cmapErr, httpErr)
......
......@@ -190,10 +190,10 @@ func (stor *cassStorage) addAgentLogSeries(series schemas.LogSeries) {
}
// getAgentLogSeries get log series
func (stor *cassStorage) getAgentLogSeries(masID int, agentID int) (series []schemas.LogSeries, err error) {
func (stor *cassStorage) getAgentLogSeries(masID int, agentID int, name string, start time.Time, end time.Time) (series []schemas.LogSeries, err error) {
var iter *gocql.Iter
iter = stor.session.Query("SELECT state FROM logging_series WHERE masid = ? AND agentid = ?", masID,
agentID).Iter()
iter = stor.session.Query("SELECT log FROM logging_series WHERE masid = ? AND agentid = ? AND name = ?", masID,
agentID, name).Iter()
var js []byte
for iter.Scan(&js) {
var logSeries schemas.LogSeries
......@@ -207,6 +207,11 @@ func (stor *cassStorage) getAgentLogSeries(masID int, agentID int) (series []sch
return
}
// getAgentLogSeriesNames get log series
func (stor *cassStorage) getAgentLogSeriesNames(masID int, agentID int) (names []string, err error) {
return
}
// deleteAgentLogMessages deletes all log messages og an agent
func (stor *cassStorage) deleteAgentLogMessages(masID int, agentID int) (err error) {
......@@ -325,7 +330,7 @@ func (stor *cassStorage) storeLogs(topic string) {
// storeSeries stores the log series in a batch operation
func (stor *cassStorage) storeSeries() {
var err error
stmt := "INSERT INTO logging_series (masid, agentid, t, log) VALUES (?, ?, ?, ?)"
stmt := "INSERT INTO logging_series (masid, agentid, name, t, log) VALUES (?, ?, ?, ?, ?)"
for {
batch := gocql.NewBatch(gocql.UnloggedBatch)
......@@ -335,7 +340,7 @@ func (stor *cassStorage) storeSeries() {
if err != nil {
fmt.Println(err)
}
batch.Query(stmt, series.MASID, series.AgentID, series.Timestamp, js)
batch.Query(stmt, series.MASID, series.AgentID, series.Timestamp, series.Name, js)
size := len(js)
for i := 0; i < 9; i++ {
// maximum of 10 operations in batch
......
......@@ -163,7 +163,7 @@ func (logger *Logger) handlePostLogMsgList(w http.ResponseWriter, r *http.Reques
logger.logErrors(r.URL.Path, cmapErr, httpErr)
}
// handlePostLogSeries is the handler for post requests to path /api/series/{masid}/
// handlePostLogSeries is the handler for post requests to path /api/series/{masid}/{agentid}
func (logger *Logger) handlePostLogSeries(w http.ResponseWriter, r *http.Request) {
var cmapErr, httpErr error
// create new log message entry
......@@ -251,8 +251,8 @@ func (logger *Logger) handleGetLogsTime(w http.ResponseWriter, r *http.Request)
logger.logErrors(r.URL.Path, cmapErr, httpErr)
}
// handleGetLogSeries is the handler for get requests to path /api/series/{masid}/{agentid}/{name}
func (logger *Logger) handleGetLogSeries(w http.ResponseWriter, r *http.Request) {
// handleGetLogSeriesNames is the handler for requests to path /api/series/{masid}/{agentid}/names
func (logger *Logger) handleGetLogSeriesNames(w http.ResponseWriter, r *http.Request) {
var cmapErr, httpErr error
masID, agentID, cmapErr := getAgentID(r)
if cmapErr != nil {
......@@ -260,8 +260,42 @@ func (logger *Logger) handleGetLogSeries(w http.ResponseWriter, r *http.Request)
logger.logErrors(r.URL.Path, cmapErr, httpErr)
return
}
var names []string
names, cmapErr = logger.getAgentLogSeriesNames(masID, agentID)
if cmapErr != nil {
httpErr = httpreply.CMAPError(w, cmapErr.Error())
logger.logErrors(r.URL.Path, cmapErr, httpErr)
return
}
httpErr = httpreply.Resource(w, names, cmapErr)
logger.logErrors(r.URL.Path, cmapErr, httpErr)
}
// handleGetLogSeriesByName is the handler for requests to path /api/series/{masid}/{agentid}/{name}
func (logger *Logger) handleGetLogSeriesByName(w http.ResponseWriter, r *http.Request) {
var cmapErr, httpErr error
masID, agentID, cmapErr := getAgentID(r)
if cmapErr != nil {
httpErr = httpreply.NotFoundError(w)
logger.logErrors(r.URL.Path, cmapErr, httpErr)
return
}
vars := mux.Vars(r)
name := vars["name"]
start, cmapErr := time.Parse("20060102150405", vars["start"])
if cmapErr != nil {
httpErr = httpreply.NotFoundError(w)
logger.logErrors(r.URL.Path, cmapErr, httpErr)
return
}
end, cmapErr := time.Parse("20060102150405", vars["end"])
if cmapErr != nil {
httpErr = httpreply.NotFoundError(w)
logger.logErrors(r.URL.Path, cmapErr, httpErr)
return
}
var logSeries []schemas.LogSeries
logSeries, cmapErr = logger.getAgentLogSeries(masID, agentID)
logSeries, cmapErr = logger.getAgentLogSeries(masID, agentID, name, start, end)
if cmapErr != nil {
httpErr = httpreply.CMAPError(w, cmapErr.Error())
logger.logErrors(r.URL.Path, cmapErr, httpErr)
......@@ -422,7 +456,8 @@ func (logger *Logger) server(port int) (serv *http.Server) {
s.Path("/logging/{masid}/{agentid}/{topic}/time/{start}/{end}").
Methods("POST", "PUT", "DELETE").HandlerFunc(logger.methodNotAllowed)
s.Path("/series/{masid}/{agentid}").Methods("GET").HandlerFunc(logger.handleGetLogSeries)
s.Path("/series/{masid}/{agentid}/names").Methods("GET").HandlerFunc(logger.handleGetLogSeriesNames)
s.Path("/series/{masid}/{agentid}/{name}/time/{start}/{end}").Methods("GET").HandlerFunc(logger.handleGetLogSeriesByName)
s.Path("/series/{masid}").Methods("POST").HandlerFunc(logger.handlePostLogSeries)
s.Path("/state/{masid}/{agentid}").Methods("GET").HandlerFunc(logger.handleGetState)
......
......@@ -129,13 +129,26 @@ func (logger *Logger) addAgentLogMessageList(logmsg []schemas.LogMessage) (err e
return
}
// addAgentLogSeries
// addAgentLogSeries add log series
func (logger *Logger) addAgentLogSeries(logseries []schemas.LogSeries) {
for i := 0; i < len(logseries); i++ {
logger.stor.addAgentLogSeries(logseries[i])
}
}
// getLogSeriesByName return all the log series of a specific name
func (logger *Logger) getAgentLogSeries(masID int, agentID int, name string, start time.Time, end time.Time) (series []schemas.LogSeries, err error) {
series, err = logger.stor.getAgentLogSeries(masID, agentID, name, start, end)
return
}
// agetAgentLogSeriesNames add log series
func (logger *Logger) getAgentLogSeriesNames(masID int, agentID int) (names []string, err error) {
names, err = logger.stor.getAgentLogSeriesNames(masID, agentID)
return
}
// getLatestAgentLogMessages return the latest num log messages
func (logger *Logger) getLatestAgentLogMessages(masID int, agentID int, topic string,
num int) (logs []schemas.LogMessage, err error) {
......@@ -150,12 +163,6 @@ func (logger *Logger) getAgentLogMessagesInRange(masID int, agentID int, topic s
return
}
// getLogSeries return all the log series of a specific name
func (logger *Logger) getAgentLogSeries(masID int, agentID int) (series []schemas.LogSeries, err error) {
series, err = logger.stor.getAgentLogSeries(masID, agentID)
return
}
// updateCommunication updates communication data of agent
func (logger *Logger) updateCommunication(masID int, agentID int,
comm []schemas.Communication) (err error) {
......
......@@ -70,7 +70,10 @@ type storage interface {
addAgentLogSeries(series schemas.LogSeries)
// getAgentLogSeries get the log series
getAgentLogSeries(masID int, agentID int) (series []schemas.LogSeries, err error)
getAgentLogSeries(masID int, agentID int, name string, start time.Time, end time.Time) (series []schemas.LogSeries, err error)
// getAgentLogSeriesNames gets the name of the log series
getAgentLogSeriesNames(masID int, agentID int) (names []string, err error)
// deleteAgentLogMessages deletes all log messages og an agent
deleteAgentLogMessages(masID int, agentID int) (err error)
......@@ -114,7 +117,7 @@ type agentStorage struct {
msgLogs []schemas.LogMessage
statLogs []schemas.LogMessage
appLogs []schemas.LogMessage
logSeries []schemas.LogSeries
logSeries map[string][]schemas.LogSeries
state schemas.State
commData []schemas.Communication
}
......@@ -321,18 +324,51 @@ func (stor *localStorage) addAgentLogSeries(series schemas.LogSeries) {
}
}
stor.mas[series.MASID].agents[series.AgentID].logSeries = append(stor.mas[series.MASID].agents[series.AgentID].logSeries, series)
if stor.mas[series.MASID].agents[series.AgentID].logSeries == nil {
stor.mas[series.MASID].agents[series.AgentID].logSeries = make(map[string][]schemas.LogSeries)
}
stor.mas[series.MASID].agents[series.AgentID].logSeries[series.Name] = append(stor.mas[series.MASID].agents[series.AgentID].logSeries[series.Name], series)
stor.mutex.Unlock()
return
}
// getAgentLogSeries return the log series
func (stor *localStorage) getAgentLogSeries(masID int, agentID int) (series []schemas.LogSeries, err error) {
func (stor *localStorage) getAgentLogSeries(masID int, agentID int, name string, start time.Time, end time.Time) (series []schemas.LogSeries, err error) {
stor.mutex.Lock()
if masID < len(stor.mas) {
if agentID < len(stor.mas[masID].agents) {
series = make([]schemas.LogSeries, len(stor.mas[masID].agents[agentID].logSeries))
copy(series, stor.mas[masID].agents[agentID].logSeries)
length := len(stor.mas[masID].agents[agentID].logSeries[name])
if length > 0 {
startIndex := sort.Search(length,
func(i int) bool {
return stor.mas[masID].agents[agentID].logSeries[name][i].Timestamp.After(start)
})
endIndex := sort.Search(length,
func(i int) bool {
return stor.mas[masID].agents[agentID].logSeries[name][i].Timestamp.After(end)
})
if endIndex-startIndex >= 0 {
series = make([]schemas.LogSeries, endIndex-startIndex)
copy(series, stor.mas[masID].agents[agentID].logSeries[name][startIndex:endIndex])
}
}
}
}
stor.mutex.Unlock()
return
}
// getAgentLogSeriesNames gets the name of the log series
func (stor *localStorage) getAgentLogSeriesNames(masID int, agentID int) (names []string, err error) {
stor.mutex.Lock()
if masID < len(stor.mas) {
if agentID < len(stor.mas[masID].agents) {
if stor.mas[masID].agents[agentID].logSeries != nil {
names = make([]string, 0, len(stor.mas[masID].agents[agentID].logSeries))
for k := range stor.mas[masID].agents[agentID].logSeries {
names = append(names, k)
}
}
}
}
stor.mutex.Unlock()
......
......@@ -71,11 +71,11 @@ type LogMessage struct {
// LogSeries contains series data of a single agent
type LogSeries struct {
MASID int `json:"masid"` // ID of MAS agent runs in
AgentID int `json:"agentid"` // ID of agent
Timestamp time.Time `json:"timestamp"` // start time of the logSeries
Name string `json:"name"` // name of the logSeries
Value int `json:"value"` // data of the logSeries
MASID int `json:"masid"` // ID of MAS agent runs in
AgentID int `json:"agentid"` // ID of agent
Name string `json:"name"`
Timestamp time.Time `json:"timestamp"` // time of the logSeries
Value float64 `json:"value"` // value of the series item
}
// State contains the state of an agent as byte array (json)
......
......@@ -1793,6 +1793,11 @@
}
}
},
"@popperjs/core": {
"version": "2.9.2",
"resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.9.2.tgz",
"integrity": "sha512-VZMYa7+fXHdwIq1TDhSXoVmSPEGM/aa+6Aiq3nVVJ9bXr24zScr+NlKFKC3iPljA7ho/GAZr+d2jOf5GIRC30Q=="
},
"@schematics/angular": {
"version": "11.0.7",
"resolved": "https://registry.npmjs.org/@schematics/angular/-/angular-11.0.7.tgz",
......@@ -4069,6 +4074,14 @@
"lodash.debounce": "^4.0.8"
}
},
"cytoscape-popper": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/cytoscape-popper/-/cytoscape-popper-2.0.0.tgz",
"integrity": "sha512-b7WSOn8qXHWtdIXFNmrgc8qkaOs16tMY0EwtRXlxzvn8X+al6TAFrUwZoYATkYSlotfd/36ZMoeKMEoUck6feA==",
"requires": {
"@popperjs/core": "^2.0.0"
}
},
"d": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz",
......
......@@ -28,6 +28,7 @@
"@types/luxon": "^1.26.3",
"bootstrap": "^4.5.0",
"cytoscape": "^3.18.2",
"cytoscape-popper": "^2.0.0",
"install": "^0.13.0",
"luxon": "^1.26.0",
"ngx-mat-timepicker": "^11.0.5",
......
......@@ -11,21 +11,23 @@ import { LoggerComponent } from './pages/logger/logger.component';
import { DFComponent } from './pages/df/df.component';
import { TopBarComponent } from './pages/top-bar/top-bar.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { NgxMatTimepickerModule } from 'ngx-mat-timepicker';
import { NgxChartsModule } from '@swimlane/ngx-charts';
import { MatDatepickerModule } from '@angular/material/datepicker';
import { MatNativeDateModule } from '@angular/material/core/';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { NgxMatTimepickerModule } from 'ngx-mat-timepicker';
import { MatIconModule } from '@angular/material/icon';
import { NgxChartsModule } from '@swimlane/ngx-charts'
import { MatSelectModule } from '@angular/material/select';
import { MatIconModule } from '@angular/material/icon';
const materialModules = [
MatDatepickerModule,
MatNativeDateModule,
MatFormFieldModule,
MatInputModule,
MatIconModule
MatIconModule,
MatSelectModule
];
@NgModule({
......
......@@ -85,9 +85,13 @@
<td>{{res.agentid}}</td>
</tr>
<tr>
<th>NODE ID</th>
<th>Node ID</th>
<td>{{res.nodeid}}</td>
</tr>
<tr>
<th>Description</th>
<td>{{res.desc}}</td>
</tr>
<tr>
<th>Create Date</th>
<td>{{res.createdat}}</td>
......
......@@ -4,8 +4,10 @@ import { MasService} from "src/app/services/mas.service";
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { ActivatedRoute, Params } from '@angular/router';
import * as cytoscape from 'cytoscape';
import popper from 'cytoscape-popper';
import { forkJoin, Observable } from 'rxjs';
import { truncate } from 'node:fs';
cytoscape.use( popper);
@Component({
selector: 'app-df',
......@@ -71,11 +73,12 @@ export class DFComponent implements OnInit {
reqNode: this.masService.getMASById(this.selectedMASID.toString()),
reqSvc: this.dfService.getAllSvcs(this.selectedMASID.toString())
}).subscribe(({ reqNode, reqSvc } : any ) => {
console.log(reqSvc)
let nodes = reqNode.graph.node.map(node => node.id);
let agents = reqNode.agents.instances.map(agent => agent.id);
let edgeNodes = reqNode.graph.edge;
let edgeAgentNode = [];
let svcs = [];
let svcs: string[] = [];
let edgeSvcAgent = [];
for (let i = 0; i < reqNode.graph.node.length; i++) {
for (let j = 0; j < reqNode.graph.node[i].agents.length; j++) {
......@@ -86,7 +89,7 @@ export class DFComponent implements OnInit {
}
}
for (let i = 0; i < reqSvc.length; i++) {
svcs.push(i);
svcs.push(reqSvc[i].desc);
edgeSvcAgent.push({
n1: i,
n2: reqSvc[i].agentid,
......@@ -147,7 +150,7 @@ export class DFComponent implements OnInit {
selector: 'node',
style: {
'background-color': "#9696f3",
label: 'data(id)',
label: 'data(name)',
"text-halign": 'center',
"text-valign": 'center',
}
......@@ -192,7 +195,7 @@ export class DFComponent implements OnInit {
data: {
id: 'node' + res.nodes[i],
name: res.nodes[i].toString(),
name: 'node' + res.nodes[i].toString(),
}
});
}
......@@ -202,7 +205,7 @@ export class DFComponent implements OnInit {
classes: 'agent',
data: {
id: 'agent' + res.agents[i],
name: res.agents[i].toString(),
name: 'agent' + res.agents[i].toString(),
}
});
}
......@@ -211,8 +214,8 @@ export class DFComponent implements OnInit {
this.graph.add({
classes: 'svc',