pacemaker
1.1.14-70404b0
Scalable High-Availability cluster resource manager
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
lib
lrmd
proxy_common.c
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2015 David Vossel <davidvossel@gmail.com>
3
*
4
* This library is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Lesser General Public
6
* License as published by the Free Software Foundation; either
7
* version 2.1 of the License, or (at your option) any later version.
8
*
9
* This library is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* Lesser General Public License for more details.
13
*
14
* You should have received a copy of the GNU Lesser General Public
15
* License along with this library; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
*
18
*/
19
20
#include <
crm_internal.h
>
21
22
#include <glib.h>
23
#include <unistd.h>
24
25
#include <
crm/crm.h
>
26
#include <
crm/msg_xml.h
>
27
#include <
crm/services.h
>
28
#include <
crm/common/mainloop.h
>
29
30
#include <
crm/pengine/status.h
>
31
#include <
crm/cib.h
>
32
#include <
crm/lrmd.h
>
33
34
int
lrmd_internal_proxy_send
(
lrmd_t
* lrmd, xmlNode *msg);
35
GHashTable *
proxy_table
= NULL;
36
37
void
38
remote_proxy_notify_destroy
(
lrmd_t
*lrmd,
const
char
*session_id)
39
{
40
/* sending to the remote node that an ipc connection has been destroyed */
41
xmlNode *msg =
create_xml_node
(NULL,
T_LRMD_IPC_PROXY
);
42
crm_xml_add
(msg,
F_LRMD_IPC_OP
,
"destroy"
);
43
crm_xml_add
(msg,
F_LRMD_IPC_SESSION
, session_id);
44
lrmd_internal_proxy_send
(lrmd, msg);
45
free_xml
(msg);
46
}
47
48
void
49
remote_proxy_relay_event
(
lrmd_t
*lrmd,
const
char
*session_id, xmlNode *msg)
50
{
51
/* sending to the remote node an event msg. */
52
xmlNode *
event
=
create_xml_node
(NULL,
T_LRMD_IPC_PROXY
);
53
crm_xml_add
(event,
F_LRMD_IPC_OP
,
"event"
);
54
crm_xml_add
(event,
F_LRMD_IPC_SESSION
, session_id);
55
add_message_xml
(event,
F_LRMD_IPC_MSG
, msg);
56
crm_log_xml_explicit
(event,
"EventForProxy"
);
57
lrmd_internal_proxy_send
(lrmd, event);
58
free_xml
(event);
59
}
60
61
void
62
remote_proxy_relay_response
(
lrmd_t
*lrmd,
const
char
*session_id, xmlNode *msg,
int
msg_id)
63
{
64
/* sending to the remote node a response msg. */
65
xmlNode *response =
create_xml_node
(NULL,
T_LRMD_IPC_PROXY
);
66
crm_xml_add
(response,
F_LRMD_IPC_OP
,
"response"
);
67
crm_xml_add
(response,
F_LRMD_IPC_SESSION
, session_id);
68
crm_xml_add_int
(response,
F_LRMD_IPC_MSG_ID
, msg_id);
69
add_message_xml
(response,
F_LRMD_IPC_MSG
, msg);
70
lrmd_internal_proxy_send
(lrmd, response);
71
free_xml
(response);
72
}
73
74
void
75
remote_proxy_end_session
(
const
char
*session)
76
{
77
remote_proxy_t
*proxy = g_hash_table_lookup(
proxy_table
, session);
78
79
if
(proxy == NULL) {
80
return
;
81
}
82
crm_trace
(
"ending session ID %s"
, proxy->
session_id
);
83
84
if
(proxy->
source
) {
85
mainloop_del_ipc_client
(proxy->
source
);
86
}
87
}
88
89
void
90
remote_proxy_free
(gpointer
data
)
91
{
92
remote_proxy_t
*proxy =
data
;
93
94
crm_trace
(
"freed proxy session ID %s"
, proxy->
session_id
);
95
free(proxy->
node_name
);
96
free(proxy->
session_id
);
97
free(proxy);
98
}
99
100
services.h
Services API.
crm.h
A dumping ground.
T_LRMD_IPC_PROXY
#define T_LRMD_IPC_PROXY
Definition:
lrmd.h:106
F_LRMD_IPC_SESSION
#define F_LRMD_IPC_SESSION
Definition:
lrmd.h:95
lrmd.h
Local Resource Manager.
remote_proxy_relay_response
void remote_proxy_relay_response(lrmd_t *lrmd, const char *session_id, xmlNode *msg, int msg_id)
Definition:
proxy_common.c:62
mainloop.h
Wrappers for and extensions to glib mainloop.
F_LRMD_IPC_OP
#define F_LRMD_IPC_OP
Definition:
lrmd.h:93
F_LRMD_IPC_MSG_ID
#define F_LRMD_IPC_MSG_ID
Definition:
lrmd.h:100
remote_proxy_free
void remote_proxy_free(gpointer data)
Definition:
proxy_common.c:90
remote_proxy_end_session
void remote_proxy_end_session(const char *session)
Definition:
proxy_common.c:75
crm_internal.h
crm_trace
#define crm_trace(fmt, args...)
Definition:
logging.h:254
crm_log_xml_explicit
#define crm_log_xml_explicit(xml, text)
Definition:
logging.h:264
create_xml_node
xmlNode * create_xml_node(xmlNode *parent, const char *name)
Definition:
xml.c:2793
mainloop_del_ipc_client
void mainloop_del_ipc_client(mainloop_io_t *client)
Definition:
mainloop.c:791
remote_proxy_s::node_name
char * node_name
Definition:
crm_internal.h:372
add_message_xml
gboolean add_message_xml(xmlNode *msg, const char *field, xmlNode *xml)
Definition:
xml.c:3332
free_xml
void free_xml(xmlNode *child)
Definition:
xml.c:2848
lrmd_internal_proxy_send
int lrmd_internal_proxy_send(lrmd_t *lrmd, xmlNode *msg)
Definition:
lrmd_client.c:1540
msg_xml.h
crm_xml_add
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Definition:
xml.c:2695
crm_xml_add_int
const char * crm_xml_add_int(xmlNode *node, const char *name, int value)
Definition:
xml.c:2783
status.h
remote_proxy_relay_event
void remote_proxy_relay_event(lrmd_t *lrmd, const char *session_id, xmlNode *msg)
Definition:
proxy_common.c:49
cib.h
Cluster Configuration.
remote_proxy_s::source
mainloop_io_t * source
Definition:
crm_internal.h:378
remote_proxy_s
Definition:
crm_internal.h:371
data
char data[0]
Definition:
internal.h:58
lrmd_s
Definition:
lrmd.h:439
proxy_table
GHashTable * proxy_table
Definition:
proxy_common.c:35
remote_proxy_s::session_id
char * session_id
Definition:
crm_internal.h:373
remote_proxy_notify_destroy
void remote_proxy_notify_destroy(lrmd_t *lrmd, const char *session_id)
Definition:
proxy_common.c:38
F_LRMD_IPC_MSG
#define F_LRMD_IPC_MSG
Definition:
lrmd.h:99
Generated on Tue Apr 5 2016 16:16:06 for pacemaker by
1.8.6