summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukasz Stanislawski <l.stanislaws@samsung.com>2018-07-25 15:03:24 +0200
committerLukasz Stanislawski <l.stanislaws@samsung.com>2018-07-25 15:03:24 +0200
commit276b5c4ce8738a8bbd1b96a146114acbec5f1d60 (patch)
treeaee018fcd700a77cb4ad8f0fdab47e2466f9340e
parent5a86c1f3619a30dc06f7133294b0b43975dffa1c (diff)
downloadttsd-worker-task-276b5c4ce8738a8bbd1b96a146114acbec5f1d60.tar.gz
ttsd-worker-task-276b5c4ce8738a8bbd1b96a146114acbec5f1d60.tar.bz2
ttsd-worker-task-276b5c4ce8738a8bbd1b96a146114acbec5f1d60.zip
remove unsued code after refactor
Change-Id: I8d08ab69d195bbee5aea8abd915b9342fa0fda8b
-rw-r--r--src/CMakeLists.txt3
-rw-r--r--src/appinfo-provider.h1
-rw-r--r--src/generators/report-generator.c (renamed from src/report-generator.c)0
-rw-r--r--src/generators/report-generator.h (renamed from src/report-generator.h)3
-rw-r--r--src/report-json-serializer.c246
-rw-r--r--src/report-json-serializer.h102
-rw-r--r--src/report.h68
-rw-r--r--src/task-factory.c1
8 files changed, 1 insertions, 423 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index eabedc8..f73c325 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -18,19 +18,18 @@ SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
SET(SRCS
task-worker.c
procfs.c
- report-generator.c
worker.c
task-factory.c
task.c
scheduler.c
config-deserializer.c
appinfo-provider.c
- report-json-serializer.c
sys-stats.c
clock.c
ipc.c
process.c
proc-scanner.c
+ generators/report-generator.c
generators/report-generator-system.c
generators/report-generator-load-avg.c
generators/report-generator-process.c
diff --git a/src/appinfo-provider.h b/src/appinfo-provider.h
index ac1c0be..8eef00a 100644
--- a/src/appinfo-provider.h
+++ b/src/appinfo-provider.h
@@ -17,7 +17,6 @@
#ifndef __APPINFO_PROVIDER_H_
#define __APPINFO_PROVIDER_H_
-#include "report.h"
#include <stdbool.h>
/**
diff --git a/src/report-generator.c b/src/generators/report-generator.c
index 5f28560..5f28560 100644
--- a/src/report-generator.c
+++ b/src/generators/report-generator.c
diff --git a/src/report-generator.h b/src/generators/report-generator.h
index 6cf6c22..b7504dd 100644
--- a/src/report-generator.h
+++ b/src/generators/report-generator.h
@@ -20,9 +20,6 @@
#include <json-glib/json-glib.h>
#include <stdbool.h>
-#include "process.h"
-#include "report.h"
-
typedef struct report_generator report_generator_t;
/**
diff --git a/src/report-json-serializer.c b/src/report-json-serializer.c
deleted file mode 100644
index 949d82c..0000000
--- a/src/report-json-serializer.c
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <json-glib/json-glib.h>
-
-#include "report-json-serializer.h"
-#include "json-schema-defs.h"
-
-static char *_serialize(JsonBuilder *builder)
-{
- JsonGenerator *gen = json_generator_new();
- if (!gen) {
- g_object_unref(builder);
- return NULL;
- }
-
- JsonNode *root = json_builder_get_root(builder);
- json_generator_set_root(gen, root);
- char *str = json_generator_to_data(gen, NULL);
- g_object_unref(gen);
- return str;
-}
-
-#define IMPLEMENT_SERIALIZER_FUNC(func_name, param_type, serializer) \
-char* \
-func_name(param_type *report) \
-{\
- JsonBuilder *builder = json_builder_new(); \
- if (!builder) return NULL; \
- serializer(builder, report); \
- char *ret = _serialize(builder); \
- g_object_unref(builder); \
- return ret; \
-}
-
-#define IMPLEMENT_ARRAY_SERIALIZER_FUNC(func_name, param_type, serializer) \
-char* \
-func_name(param_type *reports, int len) \
-{\
- JsonBuilder *builder = json_builder_new(); \
- if (!builder) return NULL; \
- serializer(builder, reports, len); \
- char *ret = _serialize(builder); \
- g_object_unref(builder); \
- return ret; \
-}
-
-static void system_load_average_report_to_json_object(JsonBuilder *builder, struct system_load_average_report *report)
-{
- json_builder_begin_object(builder);
-
- json_builder_set_member_name(builder, SCHEMA_TYPE);
- json_builder_add_string_value(builder, SCHEMA_TYPE_LOAD_AVG);
-
- json_builder_set_member_name(builder, SCHEMA_RESULT_DATA_LOAD_AVG);
- json_builder_begin_object(builder);
-
- json_builder_set_member_name(builder, SCHEMA_RESULT_TIME);
- json_builder_add_int_value(builder, report->time);
- json_builder_set_member_name(builder, SCHEMA_RESULT_AVG_ONE);
- json_builder_add_double_value(builder, report->one_min_avg);
- json_builder_set_member_name(builder, SCHEMA_RESULT_AVG_FIVE);
- json_builder_add_double_value(builder, report->five_min_avg);
- json_builder_set_member_name(builder, SCHEMA_RESULT_AVG_FIFTEEN);
- json_builder_add_double_value(builder, report->fifteen_min_avg);
-
- json_builder_end_object(builder);
-
- json_builder_end_object(builder);
-}
-
-static void system_report_to_json_object(JsonBuilder *builder, struct system_report *report)
-{
- json_builder_begin_object(builder);
-
- json_builder_set_member_name(builder, SCHEMA_TYPE);
- json_builder_add_string_value(builder, SCHEMA_TYPE_SYSTEM);
-
- json_builder_set_member_name(builder, SCHEMA_RESULT_DATA_SYSTEM);
- json_builder_begin_object(builder);
-
- json_builder_set_member_name(builder, SCHEMA_RESULT_TIME);
- json_builder_add_int_value(builder, report->time);
-
- json_builder_set_member_name(builder, SCHEMA_RESULT_CPU);
- json_builder_add_double_value(builder, report->cpu);
-
- json_builder_set_member_name(builder, SCHEMA_RESULT_MEMORY);
- json_builder_add_double_value(builder, report->memory);
-
- json_builder_end_object(builder);
-
- json_builder_end_object(builder);
-}
-
-static void top_cpu_usage_reports_to_json_object(JsonBuilder *builder, struct process_usage_report *reports, int len)
-{
- json_builder_begin_object(builder);
-
- json_builder_set_member_name(builder, SCHEMA_TYPE);
- json_builder_add_string_value(builder, SCHEMA_TYPE_TOP);
-
- json_builder_set_member_name(builder, SCHEMA_TARGET);
- json_builder_add_string_value(builder, SCHEMA_TARGET_CPU);
-
- json_builder_set_member_name(builder, SCHEMA_RESULT_DATA_TOP);
- json_builder_begin_array(builder);
-
- for (int i = 0; i < len; ++i)
- {
- json_builder_begin_object(builder);
-
- json_builder_set_member_name(builder, SCHEMA_ID);
- json_builder_add_string_value(builder, reports[i].app_id);
-
- json_builder_set_member_name(builder, SCHEMA_RESULT_PID);
- json_builder_add_int_value(builder, reports[i].pid);
-
- json_builder_set_member_name(builder, SCHEMA_RESULT_RESULT);
- json_builder_begin_object(builder);
-
- json_builder_set_member_name(builder, SCHEMA_RESULT_TIME);
- json_builder_add_int_value(builder, reports[i].time);
- json_builder_set_member_name(builder, SCHEMA_RESULT_USAGE);
- json_builder_add_double_value(builder, reports[i].usage);
-
- json_builder_end_object(builder);
-
- json_builder_end_object(builder);
- }
-
- json_builder_end_array(builder);
- json_builder_end_object(builder);
-}
-
-static void top_memory_usage_reports_to_json_object(JsonBuilder *builder, struct process_usage_report *reports, int len)
-{
- json_builder_begin_object(builder);
-
- json_builder_set_member_name(builder, SCHEMA_TYPE);
- json_builder_add_string_value(builder, SCHEMA_TYPE_TOP);
-
- json_builder_set_member_name(builder, SCHEMA_TARGET);
- json_builder_add_string_value(builder, SCHEMA_TARGET_MEMORY);
-
- json_builder_set_member_name(builder, SCHEMA_RESULT_DATA_TOP);
- json_builder_begin_array(builder);
-
- for (int i = 0; i < len; ++i)
- {
- json_builder_begin_object(builder);
-
- json_builder_set_member_name(builder, SCHEMA_ID);
- json_builder_add_string_value(builder, reports[i].app_id);
-
- json_builder_set_member_name(builder, SCHEMA_RESULT_PID);
- json_builder_add_int_value(builder, reports[i].pid);
-
- json_builder_set_member_name(builder, SCHEMA_RESULT_RESULT);
- json_builder_begin_object(builder);
-
- json_builder_set_member_name(builder, SCHEMA_RESULT_TIME);
- json_builder_add_int_value(builder, reports[i].time);
- json_builder_set_member_name(builder, SCHEMA_RESULT_USAGE);
- json_builder_add_double_value(builder, reports[i].usage);
-
- json_builder_end_object(builder);
-
- json_builder_end_object(builder);
- }
-
- json_builder_end_array(builder);
- json_builder_end_object(builder);
-}
-
-static void process_report_to_json_object(JsonBuilder *builder, struct process_report *report)
-{
- json_builder_begin_object(builder);
-
- json_builder_set_member_name(builder, SCHEMA_TYPE);
- json_builder_add_string_value(builder, SCHEMA_TYPE_PROCESS);
-
- json_builder_set_member_name(builder, SCHEMA_RESULT_TIME);
- json_builder_add_int_value(builder, report->time);
-
- json_builder_set_member_name(builder, SCHEMA_RESULT_DATA_PROCESS);
- json_builder_begin_array(builder);
-
- for (int i = 0; i < report->n_processes; ++i) {
- json_builder_begin_object(builder);
- json_builder_set_member_name(builder, SCHEMA_RESULT_APP_ID);
- json_builder_add_string_value(builder, report->processes[i].app_id);
- json_builder_set_member_name(builder, SCHEMA_RESULT_EXE);
- json_builder_add_string_value(builder, report->processes[i].exe);
- json_builder_set_member_name(builder, SCHEMA_RESULT_PID);
- json_builder_add_int_value(builder, report->processes[i].pid);
- json_builder_set_member_name(builder, SCHEMA_RESULT_CPU);
- json_builder_add_double_value(builder, report->processes[i].cpu);
- json_builder_set_member_name(builder, SCHEMA_RESULT_MEMORY);
- json_builder_add_double_value(builder, report->processes[i].memory);
- json_builder_end_object(builder);
- }
- json_builder_end_array(builder);
-
- json_builder_end_object(builder); // end data process
- json_builder_end_object(builder); // end report
-}
-
-IMPLEMENT_SERIALIZER_FUNC(
- report_json_serializer_serialize_system_load_average_report,
- struct system_load_average_report,
- system_load_average_report_to_json_object);
-
-IMPLEMENT_SERIALIZER_FUNC(
- report_json_serializer_serialize_system_report,
- struct system_report,
- system_report_to_json_object)
-
-IMPLEMENT_SERIALIZER_FUNC(
- report_json_serializer_serialize_process_report,
- struct process_report,
- process_report_to_json_object)
-
-IMPLEMENT_ARRAY_SERIALIZER_FUNC(
- report_json_serializer_serialize_top_cpu_usage_reports,
- struct process_usage_report,
- top_cpu_usage_reports_to_json_object)
-
-IMPLEMENT_ARRAY_SERIALIZER_FUNC(
- report_json_serializer_serialize_top_memory_usage_reports,
- struct process_usage_report,
- top_memory_usage_reports_to_json_object)
-
diff --git a/src/report-json-serializer.h b/src/report-json-serializer.h
deleted file mode 100644
index b236c8a..0000000
--- a/src/report-json-serializer.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __REPORT_JSON_SERIALIZER_H_
-#define __REPORT_JSON_SERIALIZER_H_
-
-#include "report.h"
-
-/**
- * @brief Serializes system_load_average_report to json string
- *
- * @param[in] report Report structure with usage data.
- *
- * @return dynamically allocated string on NULL on error.
- * @remark returned value should be released with @free
- */
-char *report_json_serializer_serialize_system_load_average_report(struct system_load_average_report *report);
-
-/**
- * @brief Serializes system_report to json string
- *
- * @param[in] report Report structure with usage data.
- *
- * @return dynamically allocated string on NULL on error.
- * @remark returned value should be released with @free
- */
-char *report_json_serializer_serialize_system_report(struct system_report *report);
-
-/**
- * @brief Serializes process_report to json string
- *
- * @param[in] report Report structure with usage data.
- *
- * @return dynamically allocated string on NULL on error.
- * @remark returned value should be released with @free
- */
-char *report_json_serializer_serialize_process_report(struct process_report *report);
-
-/**
- * @brief Serializes process_usage_report to json string
- *
- * @param[in] report Report structure with usage data.
- *
- * @return dynamically allocated string on NULL on error.
- * @remark returned value should be released with @free
- */
-char *report_json_serializer_serialize_process_memory_usage_report(struct process_usage_report *report);
-
-/**
- * @brief Serializes app_system_cpu_usage_report to json string
- *
- * @param[in] report Report structure with usage data.
- *
- * @return dynamically allocated string on NULL on error.
- * @remark returned value should be released with @free
- */
-char *report_json_serializer_serialize_apps_cpu_usage_report(struct process_usage_report *report);
-
-/**
- * @brief Serializes process_usage_report to json string
- *
- * @param[in] report Report structure with usage data.
- *
- * @return dynamically allocated string on NULL on error.
- * @remark returned value should be released with @free
- */
-char *report_json_serializer_serialize_apps_memory_usage_report(struct process_usage_report *report);
-
-/**
- * @brief Serializes app_system_cpu_usage_reports to json string
- *
- * @param[in] report NULL-terminated array of report structures with usage data.
- *
- * @return dynamically allocated string on NULL on error.
- * @remark returned value should be released with @free
- */
-char *report_json_serializer_serialize_top_cpu_usage_reports(struct process_usage_report *reports, int len);
-
-/**
- * @brief Serializes app_memory_usage_reports to json string
- *
- * @param[in] report NULL-terminated array of report structures with usage data.
- *
- * @return dynamically allocated string on NULL on error.
- * @remark returned value should be released with @free
- */
-char *report_json_serializer_serialize_top_memory_usage_reports(struct process_usage_report *reports, int len);
-
-#endif
diff --git a/src/report.h b/src/report.h
deleted file mode 100644
index dc717c4..0000000
--- a/src/report.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __REPORT_H_
-#define __REPORT_H_
-
-#include <time.h>
-
-#define APP_ID_MAX_SIZE 256
-
-/**
- * @brief Load average report
- */
-struct system_load_average_report {
- time_t time; /** Number of seconds after the Epoch */
- float one_min_avg; /** One minute load averate */
- float five_min_avg; /** Five minutes load average */
- float fifteen_min_avg; /** Fifteen minutes load average */
-};
-
-/**
- * @brief System report
- */
-struct system_report {
- time_t time; /** Number of seconds after the Epoch */
- float cpu; /** CPU utilization (Percent) */
- float memory; /** Memory utilization (Percent) */
-};
-
-/**
- * @brief Process usage report.
- */
-struct process_usage_report {
- time_t time; /** Number of seconds after the Epoch */
- int pid; /** Process Pid */
- float usage; /** CPU utilization of process (Percent) */
- char app_id[APP_ID_MAX_SIZE];
-};
-
-struct process_info {
- const char *app_id;
- const char *exe;
- int pid;
- float cpu; /** CPU utilization (Percent) */
- float memory; /** Memory utilization (Percent) */
-};
-
-struct process_report {
- time_t time; /** Number of seconds after the Epoch */
- struct process_info *processes;
- int n_processes;
-};
-
-#endif
-
diff --git a/src/task-factory.c b/src/task-factory.c
index 9924c27..194e3a4 100644
--- a/src/task-factory.c
+++ b/src/task-factory.c
@@ -23,7 +23,6 @@
#include "report-generator-load-avg.h"
#include "report-generator-process.h"
#include "report-generator-top.h"
-#include "report-json-serializer.h"
#include "log.h"
#include "err-check.h"
#include "macros.h"