summaryrefslogtreecommitdiffstats
path: root/ctdb/client/client_message_sync.c
blob: f4d244122a9c708f4fd7e393daa3f632a8552b8d (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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
/*
   CTDB client code

   Copyright (C) Amitay Isaacs  2015

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, see <http://www.gnu.org/licenses/>.
*/

#include "replace.h"
#include "system/network.h"
#include "system/filesys.h"

#include <talloc.h>
#include <tevent.h>
#include <tdb.h>

#include "common/logging.h"

#include "lib/util/debug.h"

#include "protocol/protocol.h"
#include "protocol/protocol_api.h"
#include "client/client_private.h"
#include "client/client.h"
#include "client/client_sync.h"

int ctdb_message_recd_update_ip(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
				struct ctdb_client_context *client,
				int destnode, struct ctdb_public_ip *pubip)
{
	struct ctdb_req_message message;
	int ret;

	message.srvid = CTDB_SRVID_RECD_UPDATE_IP;
	message.data.pubip = pubip;

	ret = ctdb_client_message(mem_ctx, ev, client, destnode, &message);
	if (ret != 0) {
		DEBUG(DEBUG_ERR,
		      ("Message RECD_UPDATE_IP failed to node %u\n",
		       destnode));
	}

	return ret;
}

int ctdb_message_mem_dump(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
			  struct ctdb_client_context *client,
			  int destnode, struct ctdb_srvid_message *msg)
{
	struct ctdb_req_message message;
	int ret;

	message.srvid = CTDB_SRVID_MEM_DUMP;
	message.data.msg = msg;

	ret = ctdb_client_message(mem_ctx, ev, client, destnode, &message);
	if (ret != 0) {
		DEBUG(DEBUG_ERR,
		      ("Message MEM_DUMP failed to node %u\n", destnode));
	}

	return ret;
}

int ctdb_message_reload_nodes(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
			      struct ctdb_client_context *client,
			      int destnode)
{
	struct ctdb_req_message message;
	int ret;

	message.srvid = CTDB_SRVID_RELOAD_NODES;

	ret = ctdb_client_message(mem_ctx, ev, client, destnode, &message);
	if (ret != 0) {
		DEBUG(DEBUG_ERR,
		      ("Message RELOAD_NODES failed to node %u\n", destnode));
	}

	return ret;
}

int ctdb_message_takeover_run(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
			      struct ctdb_client_context *client,
			      int destnode, struct ctdb_srvid_message *msg)
{
	struct ctdb_req_message message;
	int ret;

	message.srvid = CTDB_SRVID_TAKEOVER_RUN;
	message.data.msg = msg;

	ret = ctdb_client_message(mem_ctx, ev, client, destnode, &message);
	if (ret != 0) {
		DEBUG(DEBUG_ERR,
		      ("Message TAKEOVER_RUN failed to node %u\n", destnode));
	}

	return ret;
}

int ctdb_message_rebalance_node(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
				struct ctdb_client_context *client,
				int destnode, uint32_t pnn)
{
	struct ctdb_req_message message;
	int ret;

	message.srvid = CTDB_SRVID_REBALANCE_NODE;
	message.data.pnn = pnn;

	ret = ctdb_client_message(mem_ctx, ev, client, destnode, &message);
	if (ret != 0) {
		DEBUG(DEBUG_ERR,
		      ("Message REBALANCE_NODE failed to node %u\n",
		       destnode));
	}

	return ret;
}

int ctdb_message_disable_takeover_runs(TALLOC_CTX *mem_ctx,
				       struct tevent_context *ev,
				       struct ctdb_client_context *client,
				       int destnode,
				       struct ctdb_disable_message *disable)
{
	struct ctdb_req_message message;
	int ret;

	message.srvid = CTDB_SRVID_DISABLE_TAKEOVER_RUNS;
	message.data.disable = disable;

	ret = ctdb_client_message(mem_ctx, ev, client, destnode, &message);
	if (ret != 0) {
		DEBUG(DEBUG_ERR,
		      ("Message DISABLE_TAKEOVER_RUNS failed to node %u\n",
		       destnode));
	}

	return ret;
}

int ctdb_message_disable_recoveries(TALLOC_CTX *mem_ctx,
				    struct tevent_context *ev,
				    struct ctdb_client_context *client,
				    int destnode,
				    struct ctdb_disable_message *disable)
{
	struct ctdb_req_message message;
	int ret;

	message.srvid = CTDB_SRVID_DISABLE_RECOVERIES;
	message.data.disable = disable;

	ret = ctdb_client_message(mem_ctx, ev, client, destnode, &message);
	if (ret != 0) {
		DEBUG(DEBUG_ERR,
		      ("Message DISABLE_RECOVERIES failed to node %u\n",
		       destnode));
	}

	return ret;
}

int ctdb_message_disable_ip_check(TALLOC_CTX *mem_ctx,
				  struct tevent_context *ev,
				  struct ctdb_client_context *client,
				  int destnode, uint32_t timeout)
{
	struct ctdb_req_message message;
	int ret;

	message.srvid = CTDB_SRVID_DISABLE_IP_CHECK;
	message.data.timeout = timeout;

	ret = ctdb_client_message(mem_ctx, ev, client, destnode, &message);
	if (ret != 0) {
		DEBUG(DEBUG_ERR,
		      ("Message DISABLE_IP_CHECK failed to node %u\n",
		       destnode));
	}

	return ret;
}