mirror of
https://github.com/samba-team/samba.git
synced 2025-01-14 19:24:43 +03:00
Merge remote branch 'martins/hashinclude'
(This used to be ctdb commit 0f6991010cf4e1f0dd9f39243bcc8fff5dcc0524)
This commit is contained in:
commit
8017393444
@ -217,11 +217,19 @@ tests/bin/ctdb_transaction: $(CTDB_CLIENT_OBJ) tests/src/ctdb_transaction.o
|
|||||||
@echo Linking $@
|
@echo Linking $@
|
||||||
@$(CC) $(CFLAGS) -o $@ tests/src/ctdb_transaction.o $(CTDB_CLIENT_OBJ) $(LIB_FLAGS)
|
@$(CC) $(CFLAGS) -o $@ tests/src/ctdb_transaction.o $(CTDB_CLIENT_OBJ) $(LIB_FLAGS)
|
||||||
|
|
||||||
CTDB_TAKEOVER_OBJ = $(CTDB_SERVER_OBJ:server/ctdbd.o=)
|
CTDB_SERVER_MOST_OBJ = $(CTDB_SERVER_OBJ:server/ctdbd.o=)
|
||||||
|
CTDB_TEST_C = $(CTDB_SERVER_MOST_OBJ:.o=.c) tests/src/ctdbd_test.c
|
||||||
|
CTDB_TEST_OBJ = @TALLOC_OBJ@ @TDB_OBJ@ \
|
||||||
|
@LIBREPLACEOBJ@ $(EXTRA_OBJ) @TEVENT_OBJ@
|
||||||
|
|
||||||
tests/bin/ctdb_takeover_tests: $(CTDB_TAKEOVER_OBJ) tests/src/ctdb_takeover_tests.o
|
CTDB_TEST_DEPENDS = $(CTDB_TEST_OBJ) $(CTDB_SERVER_MOST_C) \
|
||||||
|
tests/src/ctdbd_test.c
|
||||||
|
|
||||||
|
tests/src/ctdb_takeover_tests.o: tests/src/ctdb_takeover_tests.c $(CTDB_TEST_C)
|
||||||
|
|
||||||
|
tests/bin/ctdb_takeover_tests: $(CTDB_TEST_OBJ) tests/src/ctdb_takeover_tests.o
|
||||||
@echo Linking $@
|
@echo Linking $@
|
||||||
@$(CC) $(CFLAGS) -o $@ tests/src/ctdb_takeover_tests.o $(CTDB_TAKEOVER_OBJ) $(LIB_FLAGS)
|
@$(CC) $(CFLAGS) -o $@ tests/src/ctdb_takeover_tests.o $(CTDB_TEST_OBJ) $(LIB_FLAGS)
|
||||||
|
|
||||||
tests/bin/ibwrapper_test: $(CTDB_CLIENT_OBJ) ib/ibwrapper_test.o
|
tests/bin/ibwrapper_test: $(CTDB_CLIENT_OBJ) ib/ibwrapper_test.o
|
||||||
@echo Linking $@
|
@echo Linking $@
|
||||||
|
@ -978,7 +978,7 @@ static void ctdb_client_reply_control(struct ctdb_context *ctdb,
|
|||||||
/*
|
/*
|
||||||
destroy a ctdb_control in client
|
destroy a ctdb_control in client
|
||||||
*/
|
*/
|
||||||
static int ctdb_control_destructor(struct ctdb_client_control_state *state)
|
static int ctdb_client_control_destructor(struct ctdb_client_control_state *state)
|
||||||
{
|
{
|
||||||
ctdb_reqid_remove(state->ctdb, state->reqid);
|
ctdb_reqid_remove(state->ctdb, state->reqid);
|
||||||
return 0;
|
return 0;
|
||||||
@ -1035,7 +1035,7 @@ struct ctdb_client_control_state *ctdb_control_send(struct ctdb_context *ctdb,
|
|||||||
state->state = CTDB_CONTROL_WAIT;
|
state->state = CTDB_CONTROL_WAIT;
|
||||||
state->errormsg = NULL;
|
state->errormsg = NULL;
|
||||||
|
|
||||||
talloc_set_destructor(state, ctdb_control_destructor);
|
talloc_set_destructor(state, ctdb_client_control_destructor);
|
||||||
|
|
||||||
len = offsetof(struct ctdb_req_control, data) + data.dsize;
|
len = offsetof(struct ctdb_req_control, data) + data.dsize;
|
||||||
c = ctdbd_allocate_pkt(ctdb, state, CTDB_REQ_CONTROL,
|
c = ctdbd_allocate_pkt(ctdb, state, CTDB_REQ_CONTROL,
|
||||||
@ -1883,44 +1883,6 @@ int ctdb_statistics_reset(struct ctdb_context *ctdb, uint32_t destnode)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
this is the dummy null procedure that all databases support
|
|
||||||
*/
|
|
||||||
static int ctdb_null_func(struct ctdb_call_info *call)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
this is a plain fetch procedure that all databases support
|
|
||||||
*/
|
|
||||||
static int ctdb_fetch_func(struct ctdb_call_info *call)
|
|
||||||
{
|
|
||||||
call->reply_data = &call->record_data;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
this is a plain fetch procedure that all databases support
|
|
||||||
this returns the full record including the ltdb header
|
|
||||||
*/
|
|
||||||
static int ctdb_fetch_with_header_func(struct ctdb_call_info *call)
|
|
||||||
{
|
|
||||||
call->reply_data = talloc(call, TDB_DATA);
|
|
||||||
if (call->reply_data == NULL) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
call->reply_data->dsize = sizeof(struct ctdb_ltdb_header) + call->record_data.dsize;
|
|
||||||
call->reply_data->dptr = talloc_size(call->reply_data, call->reply_data->dsize);
|
|
||||||
if (call->reply_data->dptr == NULL) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
memcpy(call->reply_data->dptr, call->header, sizeof(struct ctdb_ltdb_header));
|
|
||||||
memcpy(&call->reply_data->dptr[sizeof(struct ctdb_ltdb_header)], call->record_data.dptr, call->record_data.dsize);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
attach to a specific database - client call
|
attach to a specific database - client call
|
||||||
*/
|
*/
|
||||||
@ -4131,7 +4093,7 @@ int switch_from_server_to_client(struct ctdb_context *ctdb, const char *fmt, ...
|
|||||||
int ctdb_ctrl_getscriptstatus(struct ctdb_context *ctdb,
|
int ctdb_ctrl_getscriptstatus(struct ctdb_context *ctdb,
|
||||||
struct timeval timeout, uint32_t destnode,
|
struct timeval timeout, uint32_t destnode,
|
||||||
TALLOC_CTX *mem_ctx, enum ctdb_eventscript_call type,
|
TALLOC_CTX *mem_ctx, enum ctdb_eventscript_call type,
|
||||||
struct ctdb_scripts_wire **script_status)
|
struct ctdb_scripts_wire **scripts)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
TDB_DATA outdata, indata;
|
TDB_DATA outdata, indata;
|
||||||
@ -4150,9 +4112,9 @@ int ctdb_ctrl_getscriptstatus(struct ctdb_context *ctdb,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (outdata.dsize == 0) {
|
if (outdata.dsize == 0) {
|
||||||
*script_status = NULL;
|
*scripts = NULL;
|
||||||
} else {
|
} else {
|
||||||
*script_status = (struct ctdb_scripts_wire *)talloc_memdup(mem_ctx, outdata.dptr, outdata.dsize);
|
*scripts = (struct ctdb_scripts_wire *)talloc_memdup(mem_ctx, outdata.dptr, outdata.dsize);
|
||||||
talloc_free(outdata.dptr);
|
talloc_free(outdata.dptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,4 +295,41 @@ void ctdb_trackingdb_traverse(struct ctdb_context *ctdb, TDB_DATA data, ctdb_tra
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
this is the dummy null procedure that all databases support
|
||||||
|
*/
|
||||||
|
int ctdb_null_func(struct ctdb_call_info *call)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
this is a plain fetch procedure that all databases support
|
||||||
|
*/
|
||||||
|
int ctdb_fetch_func(struct ctdb_call_info *call)
|
||||||
|
{
|
||||||
|
call->reply_data = &call->record_data;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
this is a plain fetch procedure that all databases support
|
||||||
|
this returns the full record including the ltdb header
|
||||||
|
*/
|
||||||
|
int ctdb_fetch_with_header_func(struct ctdb_call_info *call)
|
||||||
|
{
|
||||||
|
call->reply_data = talloc(call, TDB_DATA);
|
||||||
|
if (call->reply_data == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
call->reply_data->dsize = sizeof(struct ctdb_ltdb_header) + call->record_data.dsize;
|
||||||
|
call->reply_data->dptr = talloc_size(call->reply_data, call->reply_data->dsize);
|
||||||
|
if (call->reply_data->dptr == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
memcpy(call->reply_data->dptr, call->header, sizeof(struct ctdb_ltdb_header));
|
||||||
|
memcpy(&call->reply_data->dptr[sizeof(struct ctdb_ltdb_header)], call->record_data.dptr, call->record_data.dsize);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef _RB_TREE_H
|
||||||
|
#define _RB_TREE_H
|
||||||
|
|
||||||
#define TRBT_RED 0x00
|
#define TRBT_RED 0x00
|
||||||
#define TRBT_BLACK 0x01
|
#define TRBT_BLACK 0x01
|
||||||
@ -85,3 +86,5 @@ int trbt_traversearray32(trbt_tree_t *tree, uint32_t keylen, int (*callback)(voi
|
|||||||
/* Lookup the first node in the tree with a key based on an array of uint32
|
/* Lookup the first node in the tree with a key based on an array of uint32
|
||||||
and return a pointer to data or NULL */
|
and return a pointer to data or NULL */
|
||||||
void *trbt_findfirstarray32(trbt_tree_t *tree, uint32_t keylen);
|
void *trbt_findfirstarray32(trbt_tree_t *tree, uint32_t keylen);
|
||||||
|
|
||||||
|
#endif /* _RB_TREE_H */
|
||||||
|
@ -1432,32 +1432,6 @@ struct ctdb_public_ip_list {
|
|||||||
uint32_t pnn;
|
uint32_t pnn;
|
||||||
ctdb_sock_addr addr;
|
ctdb_sock_addr addr;
|
||||||
};
|
};
|
||||||
uint32_t ip_distance(ctdb_sock_addr *ip1, ctdb_sock_addr *ip2);
|
|
||||||
uint32_t ip_distance_2_sum(ctdb_sock_addr *ip,
|
|
||||||
struct ctdb_public_ip_list *ips,
|
|
||||||
int pnn);
|
|
||||||
uint32_t lcp2_imbalance(struct ctdb_public_ip_list * all_ips, int pnn);
|
|
||||||
void lcp2_init(struct ctdb_context * tmp_ctx,
|
|
||||||
struct ctdb_node_map * nodemap,
|
|
||||||
uint32_t mask,
|
|
||||||
struct ctdb_public_ip_list *all_ips,
|
|
||||||
uint32_t **lcp2_imbalances,
|
|
||||||
bool **newly_healthy);
|
|
||||||
void lcp2_allocate_unassigned(struct ctdb_context *ctdb,
|
|
||||||
struct ctdb_node_map *nodemap,
|
|
||||||
uint32_t mask,
|
|
||||||
struct ctdb_public_ip_list *all_ips,
|
|
||||||
uint32_t *lcp2_imbalances);
|
|
||||||
bool lcp2_failback(struct ctdb_context *ctdb,
|
|
||||||
struct ctdb_node_map *nodemap,
|
|
||||||
uint32_t mask,
|
|
||||||
struct ctdb_public_ip_list *all_ips,
|
|
||||||
uint32_t *lcp2_imbalances,
|
|
||||||
bool *newly_healthy);
|
|
||||||
void ctdb_takeover_run_core(struct ctdb_context *ctdb,
|
|
||||||
struct ctdb_node_map *nodemap,
|
|
||||||
struct ctdb_public_ip_list **all_ips_p);
|
|
||||||
|
|
||||||
int ctdb_trackingdb_add_pnn(struct ctdb_context *ctdb, TDB_DATA *data, uint32_t pnn);
|
int ctdb_trackingdb_add_pnn(struct ctdb_context *ctdb, TDB_DATA *data, uint32_t pnn);
|
||||||
|
|
||||||
typedef void (*ctdb_trackingdb_cb)(struct ctdb_context *ctdb, uint32_t pnn, void *private_data);
|
typedef void (*ctdb_trackingdb_cb)(struct ctdb_context *ctdb, uint32_t pnn, void *private_data);
|
||||||
@ -1472,4 +1446,10 @@ int ctdb_add_revoke_deferred_call(struct ctdb_context *ctdb, struct ctdb_db_cont
|
|||||||
|
|
||||||
int ctdb_set_db_readonly(struct ctdb_context *ctdb, struct ctdb_db_context *ctdb_db);
|
int ctdb_set_db_readonly(struct ctdb_context *ctdb, struct ctdb_db_context *ctdb_db);
|
||||||
|
|
||||||
|
int ctdb_null_func(struct ctdb_call_info *call);
|
||||||
|
|
||||||
|
int ctdb_fetch_func(struct ctdb_call_info *call);
|
||||||
|
|
||||||
|
int ctdb_fetch_with_header_func(struct ctdb_call_info *call);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
#ifndef _CTDB_INCLUDES_H
|
||||||
|
#define _CTDB_INCLUDES_H
|
||||||
|
|
||||||
#define HAVE_UNIXSOCKET 1
|
#define HAVE_UNIXSOCKET 1
|
||||||
|
|
||||||
#include "replace.h"
|
#include "replace.h"
|
||||||
@ -58,3 +61,5 @@ _PUBLIC_ int set_blocking(int fd, BOOL set);
|
|||||||
|
|
||||||
#include "lib/util/debug.h"
|
#include "lib/util/debug.h"
|
||||||
#include "lib/util/util.h"
|
#include "lib/util/util.h"
|
||||||
|
|
||||||
|
#endif /* _CTDB_INCLUDES_H */
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef _DB_WRAP_H
|
||||||
|
#define _DB_WRAP_H
|
||||||
|
|
||||||
struct tdb_wrap {
|
struct tdb_wrap {
|
||||||
struct tdb_context *tdb;
|
struct tdb_context *tdb;
|
||||||
@ -30,3 +32,5 @@ struct tdb_wrap {
|
|||||||
struct tdb_wrap *tdb_wrap_open(TALLOC_CTX *mem_ctx,
|
struct tdb_wrap *tdb_wrap_open(TALLOC_CTX *mem_ctx,
|
||||||
const char *name, int hash_size, int tdb_flags,
|
const char *name, int hash_size, int tdb_flags,
|
||||||
int open_flags, mode_t mode);
|
int open_flags, mode_t mode);
|
||||||
|
|
||||||
|
#endif /* _DB_WRAP_H */
|
||||||
|
@ -32,45 +32,6 @@
|
|||||||
|
|
||||||
#define PERSISTENT_HEALTH_TDB "persistent_health.tdb"
|
#define PERSISTENT_HEALTH_TDB "persistent_health.tdb"
|
||||||
|
|
||||||
/*
|
|
||||||
this is the dummy null procedure that all databases support
|
|
||||||
*/
|
|
||||||
static int ctdb_null_func(struct ctdb_call_info *call)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
this is a plain fetch procedure that all databases support
|
|
||||||
*/
|
|
||||||
static int ctdb_fetch_func(struct ctdb_call_info *call)
|
|
||||||
{
|
|
||||||
call->reply_data = &call->record_data;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
this is a plain fetch procedure that all databases support
|
|
||||||
this returns the full record including the ltdb header
|
|
||||||
*/
|
|
||||||
static int ctdb_fetch_with_header_func(struct ctdb_call_info *call)
|
|
||||||
{
|
|
||||||
call->reply_data = talloc(call, TDB_DATA);
|
|
||||||
if (call->reply_data == NULL) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
call->reply_data->dsize = sizeof(struct ctdb_ltdb_header) + call->record_data.dsize;
|
|
||||||
call->reply_data->dptr = talloc_size(call->reply_data, call->reply_data->dsize);
|
|
||||||
if (call->reply_data->dptr == NULL) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
memcpy(call->reply_data->dptr, call->header, sizeof(struct ctdb_ltdb_header));
|
|
||||||
memcpy(&call->reply_data->dptr[sizeof(struct ctdb_ltdb_header)], call->record_data.dptr, call->record_data.dsize);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* write a record to a normal database
|
* write a record to a normal database
|
||||||
*
|
*
|
||||||
|
@ -59,21 +59,21 @@ int32_t ctdb_control_get_stat_history(struct ctdb_context *ctdb,
|
|||||||
TDB_DATA *outdata)
|
TDB_DATA *outdata)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
struct ctdb_statistics_wire *stat;
|
struct ctdb_statistics_wire *s;
|
||||||
|
|
||||||
len = offsetof(struct ctdb_statistics_wire, stats) + MAX_STAT_HISTORY*sizeof(struct ctdb_statistics);
|
len = offsetof(struct ctdb_statistics_wire, stats) + MAX_STAT_HISTORY*sizeof(struct ctdb_statistics);
|
||||||
|
|
||||||
stat = talloc_size(outdata, len);
|
s = talloc_size(outdata, len);
|
||||||
if (stat == NULL) {
|
if (s == NULL) {
|
||||||
DEBUG(DEBUG_ERR,(__location__ " Failed to allocate statistics history structure\n"));
|
DEBUG(DEBUG_ERR,(__location__ " Failed to allocate statistics history structure\n"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
stat->num = MAX_STAT_HISTORY;
|
s->num = MAX_STAT_HISTORY;
|
||||||
memcpy(&stat->stats[0], &ctdb->statistics_history[0], sizeof(ctdb->statistics_history));
|
memcpy(&s->stats[0], &ctdb->statistics_history[0], sizeof(ctdb->statistics_history));
|
||||||
|
|
||||||
outdata->dsize = len;
|
outdata->dsize = len;
|
||||||
outdata->dptr = (uint8_t *)stat;
|
outdata->dptr = (uint8_t *)s;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1313,13 +1313,12 @@ create_merged_ip_list(struct ctdb_context *ctdb)
|
|||||||
* It is calculated by XOR-ing the 2 IPs together and counting the
|
* It is calculated by XOR-ing the 2 IPs together and counting the
|
||||||
* number of leading zeroes. The implementation means that all
|
* number of leading zeroes. The implementation means that all
|
||||||
* addresses end up being 128 bits long.
|
* addresses end up being 128 bits long.
|
||||||
* Not static, so we can easily link it into a unit test.
|
|
||||||
*
|
*
|
||||||
* FIXME? Should we consider IPv4 and IPv6 separately given that the
|
* FIXME? Should we consider IPv4 and IPv6 separately given that the
|
||||||
* 12 bytes of 0 prefix padding will hurt the algorithm if there are
|
* 12 bytes of 0 prefix padding will hurt the algorithm if there are
|
||||||
* lots of nodes and IP addresses?
|
* lots of nodes and IP addresses?
|
||||||
*/
|
*/
|
||||||
uint32_t ip_distance(ctdb_sock_addr *ip1, ctdb_sock_addr *ip2)
|
static uint32_t ip_distance(ctdb_sock_addr *ip1, ctdb_sock_addr *ip2)
|
||||||
{
|
{
|
||||||
uint32_t ip1_k[IP_KEYLEN];
|
uint32_t ip1_k[IP_KEYLEN];
|
||||||
uint32_t *t;
|
uint32_t *t;
|
||||||
@ -1351,9 +1350,8 @@ uint32_t ip_distance(ctdb_sock_addr *ip1, ctdb_sock_addr *ip2)
|
|||||||
/* Calculate the IP distance for the given IP relative to IPs on the
|
/* Calculate the IP distance for the given IP relative to IPs on the
|
||||||
given node. The ips argument is generally the all_ips variable
|
given node. The ips argument is generally the all_ips variable
|
||||||
used in the main part of the algorithm.
|
used in the main part of the algorithm.
|
||||||
* Not static, so we can easily link it into a unit test.
|
|
||||||
*/
|
*/
|
||||||
uint32_t ip_distance_2_sum(ctdb_sock_addr *ip,
|
static uint32_t ip_distance_2_sum(ctdb_sock_addr *ip,
|
||||||
struct ctdb_public_ip_list *ips,
|
struct ctdb_public_ip_list *ips,
|
||||||
int pnn)
|
int pnn)
|
||||||
{
|
{
|
||||||
@ -1389,9 +1387,8 @@ uint32_t ip_distance_2_sum(ctdb_sock_addr *ip,
|
|||||||
|
|
||||||
/* Return the LCP2 imbalance metric for addresses currently assigned
|
/* Return the LCP2 imbalance metric for addresses currently assigned
|
||||||
to the given node.
|
to the given node.
|
||||||
* Not static, so we can easily link it into a unit test.
|
|
||||||
*/
|
*/
|
||||||
uint32_t lcp2_imbalance(struct ctdb_public_ip_list * all_ips, int pnn)
|
static uint32_t lcp2_imbalance(struct ctdb_public_ip_list * all_ips, int pnn)
|
||||||
{
|
{
|
||||||
struct ctdb_public_ip_list *t;
|
struct ctdb_public_ip_list *t;
|
||||||
|
|
||||||
@ -1412,9 +1409,8 @@ uint32_t lcp2_imbalance(struct ctdb_public_ip_list * all_ips, int pnn)
|
|||||||
|
|
||||||
/* Allocate any unassigned IPs just by looping through the IPs and
|
/* Allocate any unassigned IPs just by looping through the IPs and
|
||||||
* finding the best node for each.
|
* finding the best node for each.
|
||||||
* Not static, so we can easily link it into a unit test.
|
|
||||||
*/
|
*/
|
||||||
void basic_allocate_unassigned(struct ctdb_context *ctdb,
|
static void basic_allocate_unassigned(struct ctdb_context *ctdb,
|
||||||
struct ctdb_node_map *nodemap,
|
struct ctdb_node_map *nodemap,
|
||||||
uint32_t mask,
|
uint32_t mask,
|
||||||
struct ctdb_public_ip_list *all_ips)
|
struct ctdb_public_ip_list *all_ips)
|
||||||
@ -1435,9 +1431,8 @@ void basic_allocate_unassigned(struct ctdb_context *ctdb,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Basic non-deterministic rebalancing algorithm.
|
/* Basic non-deterministic rebalancing algorithm.
|
||||||
* Not static, so we can easily link it into a unit test.
|
|
||||||
*/
|
*/
|
||||||
bool basic_failback(struct ctdb_context *ctdb,
|
static bool basic_failback(struct ctdb_context *ctdb,
|
||||||
struct ctdb_node_map *nodemap,
|
struct ctdb_node_map *nodemap,
|
||||||
uint32_t mask,
|
uint32_t mask,
|
||||||
struct ctdb_public_ip_list *all_ips,
|
struct ctdb_public_ip_list *all_ips,
|
||||||
@ -1536,9 +1531,8 @@ bool basic_failback(struct ctdb_context *ctdb,
|
|||||||
|
|
||||||
/* Do necessary LCP2 initialisation. Bury it in a function here so
|
/* Do necessary LCP2 initialisation. Bury it in a function here so
|
||||||
* that we can unit test it.
|
* that we can unit test it.
|
||||||
* Not static, so we can easily link it into a unit test.
|
|
||||||
*/
|
*/
|
||||||
void lcp2_init(struct ctdb_context * tmp_ctx,
|
static void lcp2_init(struct ctdb_context * tmp_ctx,
|
||||||
struct ctdb_node_map * nodemap,
|
struct ctdb_node_map * nodemap,
|
||||||
uint32_t mask,
|
uint32_t mask,
|
||||||
struct ctdb_public_ip_list *all_ips,
|
struct ctdb_public_ip_list *all_ips,
|
||||||
@ -1570,9 +1564,8 @@ void lcp2_init(struct ctdb_context * tmp_ctx,
|
|||||||
|
|
||||||
/* Allocate any unassigned addresses using the LCP2 algorithm to find
|
/* Allocate any unassigned addresses using the LCP2 algorithm to find
|
||||||
* the IP/node combination that will cost the least.
|
* the IP/node combination that will cost the least.
|
||||||
* Not static, so we can easily link it into a unit test.
|
|
||||||
*/
|
*/
|
||||||
void lcp2_allocate_unassigned(struct ctdb_context *ctdb,
|
static void lcp2_allocate_unassigned(struct ctdb_context *ctdb,
|
||||||
struct ctdb_node_map *nodemap,
|
struct ctdb_node_map *nodemap,
|
||||||
uint32_t mask,
|
uint32_t mask,
|
||||||
struct ctdb_public_ip_list *all_ips,
|
struct ctdb_public_ip_list *all_ips,
|
||||||
@ -1669,10 +1662,8 @@ void lcp2_allocate_unassigned(struct ctdb_context *ctdb,
|
|||||||
/* LCP2 algorithm for rebalancing the cluster. Given a candidate node
|
/* LCP2 algorithm for rebalancing the cluster. Given a candidate node
|
||||||
* to move IPs from, determines the best IP/destination node
|
* to move IPs from, determines the best IP/destination node
|
||||||
* combination to move from the source node.
|
* combination to move from the source node.
|
||||||
*
|
|
||||||
* Not static, so we can easily link it into a unit test.
|
|
||||||
*/
|
*/
|
||||||
bool lcp2_failback_candidate(struct ctdb_context *ctdb,
|
static bool lcp2_failback_candidate(struct ctdb_context *ctdb,
|
||||||
struct ctdb_node_map *nodemap,
|
struct ctdb_node_map *nodemap,
|
||||||
struct ctdb_public_ip_list *all_ips,
|
struct ctdb_public_ip_list *all_ips,
|
||||||
int srcnode,
|
int srcnode,
|
||||||
@ -1765,7 +1756,7 @@ struct lcp2_imbalance_pnn {
|
|||||||
int pnn;
|
int pnn;
|
||||||
};
|
};
|
||||||
|
|
||||||
int lcp2_cmp_imbalance_pnn(const void * a, const void * b)
|
static int lcp2_cmp_imbalance_pnn(const void * a, const void * b)
|
||||||
{
|
{
|
||||||
const struct lcp2_imbalance_pnn * lipa = (const struct lcp2_imbalance_pnn *) a;
|
const struct lcp2_imbalance_pnn * lipa = (const struct lcp2_imbalance_pnn *) a;
|
||||||
const struct lcp2_imbalance_pnn * lipb = (const struct lcp2_imbalance_pnn *) b;
|
const struct lcp2_imbalance_pnn * lipb = (const struct lcp2_imbalance_pnn *) b;
|
||||||
@ -1782,10 +1773,8 @@ int lcp2_cmp_imbalance_pnn(const void * a, const void * b)
|
|||||||
/* LCP2 algorithm for rebalancing the cluster. This finds the source
|
/* LCP2 algorithm for rebalancing the cluster. This finds the source
|
||||||
* node with the highest LCP2 imbalance, and then determines the best
|
* node with the highest LCP2 imbalance, and then determines the best
|
||||||
* IP/destination node combination to move from the source node.
|
* IP/destination node combination to move from the source node.
|
||||||
*
|
|
||||||
* Not static, so we can easily link it into a unit test.
|
|
||||||
*/
|
*/
|
||||||
bool lcp2_failback(struct ctdb_context *ctdb,
|
static bool lcp2_failback(struct ctdb_context *ctdb,
|
||||||
struct ctdb_node_map *nodemap,
|
struct ctdb_node_map *nodemap,
|
||||||
uint32_t mask,
|
uint32_t mask,
|
||||||
struct ctdb_public_ip_list *all_ips,
|
struct ctdb_public_ip_list *all_ips,
|
||||||
@ -1847,10 +1836,8 @@ bool lcp2_failback(struct ctdb_context *ctdb,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The calculation part of the IP allocation algorithm.
|
/* The calculation part of the IP allocation algorithm. */
|
||||||
* Not static, so we can easily link it into a unit test.
|
static void ctdb_takeover_run_core(struct ctdb_context *ctdb,
|
||||||
*/
|
|
||||||
void ctdb_takeover_run_core(struct ctdb_context *ctdb,
|
|
||||||
struct ctdb_node_map *nodemap,
|
struct ctdb_node_map *nodemap,
|
||||||
struct ctdb_public_ip_list **all_ips_p)
|
struct ctdb_public_ip_list **all_ips_p)
|
||||||
{
|
{
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef _CTDB_TCP_H
|
||||||
|
#define _CTDB_TCP_H
|
||||||
|
|
||||||
/* ctdb_tcp main state */
|
/* ctdb_tcp main state */
|
||||||
struct ctdb_tcp {
|
struct ctdb_tcp {
|
||||||
@ -54,3 +56,5 @@ void ctdb_tcp_tnode_cb(uint8_t *data, size_t cnt, void *private_data);
|
|||||||
void ctdb_tcp_stop_connection(struct ctdb_node *node);
|
void ctdb_tcp_stop_connection(struct ctdb_node *node);
|
||||||
|
|
||||||
#define CTDB_TCP_ALIGNMENT 8
|
#define CTDB_TCP_ALIGNMENT 8
|
||||||
|
|
||||||
|
#endif /* _CTDB_TCP_H */
|
||||||
|
@ -17,21 +17,12 @@
|
|||||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#include "ctdbd_test.c"
|
||||||
#include "../include/ctdb_private.h"
|
|
||||||
|
|
||||||
/* This is lazy... but it is test code! */
|
/* This is lazy... but it is test code! */
|
||||||
#define CTDB_TEST_MAX_NODES 256
|
#define CTDB_TEST_MAX_NODES 256
|
||||||
#define CTDB_TEST_MAX_IPS 256
|
#define CTDB_TEST_MAX_IPS 256
|
||||||
|
|
||||||
/*
|
|
||||||
* Need these, since they're defined in ctdbd.c but we can't link
|
|
||||||
* that.
|
|
||||||
*/
|
|
||||||
int script_log_level;
|
|
||||||
bool fast_start;
|
|
||||||
void ctdb_load_nodes_file(struct ctdb_context *ctdb) {}
|
|
||||||
|
|
||||||
/* Format of each line is "IP pnn" - the separator has to be at least
|
/* Format of each line is "IP pnn" - the separator has to be at least
|
||||||
* 1 space (not a tab or whatever - a space!).
|
* 1 space (not a tab or whatever - a space!).
|
||||||
*/
|
*/
|
||||||
|
94
ctdb/tests/src/ctdbd_test.c
Normal file
94
ctdb/tests/src/ctdbd_test.c
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
/*
|
||||||
|
ctdbd test include file
|
||||||
|
|
||||||
|
Copyright (C) Martin Schwenke 2011
|
||||||
|
|
||||||
|
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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _CTDBD_TEST_C
|
||||||
|
#define _CTDBD_TEST_C
|
||||||
|
|
||||||
|
#include "includes.h"
|
||||||
|
#include "lib/tevent/tevent.h"
|
||||||
|
#include "lib/tdb/include/tdb.h"
|
||||||
|
#include "ctdb_private.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Need these, since they're defined in ctdbd.c but we can't include
|
||||||
|
* that.
|
||||||
|
*/
|
||||||
|
int script_log_level;
|
||||||
|
bool fast_start;
|
||||||
|
void ctdb_load_nodes_file(struct ctdb_context *ctdb) {}
|
||||||
|
|
||||||
|
|
||||||
|
/* UTIL_OBJ */
|
||||||
|
#include "lib/util/idtree.c"
|
||||||
|
#include "lib/util/db_wrap.c"
|
||||||
|
#include "lib/util/strlist.c"
|
||||||
|
#include "lib/util/util.c"
|
||||||
|
#include "lib/util/util_time.c"
|
||||||
|
#include "lib/util/util_file.c"
|
||||||
|
#include "lib/util/fault.c"
|
||||||
|
#include "lib/util/substitute.c"
|
||||||
|
#include "lib/util/signal.c"
|
||||||
|
|
||||||
|
/* CTDB_COMMON_OBJ */
|
||||||
|
#include "common/ctdb_io.c"
|
||||||
|
#include "common/ctdb_util.c"
|
||||||
|
#include "common/ctdb_ltdb.c"
|
||||||
|
#include "common/ctdb_message.c"
|
||||||
|
#include "common/cmdline.c"
|
||||||
|
#include "lib/util/debug.c"
|
||||||
|
#include "common/rb_tree.c"
|
||||||
|
#ifdef _LINUX_ERRNO_H
|
||||||
|
#include "common/system_linux.c"
|
||||||
|
#endif
|
||||||
|
#include "common/system_common.c"
|
||||||
|
#include "common/ctdb_logging.c"
|
||||||
|
|
||||||
|
/* CTDB_SERVER_OBJ */
|
||||||
|
#include "server/ctdb_daemon.c"
|
||||||
|
#include "server/ctdb_lockwait.c"
|
||||||
|
#include "server/ctdb_recoverd.c"
|
||||||
|
#include "server/ctdb_recover.c"
|
||||||
|
#include "server/ctdb_freeze.c"
|
||||||
|
#include "server/ctdb_tunables.c"
|
||||||
|
#include "server/ctdb_monitor.c"
|
||||||
|
#include "server/ctdb_server.c"
|
||||||
|
#include "server/ctdb_control.c"
|
||||||
|
#include "server/ctdb_call.c"
|
||||||
|
#include "server/ctdb_ltdb_server.c"
|
||||||
|
#include "server/ctdb_traverse.c"
|
||||||
|
#include "server/eventscript.c"
|
||||||
|
#include "server/ctdb_takeover.c"
|
||||||
|
#include "server/ctdb_serverids.c"
|
||||||
|
#include "server/ctdb_persistent.c"
|
||||||
|
#include "server/ctdb_keepalive.c"
|
||||||
|
#include "server/ctdb_logging.c"
|
||||||
|
#include "server/ctdb_uptime.c"
|
||||||
|
#include "server/ctdb_vacuum.c"
|
||||||
|
#include "server/ctdb_banning.c"
|
||||||
|
#include "server/ctdb_statistics.c"
|
||||||
|
|
||||||
|
/* CTDB_CLIENT_OBJ */
|
||||||
|
#include "client/ctdb_client.c"
|
||||||
|
|
||||||
|
/* CTDB_TCP_OBJ */
|
||||||
|
#include "tcp/tcp_connect.c"
|
||||||
|
#include "tcp/tcp_io.c"
|
||||||
|
#include "tcp/tcp_init.c"
|
||||||
|
|
||||||
|
#endif /* _CTDBD_TEST_C */
|
Loading…
x
Reference in New Issue
Block a user