myscoring, myscoring2 : enhancement 26/203226/1
authorjaehoon.hyun <jaehoon.hyun@samsung.com>
Thu, 11 Apr 2019 02:02:46 +0000 (11:02 +0900)
committerjaehoon.hyun <jaehoon.hyun@samsung.com>
Thu, 11 Apr 2019 02:02:46 +0000 (11:02 +0900)
Change-Id: I43fc81406c655470617641ac2b14ac7d263e1436

src/orchestrationapi/mock/myscoring [new symlink]
src/orchestrationapi/mock/myscoring2 [new symlink]
src/scoringmgr/mock/myscoring/myscoring/libmyscoring.so [new symlink]
src/scoringmgr/mock/myscoring/myscoring/libmyscoring.so.1.0.1 [new file with mode: 0755]
src/scoringmgr/mock/myscoring/myscoring/myscoring.c [new file with mode: 0644]
src/scoringmgr/mock/myscoring/myscoring/myscoring.conf [new file with mode: 0644]
src/scoringmgr/mock/myscoring2/libmyscoring.so.1.0.1 [new file with mode: 0755]
src/scoringmgr/mock/myscoring2/libmyscoring2.so [new symlink]
src/scoringmgr/mock/myscoring2/myscoring.c [new file with mode: 0644]
src/scoringmgr/mock/myscoring2/myscoring2.conf [new file with mode: 0644]

diff --git a/src/orchestrationapi/mock/myscoring b/src/orchestrationapi/mock/myscoring
new file mode 120000 (symlink)
index 0000000..68465f1
--- /dev/null
@@ -0,0 +1 @@
+../../scoringmgr/mock/myscoring
\ No newline at end of file
diff --git a/src/orchestrationapi/mock/myscoring2 b/src/orchestrationapi/mock/myscoring2
new file mode 120000 (symlink)
index 0000000..37d057d
--- /dev/null
@@ -0,0 +1 @@
+../../scoringmgr/mock/myscoring2
\ No newline at end of file
diff --git a/src/scoringmgr/mock/myscoring/myscoring/libmyscoring.so b/src/scoringmgr/mock/myscoring/myscoring/libmyscoring.so
new file mode 120000 (symlink)
index 0000000..50bdf3c
--- /dev/null
@@ -0,0 +1 @@
+libmyscoring.so.1.0.1
\ No newline at end of file
diff --git a/src/scoringmgr/mock/myscoring/myscoring/libmyscoring.so.1.0.1 b/src/scoringmgr/mock/myscoring/myscoring/libmyscoring.so.1.0.1
new file mode 100755 (executable)
index 0000000..582a2f0
Binary files /dev/null and b/src/scoringmgr/mock/myscoring/myscoring/libmyscoring.so.1.0.1 differ
diff --git a/src/scoringmgr/mock/myscoring/myscoring/myscoring.c b/src/scoringmgr/mock/myscoring/myscoring/myscoring.c
new file mode 100644 (file)
index 0000000..90c4e7a
--- /dev/null
@@ -0,0 +1,83 @@
+
+/*
+$ gcc -fPIC -c myscoring.c && gcc -shared -o libmyscoring.so.1.0.1 myscoring.o -lm
+$ ln -rs libmyscoring.so.1.0.1 libmyscoring.so
+*/
+
+#include <math.h>
+#include <assert.h>
+#include <stdio.h>
+
+#define CNT 6
+
+/*
+features :
+-. there is using moving average, but it is not written code at service_provider.cpp
+-. bandwidth is not meaning Mbps
+*/
+
+//network score mmDiscovery/service_provider.cpp
+static double networkScore(double n) {
+  return 1 / (8770 * pow(n, -0.9));
+}
+
+//cpu score mmDiscovery/service_provider.cpp
+static double cpuScore(double freq, double usage, double count){
+ return ((1 / (5.66 * pow(freq, -0.66))) +
+          (1 / (3.22 * pow(usage, -0.241))) +
+          (1 / (4 * pow(count, -0.3)))) / 3;
+}
+
+//render score mmDiscovery/service_provider.cpp
+//https://github.com/Samsung/Castanets/blob/castanets_63/service_discovery_manager/Component/mmDiscovery/monitor_client.cpp
+static double renderingScore(double r) {
+  return (r < 0) ? 0 : 0.77 * pow(r, -0.43);
+}
+
+//============== INTERFACE API ==============
+double myscoring(double (*getResource)(const char *))
+{
+  
+  printf("myscoring\n");
+  double score;
+  
+  
+  score = 0.0;
+  score += networkScore(getResource("network/bandwidth"));
+  score += cpuScore(getResource("cpu/freq"), getResource("cpu/usage"), getResource("cpu/count"));
+  score /= 2;
+  score += renderingScore(getResource("network/rtt"));
+
+  return score;
+}
+
+#define CNT 6
+
+double myscoring2(double (*getResource)(const char *))
+{
+
+  printf("myscoring\n");
+
+  double score;
+  const char *resourceNames[CNT] = {"cpu/usage", "cpu/count", "memory/free", "memory/available", "network/mbps", "network/bandwidth"};
+  double W[CNT] =                  {1.48271,     4.125421,    5.3381723,     9.194717234,        2.323,          1.123};
+  double resourceValues[CNT];
+
+  // double someResource;
+  // someResource = getResource("some/usage");
+  // assert(isnan(someResource));
+
+  for (int i = 0; i < CNT; i++)
+  {
+    resourceValues[i] = getResource(resourceNames[i]);
+    printf("resourceNames : %s %f\n", resourceNames[i], resourceValues[i]);
+  }
+
+  score = 0.0;
+  for (int i = 0; i < CNT; i++)
+  {
+    score += resourceValues[i] * W[i];
+  }
+
+  return score;
+}
diff --git a/src/scoringmgr/mock/myscoring/myscoring/myscoring.conf b/src/scoringmgr/mock/myscoring/myscoring/myscoring.conf
new file mode 100644 (file)
index 0000000..9f8ee04
--- /dev/null
@@ -0,0 +1,14 @@
+# Description of service that will be requested
+[Version]
+ConfVersion=v0.0                                        ; Version of Configuration file
+
+[ServiceInfo]
+ServiceName=ls                              ; Name of distributed service
+
+[ScoringMethod]
+LibFile=./libmyscoring.so                               ; Library file name
+FunctionName=myscoring
+
+[ResourceType]
+IntervalTimeMs=1000                                     ; Interval time of get resource
+MaxCount=10                                             ; Number of times
diff --git a/src/scoringmgr/mock/myscoring2/libmyscoring.so.1.0.1 b/src/scoringmgr/mock/myscoring2/libmyscoring.so.1.0.1
new file mode 100755 (executable)
index 0000000..582a2f0
Binary files /dev/null and b/src/scoringmgr/mock/myscoring2/libmyscoring.so.1.0.1 differ
diff --git a/src/scoringmgr/mock/myscoring2/libmyscoring2.so b/src/scoringmgr/mock/myscoring2/libmyscoring2.so
new file mode 120000 (symlink)
index 0000000..50bdf3c
--- /dev/null
@@ -0,0 +1 @@
+libmyscoring.so.1.0.1
\ No newline at end of file
diff --git a/src/scoringmgr/mock/myscoring2/myscoring.c b/src/scoringmgr/mock/myscoring2/myscoring.c
new file mode 100644 (file)
index 0000000..85ea3a9
--- /dev/null
@@ -0,0 +1,86 @@
+
+/*
+$ gcc -fPIC -c myscoring.c && gcc -shared -o -lm libmyscoring.so.1.0.1 myscoring.o -lm
+$ ln -rs libmyscoring.so.1.0.1 libmyscoring.so
+*/
+
+#include <math.h>
+#include <assert.h>
+#include <stdio.h>
+
+#define CNT 6
+
+/*
+features :
+-. there is using moving average, but it is not written code at service_provider.cpp
+-. bandwidth is not meaning Mbps
+*/
+
+//network score mmDiscovery/service_provider.cpp
+static double networkScore(double n)
+{
+  return 1 / (8770 * pow(n, -0.9));
+}
+
+//cpu score mmDiscovery/service_provider.cpp
+static double cpuScore(double freq, double usage, double count)
+{
+  return ((1 / (5.66 * pow(freq, -0.66))) +
+          (1 / (3.22 * pow(usage, -0.241))) +
+          (1 / (4 * pow(count, -0.3)))) /
+         3;
+}
+
+//render score mmDiscovery/service_provider.cpp
+//https://github.com/Samsung/Castanets/blob/castanets_63/service_discovery_manager/Component/mmDiscovery/monitor_client.cpp
+static double renderingScore(double r)
+{
+  return (r < 0) ? 0 : 0.77 * pow(r, -0.43);
+}
+
+//============== INTERFACE API ==============
+double myscoring(double (*getResource)(const char *))
+{
+
+  printf("myscoring\n");
+  double score;
+
+  score = 0.0;
+  score += networkScore(getResource("network/bandwidth"));
+  score += cpuScore(getResource("cpu/freq"), getResource("cpu/usage"), getResource("cpu/count"));
+  score /= 2;
+  score += renderingScore(getResource("network/rtt"));
+
+  return score;
+}
+
+#define CNT 6
+
+double myscoring2(double (*getResource)(const char *))
+{
+
+  printf("myscoring\n");
+
+  double score;
+  const char *resourceNames[CNT] = {"cpu/usage", "cpu/count", "memory/free", "memory/available", "network/mbps", "network/bandwidth"};
+  double W[CNT] = {1.48271, 4.125421, 5.3381723, 9.194717234, 2.323, 1.123};
+  double resourceValues[CNT];
+
+  // double someResource;
+  // someResource = getResource("some/usage");
+  // assert(isnan(someResource));
+
+  for (int i = 0; i < CNT; i++)
+  {
+    resourceValues[i] = getResource(resourceNames[i]);
+    printf("resourceNames : %s %f\n", resourceNames[i], resourceValues[i]);
+  }
+
+  score = 0.0;
+  for (int i = 0; i < CNT; i++)
+  {
+    score += resourceValues[i] * W[i];
+  }
+
+  return score;
+}
diff --git a/src/scoringmgr/mock/myscoring2/myscoring2.conf b/src/scoringmgr/mock/myscoring2/myscoring2.conf
new file mode 100644 (file)
index 0000000..abf934d
--- /dev/null
@@ -0,0 +1,14 @@
+# Description of service that will be requested
+[Version]
+ConfVersion=v0.0                                        ; Version of Configuration file
+
+[ServiceInfo]
+ServiceName=ll                              ; Name of distributed service
+
+[ScoringMethod]
+LibFile=./libmyscoring.so                               ; Library file name
+FunctionName=myscoring2
+
+[ResourceType]
+IntervalTimeMs=1000                                     ; Interval time of get resource
+MaxCount=10                                             ; Number of times