1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

merge from ronnie

remove unused bench_incr function in ctdb_bench.c

(This used to be ctdb commit 39424cb13070c9964121b533a9f9ba448ce49d16)
This commit is contained in:
Andrew Tridgell 2007-04-19 12:43:19 +10:00
commit eeb3f01e02
4 changed files with 34 additions and 84 deletions

View File

@ -306,6 +306,18 @@ static void daemon_request_call_from_client(struct ctdb_client *client,
struct daemon_call_state *dstate;
struct ctdb_call *call;
/* check that the client filled in the correct vnn for the local node */
if (ctdb_get_vnn(client->ctdb) != c->hdr.srcnode) {
DEBUG(0, (__location__ "Wrong srcnode in CTDB_REQ_CALL from client was:%d should be :%d\n", c->hdr.srcnode, ctdb_get_vnn(client->ctdb)));
return;
}
/* verify that the destnode makes sense */
if (c->hdr.destnode >= client->ctdb->num_nodes) {
DEBUG(0, (__location__ "Wrong dstnode in CTDB_REQ_CALL from client was:%d but there are only %d nodes in the cluster\n", c->hdr.destnode, client->ctdb->num_nodes));
return;
}
ctdb_db = find_ctdb_db(client->ctdb, c->db_id);
if (!ctdb_db) {
DEBUG(0, (__location__ " Unknown database in request. db_id==0x%08x",

View File

@ -3,6 +3,6 @@
killall -q ctdbd
echo "Starting 2 ctdb daemons"
bin/ctdbd --nlist direct/nodes.txt --listen 127.0.0.2:9001 --daemon &
bin/ctdbd --nlist direct/nodes.txt --listen 127.0.0.1:9001 --daemon &
bin/ctdbd --nlist direct/nodes.txt --listen 127.0.0.2:9001 &
bin/ctdbd --nlist direct/nodes.txt --listen 127.0.0.1:9001 &

View File

@ -184,24 +184,34 @@ uint32_t ctdb_hash(const TDB_DATA *key)
return (1103515243 * value + 12345);
}
void fetch_lock(int fd, uint32_t db_id, TDB_DATA key)
/* ask the daemon to migrate a record over so that the local node is the dmaster the client must not have the record locked when performing this call.
when the daemon has responded this node should be the dmaster (unless it has migrated off again)
*/
void fetch_record(int fd, uint32_t db_id, TDB_DATA key, int thisnode, int destnode)
{
struct ctdb_req_fetch_lock *req;
struct ctdb_reply_fetch_lock *rep;
struct ctdb_req_call *req;
struct ctdb_reply_call *rep;
uint32_t length;
int len, cnt, tot;
len = offsetof(struct ctdb_req_fetch_lock, key) + key.dsize;
len = offsetof(struct ctdb_req_call, data) + key.dsize;
req = malloc(len);
req->hdr.length = len;
req->hdr.ctdb_magic = CTDB_MAGIC;
req->hdr.ctdb_version = CTDB_VERSION;
req->hdr.operation = CTDB_REQ_FETCH_LOCK;
req->hdr.operation = CTDB_REQ_CALL;
req->hdr.destnode = destnode;
req->hdr.srcnode = thisnode;
req->hdr.reqid = 1;
req->flags = CTDB_IMMEDIATE_MIGRATION;
req->db_id = db_id;
req->callid = CTDB_NULL_FUNC;
req->keylen = key.dsize;
memcpy(&req->key[0], key.dptr, key.dsize);
req->calldatalen = 0;
memcpy(&req->data[0], key.dptr, key.dsize);
cnt=write(fd, req, len);
@ -227,19 +237,7 @@ void fetch_lock(int fd, uint32_t db_id, TDB_DATA key)
cnt+=numread;
}
}
printf("fetch lock reply: state:%d datalen:%d\n",rep->state,rep->datalen);
if(!rep->datalen){
printf("no data\n");
} else {
printf("data:[%s]\n",rep->data);
}
}
void store_unlock(int fd, uint32_t db_id, TDB_DATA key, TDB_DATA data)
{
/*XXX write the tdb record and drop the chainlock*/
printf("store_unlock example not implemented\n");
printf("fetch record reply: operation:%d state:%d\n",rep->hdr.operation,rep->status);
}
int main(int argc, const char *argv[])
@ -249,8 +247,7 @@ int main(int argc, const char *argv[])
struct ctdb_req_message *reply;
TDB_DATA dbname;
uint32_t db_id;
TDB_DATA key, data;
char str[256];
TDB_DATA key;
/* open the socket to talk to the local ctdb daemon */
fd=ux_socket_connect(CTDB_SOCKET);
@ -296,25 +293,12 @@ int main(int argc, const char *argv[])
printf("the has for the database id is 0x%08x\n",db_id);
printf("\n");
/* send a fetch lock */
/* send a request to migrate a record to the local node */
key.dptr=discard_const("TestKey");
key.dsize=strlen((const char *)(key.dptr));
printf("fetch the test key:[%s]\n",key.dptr);
fetch_lock(fd, db_id, key);
printf("\n");
/* send a store unlock */
sprintf(str,"TestData_%d",getpid());
data.dptr=discard_const(str);
data.dsize=strlen((const char *)(data.dptr));
printf("store new data==[%s] for this record\n",data.dptr);
store_unlock(fd, db_id, key, data);
printf("\n");
/* send a fetch lock */
printf("fetch the test key:[%s]\n",key.dptr);
fetch_lock(fd, db_id, key);
fetch_record(fd, db_id, key, 0, 1);
printf("\n");

View File

@ -45,7 +45,6 @@ static double end_timer(void)
static int timelimit = 10;
static int num_records = 10;
static int num_msgs = 1;
static int num_repeats = 100;
enum my_functions {FUNC_INCR=1, FUNC_FETCH=2};
@ -78,51 +77,6 @@ static int fetch_func(struct ctdb_call_info *call)
return 0;
}
/*
benchmark incrementing an integer
*/
static void bench_incr(struct ctdb_context *ctdb, struct ctdb_db_context *ctdb_db)
{
int loops=0;
int ret, i;
struct ctdb_call call;
ZERO_STRUCT(call);
start_timer();
while (1) {
uint32_t v = loops % num_records;
call.call_id = FUNC_INCR;
call.key.dptr = (uint8_t *)&v;
call.key.dsize = 4;
for (i=0;i<num_repeats;i++) {
ret = ctdb_call(ctdb_db, &call);
if (ret != 0) {
printf("incr call failed - %s\n", ctdb_errstr(ctdb));
return;
}
}
if (num_repeats * (++loops) % 10000 == 0) {
if (end_timer() > timelimit) break;
printf("Incr: %.2f ops/sec\r", num_repeats*loops/end_timer());
fflush(stdout);
}
}
call.call_id = FUNC_FETCH;
ret = ctdb_call(ctdb_db, &call);
if (ret == -1) {
printf("ctdb_call FUNC_FETCH failed - %s\n", ctdb_errstr(ctdb));
return;
}
printf("Incr: %.2f ops/sec (loops=%d val=%d)\n",
num_repeats*loops/end_timer(), loops, *(uint32_t *)call.reply_data.dptr);
}
static int msg_count;
static int msg_plus, msg_minus;