Skip to content

Commit

Permalink
Resolve "Cannot monitor maps"
Browse files Browse the repository at this point in the history
  • Loading branch information
syifan committed Jun 26, 2022
1 parent f470237 commit ca5e3f9
Show file tree
Hide file tree
Showing 19 changed files with 36,630 additions and 460 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ debug

# Prof file
*.prof

.DS_Store

.vscode/*.log
1 change: 0 additions & 1 deletion .vscode/configurationCache.log

This file was deleted.

12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ require (
github.com/go-sql-driver/mysql v1.6.0
github.com/golang/mock v1.4.4
github.com/gorilla/mux v1.8.0
github.com/onsi/ginkgo/v2 v2.1.3
github.com/onsi/gomega v1.17.0
github.com/onsi/ginkgo/v2 v2.1.4
github.com/onsi/gomega v1.19.0
github.com/rs/xid v1.2.1
github.com/syifan/goseth v0.0.4
github.com/syifan/goseth v0.1.0
github.com/tebeka/atexit v0.3.0
go.mongodb.org/mongo-driver v1.8.4
)
Expand All @@ -22,10 +22,10 @@ require (
github.com/xdg-go/stringprep v1.0.2 // indirect
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
golang.org/x/crypto v0.0.0-20201216223049-8b5274cf687f // indirect
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781 // indirect
golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 // indirect
golang.org/x/sys v0.0.0-20210423082822-04245dca01da // indirect
golang.org/x/text v0.3.6 // indirect
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8 // indirect
golang.org/x/text v0.3.7 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)

Expand Down
110 changes: 14 additions & 96 deletions go.sum

Large diffs are not rendered by default.

25 changes: 16 additions & 9 deletions monitoring/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"log"
"net"
"net/http"
"os"
"reflect"
"sort"
"strconv"
Expand Down Expand Up @@ -126,7 +127,9 @@ func (m *Monitor) StartServer() {
listener, err := net.Listen("tcp", ":0")
dieOnErr(err)

fmt.Printf("Monitoring simulation with http://localhost:%d\n",
fmt.Fprintf(
os.Stderr,
"Monitoring simulation with http://localhost:%d\n",
listener.Addr().(*net.TCPAddr).Port)

go func() {
Expand Down Expand Up @@ -202,8 +205,11 @@ func (m *Monitor) listComponentDetails(w http.ResponseWriter, r *http.Request) {
return
}

serializer := goseth.NewInteractiveSerializer()
err := serializer.Serialize(component, w)
serializer := goseth.NewSerializer()
serializer.SetRoot(component)
serializer.SetMaxDepth(1)
err := serializer.Serialize(w)

dieOnErr(err)
}

Expand All @@ -222,20 +228,21 @@ func (m *Monitor) listFieldValue(w http.ResponseWriter, r *http.Request) {
}

name := req.CompName
fields := req.FieldName
fields := strings.Split(req.FieldName, ".")

component := m.findComponentOr404(w, name)
if component == nil {
return
}

elem, err := m.walkFields(component, fields)
serializer := goseth.NewSerializer()
serializer.SetRoot(component)
serializer.SetMaxDepth(1)

err = serializer.SetEntryPoint(fields)
dieOnErr(err)

serializer := goseth.NewInteractiveSerializer()
elemCopy := reflect.NewAt(
elem.Type(), unsafe.Pointer(elem.UnsafeAddr())).Elem()
err = serializer.Serialize(elemCopy.Interface(), w)
err = serializer.Serialize(w)
dieOnErr(err)
}

Expand Down
3 changes: 3 additions & 0 deletions monitoring/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions monitoring/readme.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# Akita Monitoring Tool

Akita Monitoring Tool is a toolset allow user to monitor the simulation status during the simulation is running. It also provides simple solutions that users to interact with the simulation.
Akita Monitoring Tool is a tool that allows users to monitor the simulation status while the simulation is running. It also provides simple solutions for users to control the running simulation.

## Use

If you want to develop a simulator and want it to support real-time monitoring, you can initiate the monitor in your configuration code. You also need to register the simulator engine with the `RegisterEngine` function of the `Monitor` struct and all the components that you want to monitor with the `RegisterComponent` function of the`Monitor` struct.
If you want to develop a simulator that supports real-time monitoring, you can initiate the monitor in your configuration code. You also need to register the simulator engine with the `RegisterEngine` function of the `Monitor` struct. Also, you need to register all the components that you want to monitor with the `RegisterComponent` function of the `Monitor` struct.

Before the simulation starts, call the `StartServer` function of the monitor. A web server will be hosted and the port will be printed to standard output.
Before the simulation starts, call the `StartServer` function of the monitor. A web server will be hosted and the port will be printed to standard error output.

You can use a web browser to access the monitoring tool hosted at the given port.

## Develop
## Development

1. Make sure you have NodeJS and npm installed.
2. In the web folder, type `npm install` to install dependencies.
3. In the web folder, run `npm run watch` to use webpack to build static assets.
4. Set environment variable `AKITA_MONITOR_DEV` to the `true` to enable the development. In development mode, your modification to the frontend code will be reflected without recompiling the simulation.
3. In the web folder, run `npm run watch` to use Webpack to build static assets.
4. Set environment variable `AKITA_MONITOR_DEV` to the `true` to enable the development mode. In development mode, your modification to the frontend code will be reflected without recompiling the simulation.
Loading

0 comments on commit ca5e3f9

Please sign in to comment.