22 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_FDMI 123 const unsigned char *
addr;
126 printf(
"{ \"opcode\": \"%d\", ",
129 printf(
"\"rec_id\": \""U128X_F"\", ",
132 printf(
"\"fid\": \""FID_F"\", ",
138 printf(
"\"cr_key\": \"%.*s\", ", len,
addr);
140 printf(
"\"cr_key\": \"");
141 for (j = 0; j < len; j++)
142 printf(
"%02x",
addr[j]);
149 printf(
"\"cr_val\": \"%.*s\"",
152 printf(
"\"cr_val\": \"");
153 for (j = 0; j < len; j++)
154 printf(
"%02x",
addr[j]);
158 printf(
"\"cr_val\": \"0\"");
168 "Usage: fdmi_sample_plugin " 169 "-l local_addr -h ha_addr -p profile_fid -f process_fid " 170 "-g fdmi_plugin_fid [-s] [-r]\n" 171 "Use -? or -i for more verbose help on common arguments.\n" 172 "Usage example for common arguments: \n" 173 "fdmi_sample_plugin -l 192.168.52.53@tcp:12345:4:1 " 174 "-h 192.168.52.53@tcp:12345:1:1 " 175 "-p 0x7000000000000001:0x37 -f 0x7200000000000001:0x19 " 176 "-g 0x6c00000000000001:0x51" 177 "-s output the key/val as a string. Otherwise as hex." 178 "-r plugin adds an extra reference on the record and then " 179 " release it when it is consumed" 196 params->spp_output_strings =
false;
197 params->spp_extra_ref =
false;
207 LAMBDA(
void, (
const char *
string) {
208 params->spp_local_addr = (
char*)
string;
211 LAMBDA(
void, (
const char *str) {
212 params->spp_hare_addr = (
char*)str;
215 LAMBDA(
void, (
const char *str) {
216 params->spp_process_fid = (
char*)str;
219 LAMBDA(
void, (
const char *str) {
220 params->spp_profile_fid = (
char*)str;
223 LAMBDA(
void, (
const char *str) {
224 params->spp_fdmi_plugin_fid_s =
229 params->spp_output_strings =
true;
233 params->spp_extra_ref =
true;
249 params->spp_fdmi_plugin_fid_s);
298 return M0_ERR_INFO(-EINVAL,
"Unknown reqh service type: M0_CST_FDMI");
305 return M0_RC_INFO(
rc,
"Failed to allocate FDMI service.");
339 fprintf(stderr,
"Plugin registration: rc=%d\n",
rc);
362 setvbuf(stdin,
NULL, _IONBF, 0);
428 fprintf(stderr,
"fdmi_sample_plugin interrupted by signal %d\n", signum);
433 signal(SIGINT, SIG_DFL);
434 signal(SIGTERM, SIG_DFL);
442 sigemptyset(&sa.sa_mask);
445 sigaddset(&sa.sa_mask, SIGINT);
446 sigaddset(&sa.sa_mask, SIGTERM);
448 rc = sigaction(SIGINT, &sa,
NULL) ?: sigaction(SIGTERM, &sa,
NULL);
458 " profile_fid : %s\n" 459 " process_fid : %s\n" 461 " output as string: %s\n",
464 params->spp_fdmi_plugin_fid_s,
465 params->spp_output_strings?
"true":
"false");
468 int main(
int argc,
char **argv)
479 fprintf(stderr,
"Args parse failed\n");
499 fprintf(stderr,
"fdmi_sample_plugin waiting for signal...\n");
510 #undef M0_TRACE_SUBSYSTEM
#define M0_GETOPTS(progname, argc, argv,...)
M0_EXTERN struct m0_reqh_service_type m0_fdmi_service_type
static volatile int terminated
M0_INTERNAL int m0_reqh_service_start(struct m0_reqh_service *service)
M0_INTERNAL void m0_reqh_service_stop(struct m0_reqh_service *service)
M0_INTERNAL void m0_fol_rec_fini(struct m0_fol_rec *rec)
const char * mc_process_fid
int main(int argc, char **argv)
struct m0_fdmi_record_reg * m0_fdmi__pdock_record_reg_find(const struct m0_uint128 *rid)
#define M0_LOG(level,...)
M0_INTERNAL void m0_reqh_service_prepare_to_stop(struct m0_reqh_service *service)
struct m0_fsp_params fsp_params
static struct m0_semaphore fsp_sem
const struct m0_fdmi_pd_ops * fsp_pdo
void m0_client_fini(struct m0_client *m0c, bool fini_m0)
static struct m0_clovis * m0c
int m0_client_init(struct m0_client **m0c, struct m0_config *conf, bool init_m0)
#define M0_VOIDARG(ch, desc, func)
struct m0_rpc_at_buf cr_val
M0_INTERNAL struct m0_reqh_service_type * m0_reqh_service_type_find(const char *sname)
int(* po_fdmi_rec)(struct m0_uint128 *rec_id, struct m0_buf fdmi_rec, struct m0_fid filter_id)
static void fsp_sighandler(int signum)
struct m0_cas_rec * cr_rec
struct m0_rpc_at_buf cr_key
M0_INTERNAL void m0_fol_rec_init(struct m0_fol_rec *rec, struct m0_fol *fol)
void(* fpo_deregister_plugin)(struct m0_fid *filter_ids, uint64_t filter_count)
#define M0_STRINGARG(ch, desc, func)
#define M0_RC_INFO(rc, fmt,...)
#define M0_ERR_INFO(rc, fmt,...)
return M0_ERR(-EOPNOTSUPP)
M0_INTERNAL void m0_ref_get(struct m0_ref *ref)
static const struct socktype stype[]
static int fsp_sighandler_init(void)
static int fsp_init(struct m0_fsp_params *params)
M0_INTERNAL void m0_reqh_service_fini(struct m0_reqh_service *service)
static struct m0_client * fsp_client
static int fsp_args_parse(struct m0_fsp_params *params, int argc, char **argv)
M0_INTERNAL int m0_semaphore_init(struct m0_semaphore *semaphore, unsigned value)
static struct m0_config fsp_conf
static void dump_fol_rec_to_json(struct m0_uint128 *rec_id, struct m0_fol_rec *rec)
M0_INTERNAL int m0_reqh_service_allocate(struct m0_reqh_service **out, const struct m0_reqh_service_type *stype, struct m0_reqh_context *rctx)
union m0_rpc_at_buf::@447 u
struct m0_cas_recv cg_rec
static void fsp_print_params(struct m0_fsp_params *params)
M0_INTERNAL void m0_reqh_service_init(struct m0_reqh_service *service, struct m0_reqh *reqh, const struct m0_fid *fid)
M0_INTERNAL int m0_fid_sscanf(const char *s, struct m0_fid *fid)
static void fdmi_service_stop(struct m0_client *m0c)
struct m0_fid spp_fdmi_plugin_fid
struct m0_cas_recv cg_rec
static void fsp_fini(struct m0_fsp_params *params)
void * mc_idx_service_conf
void(* fpo_enable_filters)(bool enable, struct m0_fid *filter_ids, uint32_t filter_count)
static void fini_fdmi_plugin(struct m0_fsp_params *params)
M0_INTERNAL struct m0_reqh_service * m0_reqh_service_find(const struct m0_reqh_service_type *st, const struct m0_reqh *reqh)
uint32_t mc_max_rpc_msg_size
const char * mc_local_addr
M0_INTERNAL void m0_semaphore_fini(struct m0_semaphore *semaphore)
uint32_t mc_tm_recv_queue_min_len
int(* fpo_register_filter)(const struct m0_fid *fid, const struct m0_fdmi_filter_desc *desc, const struct m0_fdmi_plugin_ops *pcb)
static void fsp_usage(void)
static int fdmi_service_start(struct m0_client *m0c)
M0_INTERNAL void m0_reqh_idle_wait_for(struct m0_reqh *reqh, struct m0_reqh_service *service)
static int init_fdmi_plugin(struct m0_fsp_params *params)
struct m0t1fs_filedata * fd
struct m0_cas_rec * cr_rec
static struct m0_idx_dix_config fsp_dix_conf
static struct m0_cas_op * cas_op(const struct m0_fom *fom)
M0_INTERNAL void m0_semaphore_down(struct m0_semaphore *semaphore)
static void fdmi_plugin_record_ack()
M0_INTERNAL void m0_semaphore_up(struct m0_semaphore *semaphore)
def start_service(self, service, idx)
static int process_fdmi_record(struct m0_uint128 *rec_id, struct m0_buf fdmi_rec, struct m0_fid filter_id)
#define m0_tl_for(name, head, obj)
static struct m0_reqh_service * fsp_fdmi_service
void(* fpo_release_fdmi_rec)(struct m0_uint128 *rec_id, struct m0_fid *filter_id)
char * spp_fdmi_plugin_fid_s
M0_INTERNAL int m0_fol_rec_decode(struct m0_fol_rec *rec, struct m0_buf *at)
const struct m0_fdmi_pd_ops * m0_fdmi_plugin_dock_api_get(void)