private void _connect() { this.target_server = local_db.ctx.connector.getServerHandle(this.log_server_guid); // TODO: if we can't get the target, we should just get someone who has his logs! }
public ReplHandler(IStepsSnapshotKVDB db, ServerContext ctx) { this.next_stage = db; this.my_repl_interface = new MyReplConnection(this); this.rnd = new Random(); this.pusher = new ReplPusher(this); this.ctx = ctx; try { var di_rk = new RecordKey() .appendKeyPart("_config") .appendKeyPart("DATA-INSTANCE-ID"); var rec = db.FindNext(di_rk, true); if (di_rk.CompareTo(rec.Key) != 0) { throw new Exception( String.Format("ReplHandler {0} , not able to fetch DATA-INSTANCE-ID", ctx.server_guid)); } this.data_instance_id = rec.Value.ToString(); Console.WriteLine("ReplHandler - {0}: data_instance_id {1}", ctx.server_guid, data_instance_id); } catch (KeyNotFoundException) { throw new Exception("no data instance ID, try InitResume or InitJoin"); } // check server_guid matches? // register ourself ctx.connector.registerServer(ctx.server_guid, this.my_repl_interface); // startup our background task worker = new Thread(delegate() { this.workerThread(); }); worker.Start(); }
public void registerServer(string name, IReplConnection instance) { server_list[name] = instance; }