2010-01-23 02:13:59 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <iostream>
|
|
|
|
#include <sstream>
|
|
|
|
#include "logstore.h"
|
2010-01-27 23:15:47 +00:00
|
|
|
#include "datapage.h"
|
|
|
|
#include "logiterators.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)
|
|
|
|
{
|
|
|
|
printf ("Stopping server...\n");
|
|
|
|
lserver->stopserver();
|
|
|
|
delete lserver;
|
|
|
|
|
|
|
|
printf("Stopping merge threads...\n");
|
|
|
|
mscheduler->shutdown();
|
|
|
|
delete mscheduler;
|
|
|
|
|
|
|
|
printf("Deinitializing stasis...\n");
|
|
|
|
fflush(stdout);
|
2010-02-19 00:59:14 +00:00
|
|
|
diskTreeComponent::deinit_stasis();
|
2010-01-23 02:13:59 +00:00
|
|
|
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
2010-02-10 21:49:50 +00:00
|
|
|
void initialize_server()
|
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-02-19 00:59:14 +00:00
|
|
|
diskTreeComponent::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-01-23 02:13:59 +00:00
|
|
|
logtable ltable;
|
|
|
|
|
|
|
|
int pcount = 40;
|
|
|
|
ltable.set_fixed_page_count(pcount);
|
|
|
|
|
|
|
|
recordid table_root = ltable.allocTable(xid);
|
|
|
|
|
|
|
|
Tcommit(xid);
|
|
|
|
|
2010-02-25 01:29:32 +00:00
|
|
|
writelock(ltable.header_lock,0);
|
|
|
|
|
2010-01-23 02:13:59 +00:00
|
|
|
int lindex = mscheduler->addlogtable(<able);
|
|
|
|
ltable.setMergeData(mscheduler->getMergeData(lindex));
|
2010-02-25 01:29:32 +00:00
|
|
|
|
2010-02-10 21:49:50 +00:00
|
|
|
int64_t c0_size = 1024 * 1024 * 10;
|
|
|
|
printf("warning: running w/ tiny c0 for testing"); // XXX
|
|
|
|
mscheduler->startlogtable(lindex, c0_size);
|
2010-01-23 02:13:59 +00:00
|
|
|
|
2010-02-25 01:29:32 +00:00
|
|
|
unlock(ltable.header_lock);
|
|
|
|
|
2010-01-23 02:13:59 +00:00
|
|
|
lserver = new logserver(10, 32432);
|
|
|
|
|
|
|
|
lserver->startserver(<able);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @test
|
|
|
|
*/
|
|
|
|
int main()
|
|
|
|
{
|
2010-02-10 21:49:50 +00:00
|
|
|
initialize_server();
|
|
|
|
abort(); // can't get here.
|
2010-01-23 02:13:59 +00:00
|
|
|
}
|
|
|
|
|