2010-01-23 02:13:59 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <iostream>
|
|
|
|
#include <sstream>
|
|
|
|
#include "logstore.h"
|
2010-03-17 21:51:26 +00:00
|
|
|
#include "logserver.h"
|
2010-01-27 23:15:47 +00:00
|
|
|
#include "datapage.h"
|
2010-01-23 02:13:59 +00:00
|
|
|
#include "merger.h"
|
|
|
|
#include <assert.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <pthread.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
#include <csignal>
|
|
|
|
|
|
|
|
#undef begin
|
|
|
|
#undef end
|
|
|
|
|
|
|
|
logserver *lserver=0;
|
|
|
|
merge_scheduler *mscheduler=0;
|
|
|
|
|
2010-02-25 01:29:32 +00:00
|
|
|
/*void ignore_pipe(int param)
|
|
|
|
{
|
|
|
|
printf("Ignoring SIGPIPE\n");
|
|
|
|
}*/
|
2010-01-23 02:13:59 +00:00
|
|
|
void terminate (int param)
|
|
|
|
{
|
2010-03-01 21:26:07 +00:00
|
|
|
printf ("Stopping server...\n");
|
|
|
|
lserver->stopserver();
|
|
|
|
delete lserver;
|
|
|
|
|
|
|
|
printf("Stopping merge threads...\n");
|
|
|
|
mscheduler->shutdown();
|
|
|
|
delete mscheduler;
|
|
|
|
|
|
|
|
printf("Deinitializing stasis...\n");
|
|
|
|
fflush(stdout);
|
2010-04-28 19:21:25 +00:00
|
|
|
logtable<datatuple>::deinit_stasis();
|
2010-03-01 21:26:07 +00:00
|
|
|
|
|
|
|
exit(0);
|
2010-01-23 02:13:59 +00:00
|
|
|
}
|
|
|
|
|
2010-03-17 23:45:41 +00:00
|
|
|
int main(int argc, char *argv[])
|
2010-01-23 02:13:59 +00:00
|
|
|
{
|
|
|
|
//signal handling
|
|
|
|
void (*prev_fn)(int);
|
2010-02-25 01:29:32 +00:00
|
|
|
// void (*prev_pipe)(int);
|
|
|
|
|
|
|
|
prev_fn = signal (SIGINT,terminate);
|
2010-01-23 02:13:59 +00:00
|
|
|
|
2010-04-28 19:21:25 +00:00
|
|
|
logtable<datatuple>::init_stasis();
|
2010-02-15 23:02:01 +00:00
|
|
|
|
2010-01-23 02:13:59 +00:00
|
|
|
int xid = Tbegin();
|
|
|
|
|
2010-02-25 01:29:32 +00:00
|
|
|
mscheduler = new merge_scheduler;
|
2010-03-13 00:05:06 +00:00
|
|
|
|
2010-03-17 21:51:26 +00:00
|
|
|
logtable<datatuple> ltable;
|
2010-01-23 02:13:59 +00:00
|
|
|
|
2010-03-01 21:26:07 +00:00
|
|
|
recordid table_root = ROOT_RECORD;
|
|
|
|
if(TrecordType(xid, ROOT_RECORD) == INVALID_SLOT) {
|
|
|
|
printf("Creating empty logstore\n");
|
|
|
|
table_root = ltable.allocTable(xid);
|
|
|
|
assert(table_root.page == ROOT_RECORD.page &&
|
|
|
|
table_root.slot == ROOT_RECORD.slot);
|
|
|
|
} else {
|
|
|
|
printf("Opened existing logstore\n");
|
|
|
|
table_root.size = TrecordSize(xid, ROOT_RECORD);
|
|
|
|
ltable.openTable(xid, table_root);
|
|
|
|
}
|
2010-01-23 02:13:59 +00:00
|
|
|
|
|
|
|
Tcommit(xid);
|
|
|
|
|
|
|
|
int lindex = mscheduler->addlogtable(<able);
|
|
|
|
ltable.setMergeData(mscheduler->getMergeData(lindex));
|
2010-02-25 01:29:32 +00:00
|
|
|
|
2010-03-24 20:30:35 +00:00
|
|
|
int64_t c0_size = 1024 * 1024 * 512 * 1;
|
2010-03-17 23:45:41 +00:00
|
|
|
|
2010-03-24 20:30:35 +00:00
|
|
|
if(argc == 2 && !strcmp(argv[1], "--test")) {
|
2010-03-17 23:45:41 +00:00
|
|
|
|
2010-06-21 22:59:05 +00:00
|
|
|
c0_size = 1024 * 1024 * 100;
|
2010-03-17 23:45:41 +00:00
|
|
|
printf("warning: running w/ tiny c0 for testing"); // XXX build a separate test server and deployment server?
|
|
|
|
}
|
|
|
|
|
2010-04-27 17:57:43 +00:00
|
|
|
if(argc == 2 && !strcmp(argv[1], "--benchmark")) {
|
|
|
|
|
|
|
|
c0_size = 1024 * 1024 * 1024 * 1;
|
|
|
|
printf("note: running w/ 2GB c0 for benchmarking"); // XXX build a separate test server and deployment server?
|
|
|
|
}
|
|
|
|
|
2010-02-10 21:49:50 +00:00
|
|
|
mscheduler->startlogtable(lindex, c0_size);
|
2010-01-23 02:13:59 +00:00
|
|
|
|
2010-05-28 18:31:34 +00:00
|
|
|
lserver = new logserver(100, 32432);
|
2010-01-23 02:13:59 +00:00
|
|
|
|
|
|
|
lserver->startserver(<able);
|
|
|
|
|
2010-03-17 23:45:41 +00:00
|
|
|
abort(); // can't get here.
|
2010-01-23 02:13:59 +00:00
|
|
|
}
|