scoringmgr/myscoring: change default scoring lib 08/203408/1 accepted/tizen/unified/20190415.132602 submit/tizen/20190412.085618 submit/tizen/20190415.051353
authorwansuyoo <wansu.yoo@samsung.com>
Fri, 12 Apr 2019 08:45:35 +0000 (17:45 +0900)
committerwansuyoo <wansu.yoo@samsung.com>
Fri, 12 Apr 2019 08:47:20 +0000 (17:47 +0900)
disable network resource checking (temporarily)
add force option at linking scoring lib

Change-Id: I4302284ce0ae420994bfa2675f00d2d6cefb3ae2
Signed-off-by: wansuyoo <wansu.yoo@samsung.com>
packaging/edge-orchestration.spec
src/scoringmgr/mock/myscoring/Makefile
src/scoringmgr/mock/myscoring/myscoring.c
src/scoringmgr/mock/myscoring/myscoring.conf

index 9bc0b5e..506ad2e 100755 (executable)
@@ -93,7 +93,7 @@ systemctl daemon-reload
 systemctl restart %{name}
 
 %post -n libedge-orchestration
-ln -s %{_sysconfdir}/%{name}/myscoring/libmyscoring.so.1.0.1 %{_sysconfdir}/%{name}/myscoring/libmyscoring.so
+ln -sf %{_sysconfdir}/%{name}/myscoring/libmyscoring.so.1.0.1 %{_sysconfdir}/%{name}/myscoring/libmyscoring.so
 
 %files
 %manifest %{name}.manifest
index bf730d1..a2cae8f 100644 (file)
@@ -17,7 +17,7 @@ all: clean build
 build:
        $(CC) -fPIC -c $(SRC_FILES)
        $(CC) -shared -o $(LIBRARY_FILE).$(LIBRARY_VER) $(OBJ_FILES) -lm
-       ln -s $(LIBRARY_FILE).$(LIBRARY_VER) $(LIBRARY_FILE)
+       ln -sf $(LIBRARY_FILE).$(LIBRARY_VER) $(LIBRARY_FILE)
        -rm -f $(OBJ_FILES)
 
 clean:
index 90c4e7a..e4eedd3 100644 (file)
@@ -81,3 +81,33 @@ double myscoring2(double (*getResource)(const char *))
 
   return score;
 }
+
+#define MY_SCORING_3_CNT 4
+double myscoring3(double (*getResource)(const char *))
+{
+
+  printf("myscoring\n");
+
+  double score;
+  const char *resourceNames[MY_SCORING_3_CNT] = {"cpu/usage", "cpu/count", "memory/free", "memory/available"};
+  double W[MY_SCORING_3_CNT] =                  {1.48271,     4.125421,    5.3381723,     9.194717234};
+  double resourceValues[MY_SCORING_3_CNT];
+
+  // double someResource;
+  // someResource = getResource("some/usage");
+  // assert(isnan(someResource));
+
+  for (int i = 0; i < MY_SCORING_3_CNT; i++)
+  {
+    resourceValues[i] = getResource(resourceNames[i]);
+    printf("resourceNames : %s %f\n", resourceNames[i], resourceValues[i]);
+  }
+
+  score = 0.0;
+  for (int i = 0; i < MY_SCORING_3_CNT; i++)
+  {
+    score += resourceValues[i] * W[i];
+  }
+
+  return score;
+}
index 9f8ee04..bd84c46 100644 (file)
@@ -7,7 +7,7 @@ ServiceName=ls                              ; Name of distributed service
 
 [ScoringMethod]
 LibFile=./libmyscoring.so                               ; Library file name
-FunctionName=myscoring
+FunctionName=myscoring3
 
 [ResourceType]
 IntervalTimeMs=1000                                     ; Interval time of get resource