summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjaehoon.hyun <jaehoon.hyun@samsung.com>2019-03-29 18:13:01 +0900
committerjaehoon.hyun <jaehoon.hyun@samsung.com>2019-03-29 18:13:01 +0900
commit0a320dc256f5081c0615c8c5570c33f8b7d2de9f (patch)
treeac4ea7928b892c3e6b94dd1d1790e0dd29db2182
parent6bb8ce28ef602f1afcdbbb7ebd92ea76c3ae7b67 (diff)
downloadedge-orchestration-0a320dc256f5081c0615c8c5570c33f8b7d2de9f.tar.gz
edge-orchestration-0a320dc256f5081c0615c8c5570c33f8b7d2de9f.tar.bz2
edge-orchestration-0a320dc256f5081c0615c8c5570c33f8b7d2de9f.zip
change interface scoringmgr, configuremgr
-rw-r--r--src/configuremgr/configuremgr_test.go10
-rw-r--r--src/configuremgr/description/doc.go27
-rw-r--r--src/configuremgr/watchConfPath.go23
-rw-r--r--src/scoringmgr/handlers.go5
-rw-r--r--src/scoringmgr/scoringmgr_test.go4
5 files changed, 39 insertions, 30 deletions
diff --git a/src/configuremgr/configuremgr_test.go b/src/configuremgr/configuremgr_test.go
index 5a38180..538510d 100644
--- a/src/configuremgr/configuremgr_test.go
+++ b/src/configuremgr/configuremgr_test.go
@@ -23,11 +23,11 @@ func TestBasicMockConfigureMgr(t *testing.T){
//mock function
//test object
- configuremgrObj := new(configuremgr.ConfigureMgr)
- configuremgrObj.IDeviceDiscoveryMgr.PushConfPath = mockconfiguremgr.PushConfPathDiscoveryDeviceMock
- configuremgrObj.IAppExecuteMgr.PushConfPath = mockconfiguremgr.PushConfPathAppExecuteMock
- configuremgrObj.IScoringMgr.PushLibPath = mockconfiguremgr.PushLibPathScoringAppMock
- configuremgrObj.Done = make(chan bool)
+ configuremgrObj := configuremgr.Init()
+ configuremgrObj.IDeviceDiscoveryMgr.PushConfPath = mockconfiguremgr.PushConfPathDiscoveryDeviceMock
+ configuremgrObj.IAppExecuteMgr.PushConfPath = mockconfiguremgr.PushConfPathAppExecuteMock
+ configuremgrObj.IScoringMgr.PushLibPath = mockconfiguremgr.PushLibPathScoringAppMock
+
go configuremgrObj.Watch(watchDir)
diff --git a/src/configuremgr/description/doc.go b/src/configuremgr/description/doc.go
index 7d9a2d4..4dad6f1 100644
--- a/src/configuremgr/description/doc.go
+++ b/src/configuremgr/description/doc.go
@@ -1,19 +1,18 @@
package confdescription
type Doc struct {
- Version struct {
- ConfVersion string
- }
- ServiceInfo struct {
- ServiceName string
- }
- ResourceType struct {
- IntervalTimeMs int
- MaxCount int
- }
-
- ScoringMethod struct {
- LibFile string
- }
+ Version struct {
+ ConfVersion string
+ }
+ ServiceInfo struct {
+ ServiceName string
+ }
+ ResourceType struct {
+ IntervalTimeMs int
+ MaxCount int
+ }
+ ScoringMethod struct {
+ LibFile string
+ }
} \ No newline at end of file
diff --git a/src/configuremgr/watchConfPath.go b/src/configuremgr/watchConfPath.go
index 8e955d3..9828707 100644
--- a/src/configuremgr/watchConfPath.go
+++ b/src/configuremgr/watchConfPath.go
@@ -13,21 +13,30 @@ import (
type ConfigureMgr struct {
- IDeviceDiscoveryMgr struct {
+ IDiscoveryMgr struct {
PushConfPath func(*confdescription.Doc) (error)
}
IAppExecuteMgr struct {
- PushConfPath func(*confdescription.Doc) (error)
+ // PushConfPath func(*confdescription.Doc) (error)
+ // ExecuteApp func(target string, name string, args []string, notiChan chan string) (serviceID uint64, err error)
}
IScoringMgr struct {
- PushLibPath func(libPath string) (error)
+ PushLibPath func(libPath string, doc *confdescription.Doc, handlersCh chan<- interface{}) (error)
+ Ch chan interface{}
}
Done chan bool
}
+func Init() (configuremgrObj *ConfigureMgr) {
+ configuremgrObj = new(ConfigureMgr)
+ configuremgrObj.Done = make(chan bool)
+
+ return
+}
+
func (cfgMgr *ConfigureMgr) installConfigure(path string) {
//1. libPath, conf := diretoryname get
@@ -39,9 +48,9 @@ func (cfgMgr *ConfigureMgr) installConfigure(path string) {
libPath, confPath := cfgMgr.getdirname(path)
sconf.Must(cfg).Read(ini.File(confPath))
- cfgMgr.IScoringMgr.PushLibPath(libPath)
- cfgMgr.IDeviceDiscoveryMgr.PushConfPath(cfg)
- cfgMgr.IAppExecuteMgr.PushConfPath(cfg)
+ cfgMgr.IScoringMgr.PushLibPath(libPath, cfg, cfgMgr.IScoringMgr.Ch)
+ cfgMgr.IDiscoveryMgr.PushConfPath(cfg)
+ // cfgMgr.IAppExecuteMgr.PushConfPath(cfg)
}
@@ -81,7 +90,7 @@ func (cfgMgr *ConfigureMgr) Watch(path string) {
return
}
- ELog.Println("log event:", event)
+ ILog.Println("log event:", event)
if event.Op & fsnotify.Create == fsnotify.Create {
cfgMgr.installConfigure(event.Name)
}
diff --git a/src/scoringmgr/handlers.go b/src/scoringmgr/handlers.go
index b730181..4bb6f58 100644
--- a/src/scoringmgr/handlers.go
+++ b/src/scoringmgr/handlers.go
@@ -22,6 +22,7 @@ type Handlers struct {
Ch chan interface{}
IloadScoringLibrary func (string, int) ()
+ GetScore func (string) float64
}
@@ -35,6 +36,8 @@ func Init() (handlers *Handlers){
//TODO : async notify lib loading
func PushLibPath(libPath string, doc *confdescription.Doc, handlersCh chan<- interface{}) (err error){
+ ILog.Printf("input PushLibPath : %s", libPath)
+
handlersCh <- pair{libPath, doc}
return nil
}
@@ -48,7 +51,7 @@ func (handlers *Handlers) Listening() {
select {
case obj := <- handlers.Ch :
-
+ ILog.Printf("input handlers.Ch from configuremgr")
handlerObj := handlers.makeHandler(obj.(pair))
handlers.runScoring(handlerObj)
}
diff --git a/src/scoringmgr/scoringmgr_test.go b/src/scoringmgr/scoringmgr_test.go
index 8dbc174..a22cf3a 100644
--- a/src/scoringmgr/scoringmgr_test.go
+++ b/src/scoringmgr/scoringmgr_test.go
@@ -21,7 +21,7 @@ func TestBasicMockScoringMgr(t *testing.T){
scoringHandlers.Listening()
- time.Sleep(time.Duration(1 * time.Second))
+ time.Sleep(time.Duration(1) * time.Second)
libPath := "mock/mysum/libmysum.so"
confPath := "mock/mysum/mysum.conf"
@@ -33,6 +33,4 @@ func TestBasicMockScoringMgr(t *testing.T){
time.Sleep(time.Duration(5) * time.Second)
-
-
} \ No newline at end of file