Motr  M0
fdmi_sample_plugin.c File Reference
#include "lib/trace.h"
#include "motr/client.h"
#include "fid/fid.h"
#include "motr/client_internal.h"
#include "lib/getopts.h"
#include "fdmi/fdmi.h"
#include "fdmi/plugin_dock.h"
#include "fdmi/service.h"
#include "reqh/reqh.h"
Include dependency graph for fdmi_sample_plugin.c:

Go to the source code of this file.

Data Structures

struct  m0_fsp_params
 

Macros

#define M0_TRACE_SUBSYSTEM   M0_TRACE_SUBSYS_FDMI
 

Functions

static void dump_fol_rec_to_json (struct m0_uint128 *rec_id, struct m0_fol_rec *rec)
 
static void fsp_usage (void)
 
static int fsp_args_parse (struct m0_fsp_params *params, int argc, char **argv)
 
static int process_fdmi_record (struct m0_uint128 *rec_id, struct m0_buf fdmi_rec, struct m0_fid filter_id)
 
static int fdmi_service_start (struct m0_client *m0c)
 
static void fdmi_service_stop (struct m0_client *m0c)
 
static int init_fdmi_plugin (struct m0_fsp_params *params)
 
static void fini_fdmi_plugin (struct m0_fsp_params *params)
 
static void fdmi_plugin_record_ack ()
 
static int fsp_init (struct m0_fsp_params *params)
 
static void fsp_fini (struct m0_fsp_params *params)
 
static void fsp_sighandler (int signum)
 
static int fsp_sighandler_init (void)
 
static void fsp_print_params (struct m0_fsp_params *params)
 
int main (int argc, char **argv)
 

Variables

struct m0_fsp_params fsp_params
 
static struct m0_semaphore fsp_sem
 
static volatile int terminated = 0
 
static struct m0_config fsp_conf = {}
 
static struct m0_clientfsp_client = NULL
 
static struct m0_idx_dix_config fsp_dix_conf = {}
 
const struct m0_fdmi_pd_opsfsp_pdo
 
static struct m0_reqh_servicefsp_fdmi_service = NULL
 

Macro Definition Documentation

◆ M0_TRACE_SUBSYSTEM

#define M0_TRACE_SUBSYSTEM   M0_TRACE_SUBSYS_FDMI

Definition at line 22 of file fdmi_sample_plugin.c.

Function Documentation

◆ dump_fol_rec_to_json()

static void dump_fol_rec_to_json ( struct m0_uint128 rec_id,
struct m0_fol_rec rec 
)
static

Definition at line 110 of file fdmi_sample_plugin.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fdmi_plugin_record_ack()

static void fdmi_plugin_record_ack ( )
static

Reading from stdin to get FDMI record ID and then release this record.

Definition at line 357 of file fdmi_sample_plugin.c.

Here is the caller graph for this function:

◆ fdmi_service_start()

static int fdmi_service_start ( struct m0_client m0c)
static

Definition at line 288 of file fdmi_sample_plugin.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fdmi_service_stop()

static void fdmi_service_stop ( struct m0_client m0c)
static

Definition at line 315 of file fdmi_sample_plugin.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fini_fdmi_plugin()

static void fini_fdmi_plugin ( struct m0_fsp_params params)
static

Definition at line 347 of file fdmi_sample_plugin.c.

Here is the caller graph for this function:

◆ fsp_args_parse()

static int fsp_args_parse ( struct m0_fsp_params params,
int  argc,
char **  argv 
)
static
Return values
0Success.
-ExxxError.

Definition at line 187 of file fdmi_sample_plugin.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fsp_fini()

static void fsp_fini ( struct m0_fsp_params params)
static

Definition at line 414 of file fdmi_sample_plugin.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fsp_init()

static int fsp_init ( struct m0_fsp_params params)
static

Definition at line 375 of file fdmi_sample_plugin.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fsp_print_params()

static void fsp_print_params ( struct m0_fsp_params params)
static

Definition at line 452 of file fdmi_sample_plugin.c.

Here is the caller graph for this function:

◆ fsp_sighandler()

static void fsp_sighandler ( int  signum)
static

Definition at line 426 of file fdmi_sample_plugin.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fsp_sighandler_init()

static int fsp_sighandler_init ( void  )
static

Definition at line 437 of file fdmi_sample_plugin.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fsp_usage()

static void fsp_usage ( void  )
static

Definition at line 165 of file fdmi_sample_plugin.c.

Here is the caller graph for this function:

◆ init_fdmi_plugin()

static int init_fdmi_plugin ( struct m0_fsp_params params)
static

Definition at line 328 of file fdmi_sample_plugin.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 468 of file fdmi_sample_plugin.c.

Here is the call graph for this function:

◆ process_fdmi_record()

static int process_fdmi_record ( struct m0_uint128 rec_id,
struct m0_buf  fdmi_rec,
struct m0_fid  filter_id 
)
static

Callback function called by the FDMI service to deliver the FDMI event to the plugin program.

Definition at line 259 of file fdmi_sample_plugin.c.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ fsp_client

struct m0_client* fsp_client = NULL
static

Pointer to the initialized m0_client structure denoting our program functionality.

Definition at line 92 of file fdmi_sample_plugin.c.

◆ fsp_conf

struct m0_config fsp_conf = {}
static

This program is basically adding the new client to the cluster. To do so we need to specify the client endpoint and the address of the cluster configuration service. This structure is used for delivering this info to the Motr core.

Definition at line 86 of file fdmi_sample_plugin.c.

◆ fsp_dix_conf

struct m0_idx_dix_config fsp_dix_conf = {}
static

Definition at line 95 of file fdmi_sample_plugin.c.

◆ fsp_fdmi_service

struct m0_reqh_service* fsp_fdmi_service = NULL
static

The handle of the local FDMI service that we start. Its purpose is to receive the FDMI rpcs, find the local consumer (this program) and send forward them to the consumer plugin in the form of FDMI records.

Definition at line 108 of file fdmi_sample_plugin.c.

◆ fsp_params

struct m0_fsp_params fsp_params

This is the FDMI plugin program. Its purpose is to start the listener for the special type of the FDMI events and forward them to the fdmi_app wrapper written in python. The communication is done via stdout. Storage for the program run parameters passed from console or the wrapper application.

Definition at line 67 of file fdmi_sample_plugin.c.

◆ fsp_pdo

const struct m0_fdmi_pd_ops* fsp_pdo

The vector of the FDMI plugin callback operations. They are called by the Motr when the new FDMI event occurs.

Definition at line 101 of file fdmi_sample_plugin.c.

◆ fsp_sem

struct m0_semaphore fsp_sem
static

The main loop semaphore. The main loop here is just sleeping most of the time and waiting for some stop signal (e.g ctrl+c) from the python fdmi_app that controls this plugin program.

The main job is done in one of the Motr locality threads, that handles the fops with FDMI data and call the callback function installed by this program if the type of the plugin match is found.

Definition at line 78 of file fdmi_sample_plugin.c.

◆ terminated

volatile int terminated = 0
static

Definition at line 79 of file fdmi_sample_plugin.c.