public ReplLogFetcher(ReplHandler local_db, string log_server_guid) { this.local_db = local_db; this.log_server_guid = log_server_guid; our_fetcher = new Thread(delegate() { this.workerThread(); }); our_fetcher.Start(); }
public static void waitUntilState(LayerManager db, ReplHandler srvr, ReplState state) { for (int x = 0; x < 20; x++) { if (srvr.State == state) { break; } Console.WriteLine("waiting for ({0}) to become {1}.. (currently: {2})", srvr.ToString(),state, srvr.State); Thread.Sleep(1000); } if (srvr.State != state) { db.debugDump(); Console.WriteLine("server({0}) failed to become {1}, aborting test", srvr.ToString(), state); Environment.Exit(1); } Console.WriteLine("Server ({0}) is now {1}!", srvr, state); }
public ReplPusher(ReplHandler handler) { servers = new HashSet<string>(); myhandler = handler; }
public static ReplHandler InitResume(IStepsSnapshotKVDB db, ServerContext ctx) { ReplHandler repl = new ReplHandler(db, ctx); return repl; }
public static ReplHandler InitJoin(IStepsSnapshotKVDB db, ServerContext ctx, string seed_name) { // connect to the other server, get his instance id, exchange seeds IReplConnection seed = ctx.connector.getServerHandle(seed_name); JoinInfo join_info = seed.requestToJoin(ctx.server_guid); // record the join result db.setValue(new RecordKey() .appendKeyPart("_config") .appendKeyPart("DATA-INSTANCE-ID"), RecordUpdate.WithPayload(join_info.data_instance_id)); // init a clean log db.setValue(new RecordKey() .appendKeyPart("_logs") .appendKeyPart(ctx.server_guid) .appendKeyPart(new RecordKeyType_Long(0)), RecordUpdate.WithPayload(new byte[0])); foreach (var seed_server in join_info.seed_servers) { db.setValue(new RecordKey() .appendKeyPart("_config") .appendKeyPart("seeds") .appendKeyPart(seed_server), RecordUpdate.WithPayload("")); } Console.WriteLine("InitJoin: server ({0}) joining seeds ({1})", ctx.server_guid, String.Join(",", join_info.seed_servers)); ReplHandler repl = new ReplHandler(db, ctx); return repl; }
public static ReplHandler InitFresh(IStepsSnapshotKVDB db, ServerContext ctx) { // init fresh // record our instance ID db.setValue(new RecordKey() .appendKeyPart("_config") .appendKeyPart("MY-SERVER-ID"), RecordUpdate.WithPayload(ctx.server_guid)); // create and record a new instance ID db.setValue(new RecordKey() .appendKeyPart("_config") .appendKeyPart("DATA-INSTANCE-ID"), RecordUpdate.WithPayload(Lsd.numberToLsd(ReplHandler.myrnd.Next(), 15))); // record the "start of fresh log" record db.setValue(new RecordKey() .appendKeyPart("_logs") .appendKeyPart(ctx.server_guid) .appendKeyPart(new RecordKeyType_Long(0)), RecordUpdate.WithPayload(new byte[0])); // record ourself as a seed/log db.setValue(new RecordKey() .appendKeyPart("_config").appendKeyPart("seeds").appendKeyPart(ctx.server_guid), RecordUpdate.WithPayload("")); ReplHandler repl = new ReplHandler(db, ctx); repl.state = ReplState.active; // TODO: is this the right way to become active? return repl; }
internal MyReplConnection(ReplHandler hndl) { this.hndl = hndl; }
public static void waitUntilActive(LayerManager db, ReplHandler srvr) { waitUntilState(db, srvr, ReplState.active); }