private void workerFunc()
{
// Make sure we try to stay connnected to all seeds so we can push writes to them
// as fast as possible.
pusher.scanSeeds();
if (this.should_shutdown) {
this.state = ReplState.do_shutdown;
}
switch (this.state) {
case ReplState.init:
// we are initializing.... check our log state and see if we need a full rebuild
Console.WriteLine("Repl({0}): log resume", ctx.server_guid);
worker_logResume();
break;
case ReplState.rebuild:
// we need a FULL rebuild
Console.WriteLine("Repl({0}): full rebuild started", ctx.server_guid);
worker_fullRebuild();
Console.WriteLine("Repl({0}): full rebuild finished", ctx.server_guid);
break;
case ReplState.resolve:
Console.WriteLine("Repl({0}): resolve needed!!", ctx.server_guid);
break;
case ReplState.active:
// we are just running!!
ctx.connector.registerServer(ctx.server_guid, this.my_repl_interface);
// pop back to init to check log tails
worker_logResume();
break;
case ReplState.error:
Console.WriteLine("Repl({0}): error, stalled", ctx.server_guid);
break;
case ReplState.do_shutdown:
// do whatever cleanup we need
_stopFetchers();
this.state = ReplState.shutdown;
break;
case ReplState.shutdown:
break;
default:
// UNKNOWN ReplState
throw new Exception("unknown ReplState: " + this.state.ToString());
}
}