summaryrefslogtreecommitdiffstats
path: root/xlators/features/changelog/lib/src/gf-changelog-rpc.c
blob: 8ec6ffbcebc50ded0f7d416d4efc2e31b99386a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
   Copyright (c) 2013 Red Hat, Inc. <http://www.redhat.com>
   This file is part of GlusterFS.

   This file is licensed to you under your choice of the GNU Lesser
   General Public License, version 3 or any later version (LGPLv3 or
   later), or the GNU General Public License, version 2 (GPLv2), in all
   cases as published by the Free Software Foundation.
*/

#include "gf-changelog-rpc.h"
#include "changelog-misc.h"
#include "changelog-mem-types.h"

struct rpc_clnt_program gf_changelog_clnt;

/* TODO: piggyback reconnect to called (upcall) */
int
gf_changelog_rpc_notify(struct rpc_clnt *rpc, void *mydata,
                        rpc_clnt_event_t event, void *data)
{
    switch (event) {
        case RPC_CLNT_CONNECT:
            break;
        case RPC_CLNT_DISCONNECT:
        case RPC_CLNT_MSG:
        case RPC_CLNT_DESTROY:
        case RPC_CLNT_PING:
            break;
    }

    return 0;
}

struct rpc_clnt *
gf_changelog_rpc_init(xlator_t *this, gf_changelog_t *entry)
{
    char sockfile[UNIX_PATH_MAX] = {
        0,
    };

    CHANGELOG_MAKE_SOCKET_PATH(entry->brick, sockfile, UNIX_PATH_MAX);
    return changelog_rpc_client_init(this, entry, sockfile,
                                     gf_changelog_rpc_notify);
}

/**
 * remote procedure calls declarations.
 */

int
gf_probe_changelog_cbk(struct rpc_req *req, struct iovec *iovec, int count,
                       void *myframe)
{
    return 0;
}

int
gf_probe_changelog_filter(call_frame_t *frame, xlator_t *this, void *data)
{
    char *sock = NULL;
    gf_changelog_t *entry = NULL;
    changelog_probe_req req = {
        0,
    };

    entry = data;
    sock = RPC_SOCK(entry);

    (void)memcpy(&req.sock, sock, strlen(sock));
    req.filter = entry->notify;

    /* invoke RPC */
    return changelog_rpc_sumbit_req(
        RPC_PROBER(entry), (void *)&req, frame, &gf_changelog_clnt,
        CHANGELOG_RPC_PROBE_FILTER, NULL, 0, NULL, this, gf_probe_changelog_cbk,
        (xdrproc_t)xdr_changelog_probe_req);
}

int
gf_changelog_invoke_rpc(xlator_t *this, gf_changelog_t *entry, int procidx)
{
    return changelog_invoke_rpc(this, RPC_PROBER(entry), &gf_changelog_clnt,
                                procidx, entry);
}

struct rpc_clnt_procedure gf_changelog_procs[CHANGELOG_RPC_PROC_MAX] = {
    [CHANGELOG_RPC_PROC_NULL] = {"NULL", NULL},
    [CHANGELOG_RPC_PROBE_FILTER] = {"PROBE FILTER", gf_probe_changelog_filter},
};

struct rpc_clnt_program gf_changelog_clnt = {
    .progname = "LIBGFCHANGELOG",
    .prognum = CHANGELOG_RPC_PROGNUM,
    .progver = CHANGELOG_RPC_PROGVER,
    .numproc = CHANGELOG_RPC_PROC_MAX,
    .proctable = gf_changelog_procs,
};