stasis-bLSM/server.cpp
sears 7c2397340c Fixed a bunch of iterator bugs and racy merges. Added drop_database utility.
Bugfixes:
 - Atomically deallocate regions and update the logstore object
 - Proactively invalidate iterators after each merge (before, it would simply set a not-valid bit.  This doesn't work because iterators hold page pins, which breaks force-writes)
 - Clarify semantics of opening iterators mid-stream:  All calls now return iterators that return first key >= the requested one.  revalidate() needs the key > the requested one, so it calls peek(), then (if necessary) getnext().
 - Add asserts to check that the header is latched at update, and that tuples returned by iterators are strictly monotonically increasing'
 - Improve error handling in network.h  We still get (and terminate on) SIGPIPE.

Refactoring:
 - Add dispatch function to network.h.



git-svn-id: svn+ssh://svn.corp.yahoo.com/yahoo/yrl/labs/pnuts/code/logstore@620 8dad8b1f-cf64-0410-95b6-bcf113ffbcfe
2010-02-25 01:29:32 +00:00

92 lines
1.6 KiB
C++

#include <string>
#include <vector>
#include <iostream>
#include <sstream>
#include "logstore.h"
#include "datapage.h"
#include "logiterators.h"
#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;
/*void ignore_pipe(int param)
{
printf("Ignoring SIGPIPE\n");
}*/
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);
diskTreeComponent::deinit_stasis();
exit(0);
}
void initialize_server()
{
//signal handling
void (*prev_fn)(int);
// void (*prev_pipe)(int);
prev_fn = signal (SIGINT,terminate);
diskTreeComponent::init_stasis();
int xid = Tbegin();
mscheduler = new merge_scheduler;
logtable ltable;
int pcount = 40;
ltable.set_fixed_page_count(pcount);
recordid table_root = ltable.allocTable(xid);
Tcommit(xid);
writelock(ltable.header_lock,0);
int lindex = mscheduler->addlogtable(&ltable);
ltable.setMergeData(mscheduler->getMergeData(lindex));
int64_t c0_size = 1024 * 1024 * 10;
printf("warning: running w/ tiny c0 for testing"); // XXX
mscheduler->startlogtable(lindex, c0_size);
unlock(ltable.header_lock);
lserver = new logserver(10, 32432);
lserver->startserver(&ltable);
}
/** @test
*/
int main()
{
initialize_server();
abort(); // can't get here.
}