My Project
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
Enumerations | Functions | Variables
dfg_reader.c File Reference

Defines conversion of JSON strings to dedos_dfg. More...

#include "dfg_reader.h"
#include "dfg.h"
#include "jsmn_parser.h"
#include "jsmn.h"
#include "logging.h"
#include <strings.h>
#include <stdbool.h>
#include <string.h>

Go to the source code of this file.

Enumerations

enum  object_type {
  ROOT =0, RUNTIMES =1, ROUTES =2, DESTINATIONS =3,
  MSUS =4, PROFILING =5, META_ROUTING =6, SOURCE_TYPES =7,
  SCHEDULING =8, DEPENDENCIES =9, MSU_TYPES = 10
}
 The objects types which can be located in the json DFG See key_map for usage. More...
 

Functions

static int fix_num_threads (struct dedos_dfg *dfg)
 Fixes the thread assignment within the DFG such that the pinned and unpinned threads are accurate. More...
 
struct dedos_dfgparse_dfg_json_file (const char *filename)
 Converts a json file to a dfg structure. More...
 
static int set_app_name (jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
 Key: "application_name", Object: ROOT. More...
 
static int set_ctl_ip (jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
 Key: "global_ctl_ip", Object: ROOT. More...
 
static int set_ctl_port (jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
 Key: "global_ctl_port", Object: ROOT. More...
 
static int set_db_ip (jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
 Key: "db_ip", Object: ROOT. More...
 
static int set_db_port (jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
 Key: "global_ctl_port", Object: ROOT. More...
 
static int set_db_user (jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
 Key: "db_user", Object ROOT. More...
 
static int set_db_pwd (jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
 Key: "db_pwd", Object ROOT. More...
 
static int set_db_name (jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
 Key: "db_name", Object ROOT. More...
 
static struct json_state init_runtime (struct json_state *in__, int index__)
 Key: element in "runtimes", Object ROOT. More...
 
static int set_runtimes (jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
 Key: "runtimes", Object ROOT. More...
 
static struct json_state init_dfg_msu_from_json (struct json_state *in__, int index__)
 Key: element in "MSUs", Object ROOT. More...
 
static int set_msus (jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
 Key: "MSUs", Object ROOT. More...
 
static struct json_state init_dfg_msu_type (struct json_state *in__, int index__)
 Key: element in "MSU_types", Object ROOT. More...
 
static int set_msu_types (jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
 Key: "MSU_types", Object: ROOT. More...
 
static int set_msu_type_id (jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
 Key: "id", Object: MSU_TYPES. More...
 
static int set_msu_type_name (jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
 Key: "name", Object: MSU_TYPES. More...
 
static int set_meta_routing (jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
 Key: "meta_routing", Object: MSU_TYPES. More...
 
static struct json_state init_dependencies (struct json_state *in__, int index__)
 Key: Element in "dependencies", Object: MSU_TYPES. More...
 
static int set_dependencies (jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
 Key: "dependencies", Object MSU_TYPES. More...
 
static int set_cloneable (jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
 Key: "cloneable", Object MSU_TYPES. More...
 
static int set_colocation_group (jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
 Key: "colocation_group", object MSU_TYPES. More...
 
static int set_msu_init_data (jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
 Key: "init_data", Object: MSUS. More...
 
static int set_msu_id (jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
 Key: "id", Object MSUS. More...
 
static int set_msu_vertex_type (jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
 Key: "vertex_type", Object MSUS. More...
 
static int set_msu_type (jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
 Key "type", Object MSUS. More...
 
static int set_blocking_mode (jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
 key: "blocking_mode", object: MSUS More...
 
static int set_scheduling (jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
 Key: "scheduling", Object MSUS. More...
 
static int set_rt_id (jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
 Key: id, Object RUNTIMES. More...
 
static int set_rt_ip (jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
 Key: ip, Object RUNTIMES. More...
 
static int set_rt_port (jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
 Key: port, object RUNTIMES. More...
 
static int set_rt_n_cores (jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
 Key: num_cores, object RUNTIMES. More...
 
static int set_num_pinned_threads (jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
 Key: num_pinned_threads, object RUNTIMES. More...
 
static int set_num_unpinned_threads (jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
 Key: num_unpinned_threads, object RUNTIMES. More...
 
static struct json_state init_route (struct json_state *in__, int index__)
 Key: Element in "routes", object RUNTIMES. More...
 
static int set_rt_routes (jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
 Key: "routes", object RUNTIMES. More...
 
static int set_route_id (jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
 Key: "id", object ROUTES. More...
 
static int set_route_type (jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
 Key: "type", object ROUTES. More...
 
static struct json_state init_endpoint (struct json_state *in__, int index__)
 Key: Element in "endpoints", object ROUTES. More...
 
static int set_route_endpoints (jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
 Key: "endpoints", object ROUTES. More...
 
static int set_dest_key (jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
 Key: "key", object DESTINATIONS. More...
 
static int set_dest_msu (jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
 Key: "msu", object DESTINATIONS. More...
 
static int set_source_types (jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
 Key: "source_types", object META_ROUTING. More...
 
static int set_dst_types (jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
 Key: "dst_types", object META_ROUTING. More...
 
static int set_dep_type (jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
 key: "type", object DEPENDENCIES More...
 
static int set_dep_locality (jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
 Key: "locality", object: DEPENDENCIES. More...
 
static int set_msu_runtime (jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
 Key: "runtime", object: SCHEDULING. More...
 
static int set_msu_thread (jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
 Key: "thread_id", object: SCHEDULING. More...
 
static int set_msu_routes (jsmntok_t **tok__, char *j__, struct json_state *in__, struct json_state **saved__)
 key: "routes", object SCHEDULING More...
 
static int not_implemented (jsmntok_t **tok, char *j, struct json_state *in, struct json_state **saved)
 To be used to raise an error when a JSON key is deprecated. More...
 

Variables

static struct key_mapping key_map []
 Provides the mapping between the keys in the JSON and the functions which are called when those keys are encountered. More...
 

Detailed Description

Defines conversion of JSON strings to dedos_dfg.

Definition in file dfg_reader.c.

Enumeration Type Documentation

The objects types which can be located in the json DFG See key_map for usage.

Enumerator
ROOT 
RUNTIMES 
ROUTES 
DESTINATIONS 
MSUS 
PROFILING 
META_ROUTING 
SOURCE_TYPES 
SCHEDULING 
DEPENDENCIES 
MSU_TYPES 

Definition at line 39 of file dfg_reader.c.

Function Documentation

static int fix_num_threads ( struct dedos_dfg dfg)
static

Fixes the thread assignment within the DFG such that the pinned and unpinned threads are accurate.

Must be run, because during execution the only hint of pinned/unpinned is msu blocking mode. To be run after DFG is fully parsed.

Returns
0 on success, -1 on error

Definition at line 52 of file dfg_reader.c.

static struct json_state init_dependencies ( struct json_state in__,
int  index__ 
)
static

Key: Element in "dependencies", Object: MSU_TYPES.

Definition at line 266 of file dfg_reader.c.

static struct json_state init_dfg_msu_from_json ( struct json_state in__,
int  index__ 
)
static

Key: element in "MSUs", Object ROOT.

Definition at line 214 of file dfg_reader.c.

static struct json_state init_dfg_msu_type ( struct json_state in__,
int  index__ 
)
static

Key: element in "MSU_types", Object ROOT.

Definition at line 228 of file dfg_reader.c.

static struct json_state init_endpoint ( struct json_state in__,
int  index__ 
)
static

Key: Element in "endpoints", object ROUTES.

Definition at line 481 of file dfg_reader.c.

static struct json_state init_route ( struct json_state in__,
int  index__ 
)
static

Key: Element in "routes", object RUNTIMES.

Definition at line 440 of file dfg_reader.c.

static struct json_state init_runtime ( struct json_state in__,
int  index__ 
)
static

Key: element in "runtimes", Object ROOT.

Definition at line 200 of file dfg_reader.c.

static int not_implemented ( jsmntok_t **  tok,
char *  j,
struct json_state in,
struct json_state **  saved 
)
static

To be used to raise an error when a JSON key is deprecated.

Definition at line 673 of file dfg_reader.c.

struct dedos_dfg* parse_dfg_json_file ( const char *  filename)

Converts a json file to a dfg structure.

Parameters
filenameThe json file to parse
Returns
A copy of the newly-allocated DFG, or NULL if error

Definition at line 96 of file dfg_reader.c.

static int set_app_name ( jsmntok_t **  tok__,
char *  j__,
struct json_state in__,
struct json_state **  saved__ 
)
static

Key: "application_name", Object: ROOT.

Definition at line 117 of file dfg_reader.c.

static int set_blocking_mode ( jsmntok_t **  tok__,
char *  j__,
struct json_state in__,
struct json_state **  saved__ 
)
static

key: "blocking_mode", object: MSUS

Definition at line 338 of file dfg_reader.c.

static int set_cloneable ( jsmntok_t **  tok__,
char *  j__,
struct json_state in__,
struct json_state **  saved__ 
)
static

Key: "cloneable", Object MSU_TYPES.

Definition at line 280 of file dfg_reader.c.

static int set_colocation_group ( jsmntok_t **  tok__,
char *  j__,
struct json_state in__,
struct json_state **  saved__ 
)
static

Key: "colocation_group", object MSU_TYPES.

Definition at line 287 of file dfg_reader.c.

static int set_ctl_ip ( jsmntok_t **  tok__,
char *  j__,
struct json_state in__,
struct json_state **  saved__ 
)
static

Key: "global_ctl_ip", Object: ROOT.

Definition at line 129 of file dfg_reader.c.

static int set_ctl_port ( jsmntok_t **  tok__,
char *  j__,
struct json_state in__,
struct json_state **  saved__ 
)
static

Key: "global_ctl_port", Object: ROOT.

Definition at line 143 of file dfg_reader.c.

static int set_db_ip ( jsmntok_t **  tok__,
char *  j__,
struct json_state in__,
struct json_state **  saved__ 
)
static

Key: "db_ip", Object: ROOT.

Definition at line 150 of file dfg_reader.c.

static int set_db_name ( jsmntok_t **  tok__,
char *  j__,
struct json_state in__,
struct json_state **  saved__ 
)
static

Key: "db_name", Object ROOT.

Definition at line 191 of file dfg_reader.c.

static int set_db_port ( jsmntok_t **  tok__,
char *  j__,
struct json_state in__,
struct json_state **  saved__ 
)
static

Key: "global_ctl_port", Object: ROOT.

Definition at line 165 of file dfg_reader.c.

static int set_db_pwd ( jsmntok_t **  tok__,
char *  j__,
struct json_state in__,
struct json_state **  saved__ 
)
static

Key: "db_pwd", Object ROOT.

Definition at line 182 of file dfg_reader.c.

static int set_db_user ( jsmntok_t **  tok__,
char *  j__,
struct json_state in__,
struct json_state **  saved__ 
)
static

Key: "db_user", Object ROOT.

Definition at line 173 of file dfg_reader.c.

static int set_dep_locality ( jsmntok_t **  tok__,
char *  j__,
struct json_state in__,
struct json_state **  saved__ 
)
static

Key: "locality", object: DEPENDENCIES.

Definition at line 578 of file dfg_reader.c.

static int set_dep_type ( jsmntok_t **  tok__,
char *  j__,
struct json_state in__,
struct json_state **  saved__ 
)
static

key: "type", object DEPENDENCIES

Definition at line 562 of file dfg_reader.c.

static int set_dependencies ( jsmntok_t **  tok__,
char *  j__,
struct json_state in__,
struct json_state **  saved__ 
)
static

Key: "dependencies", Object MSU_TYPES.

Definition at line 277 of file dfg_reader.c.

static int set_dest_key ( jsmntok_t **  tok__,
char *  j__,
struct json_state in__,
struct json_state **  saved__ 
)
static

Key: "key", object DESTINATIONS.

Definition at line 495 of file dfg_reader.c.

static int set_dest_msu ( jsmntok_t **  tok__,
char *  j__,
struct json_state in__,
struct json_state **  saved__ 
)
static

Key: "msu", object DESTINATIONS.

Definition at line 502 of file dfg_reader.c.

static int set_dst_types ( jsmntok_t **  tok__,
char *  j__,
struct json_state in__,
struct json_state **  saved__ 
)
static

Key: "dst_types", object META_ROUTING.

Definition at line 539 of file dfg_reader.c.

static int set_meta_routing ( jsmntok_t **  tok__,
char *  j__,
struct json_state in__,
struct json_state **  saved__ 
)
static

Key: "meta_routing", Object: MSU_TYPES.

Definition at line 263 of file dfg_reader.c.

static int set_msu_id ( jsmntok_t **  tok__,
char *  j__,
struct json_state in__,
struct json_state **  saved__ 
)
static

Key: "id", Object MSUS.

Definition at line 307 of file dfg_reader.c.

static int set_msu_init_data ( jsmntok_t **  tok__,
char *  j__,
struct json_state in__,
struct json_state **  saved__ 
)
static

Key: "init_data", Object: MSUS.

Definition at line 294 of file dfg_reader.c.

static int set_msu_routes ( jsmntok_t **  tok__,
char *  j__,
struct json_state in__,
struct json_state **  saved__ 
)
static

key: "routes", object SCHEDULING

Definition at line 647 of file dfg_reader.c.

static int set_msu_runtime ( jsmntok_t **  tok__,
char *  j__,
struct json_state in__,
struct json_state **  saved__ 
)
static

Key: "runtime", object: SCHEDULING.

Definition at line 593 of file dfg_reader.c.

static int set_msu_thread ( jsmntok_t **  tok__,
char *  j__,
struct json_state in__,
struct json_state **  saved__ 
)
static

Key: "thread_id", object: SCHEDULING.

Definition at line 607 of file dfg_reader.c.

static int set_msu_type ( jsmntok_t **  tok__,
char *  j__,
struct json_state in__,
struct json_state **  saved__ 
)
static

Key "type", Object MSUS.

Definition at line 322 of file dfg_reader.c.

static int set_msu_type_id ( jsmntok_t **  tok__,
char *  j__,
struct json_state in__,
struct json_state **  saved__ 
)
static

Key: "id", Object: MSU_TYPES.

Definition at line 243 of file dfg_reader.c.

static int set_msu_type_name ( jsmntok_t **  tok__,
char *  j__,
struct json_state in__,
struct json_state **  saved__ 
)
static

Key: "name", Object: MSU_TYPES.

Definition at line 250 of file dfg_reader.c.

static int set_msu_types ( jsmntok_t **  tok__,
char *  j__,
struct json_state in__,
struct json_state **  saved__ 
)
static

Key: "MSU_types", Object: ROOT.

Definition at line 240 of file dfg_reader.c.

static int set_msu_vertex_type ( jsmntok_t **  tok__,
char *  j__,
struct json_state in__,
struct json_state **  saved__ 
)
static

Key: "vertex_type", Object MSUS.

Definition at line 314 of file dfg_reader.c.

static int set_msus ( jsmntok_t **  tok__,
char *  j__,
struct json_state in__,
struct json_state **  saved__ 
)
static

Key: "MSUs", Object ROOT.

Definition at line 225 of file dfg_reader.c.

static int set_num_pinned_threads ( jsmntok_t **  tok__,
char *  j__,
struct json_state in__,
struct json_state **  saved__ 
)
static

Key: num_pinned_threads, object RUNTIMES.

Definition at line 410 of file dfg_reader.c.

static int set_num_unpinned_threads ( jsmntok_t **  tok__,
char *  j__,
struct json_state in__,
struct json_state **  saved__ 
)
static

Key: num_unpinned_threads, object RUNTIMES.

Definition at line 425 of file dfg_reader.c.

static int set_route_endpoints ( jsmntok_t **  tok__,
char *  j__,
struct json_state in__,
struct json_state **  saved__ 
)
static

Key: "endpoints", object ROUTES.

Definition at line 492 of file dfg_reader.c.

static int set_route_id ( jsmntok_t **  tok__,
char *  j__,
struct json_state in__,
struct json_state **  saved__ 
)
static

Key: "id", object ROUTES.

Definition at line 454 of file dfg_reader.c.

static int set_route_type ( jsmntok_t **  tok__,
char *  j__,
struct json_state in__,
struct json_state **  saved__ 
)
static

Key: "type", object ROUTES.

Definition at line 468 of file dfg_reader.c.

static int set_rt_id ( jsmntok_t **  tok__,
char *  j__,
struct json_state in__,
struct json_state **  saved__ 
)
static

Key: id, Object RUNTIMES.

Definition at line 375 of file dfg_reader.c.

static int set_rt_ip ( jsmntok_t **  tok__,
char *  j__,
struct json_state in__,
struct json_state **  saved__ 
)
static

Key: ip, Object RUNTIMES.

Definition at line 382 of file dfg_reader.c.

static int set_rt_n_cores ( jsmntok_t **  tok__,
char *  j__,
struct json_state in__,
struct json_state **  saved__ 
)
static

Key: num_cores, object RUNTIMES.

Definition at line 403 of file dfg_reader.c.

static int set_rt_port ( jsmntok_t **  tok__,
char *  j__,
struct json_state in__,
struct json_state **  saved__ 
)
static

Key: port, object RUNTIMES.

Definition at line 396 of file dfg_reader.c.

static int set_rt_routes ( jsmntok_t **  tok__,
char *  j__,
struct json_state in__,
struct json_state **  saved__ 
)
static

Key: "routes", object RUNTIMES.

Definition at line 451 of file dfg_reader.c.

static int set_runtimes ( jsmntok_t **  tok__,
char *  j__,
struct json_state in__,
struct json_state **  saved__ 
)
static

Key: "runtimes", Object ROOT.

Definition at line 211 of file dfg_reader.c.

static int set_scheduling ( jsmntok_t **  tok__,
char *  j__,
struct json_state in__,
struct json_state **  saved__ 
)
static

Key: "scheduling", Object MSUS.

Definition at line 372 of file dfg_reader.c.

static int set_source_types ( jsmntok_t **  tok__,
char *  j__,
struct json_state in__,
struct json_state **  saved__ 
)
static

Key: "source_types", object META_ROUTING.

Definition at line 517 of file dfg_reader.c.

Variable Documentation

static struct key_mapping key_map
static

Provides the mapping between the keys in the JSON and the functions which are called when those keys are encountered.

(See jsmn_parser.h for details of key_mapping structure)

Definition at line 94 of file dfg_reader.c.