示例#1
0
 public DummyZKFCThread(MiniZKFCCluster _enclosing, MultithreadedTestUtil.TestContext
                        ctx, DummyHAService svc)
     : base(ctx)
 {
     this._enclosing = _enclosing;
     this.zkfc       = new MiniZKFCCluster.DummyZKFC(this._enclosing.conf, svc);
 }
示例#2
0
 /// <summary>Test that the ZKFC can gracefully cede its active status.</summary>
 /// <exception cref="System.Exception"/>
 public virtual void TestCedeActive()
 {
     try
     {
         cluster.Start();
         MiniZKFCCluster.DummyZKFC zkfc = cluster.GetZkfc(0);
         // It should be in active to start.
         Assert.Equal(ActiveStandbyElector.State.Active, zkfc.GetElectorForTests
                          ().GetStateForTests());
         // Ask it to cede active for 3 seconds. It should respond promptly
         // (i.e. the RPC itself should not take 3 seconds!)
         ZKFCProtocol proxy = zkfc.GetLocalTarget().GetZKFCProxy(conf, 5000);
         long         st    = Time.Now();
         proxy.CedeActive(3000);
         long et = Time.Now();
         Assert.True("RPC to cedeActive took " + (et - st) + " ms", et -
                     st < 1000);
         // Should be in "INIT" state since it's not in the election
         // at this point.
         Assert.Equal(ActiveStandbyElector.State.Init, zkfc.GetElectorForTests
                          ().GetStateForTests());
         // After the prescribed 3 seconds, should go into STANDBY state,
         // since the other node in the cluster would have taken ACTIVE.
         cluster.WaitForElectorState(0, ActiveStandbyElector.State.Standby);
         long et2 = Time.Now();
         Assert.True("Should take ~3 seconds to rejoin. Only took " + (et2
                                                                       - et) + "ms before rejoining.", et2 - et > 2800);
     }
     finally
     {
         cluster.Stop();
     }
 }
示例#3
0
 /// <summary>Wait for the given HA service to enter the given HA state.</summary>
 /// <remarks>
 /// Wait for the given HA service to enter the given HA state.
 /// This is based on the state of ZKFC, not the state of HA service.
 /// There could be difference between the two. For example,
 /// When the service becomes unhealthy, ZKFC will quit ZK election and
 /// transition to HAServiceState.INITIALIZING and remain in that state
 /// until the service becomes healthy.
 /// </remarks>
 /// <exception cref="System.Exception"/>
 public virtual void WaitForHAState(int idx, HAServiceProtocol.HAServiceState state
                                    )
 {
     MiniZKFCCluster.DummyZKFC svc = GetZkfc(idx);
     while (svc.GetServiceState() != state)
     {
         ctx.CheckException();
         Thread.Sleep(50);
     }
 }
示例#4
0
 /// <exception cref="System.Exception"/>
 private int RunFC(DummyHAService target, params string[] args)
 {
     MiniZKFCCluster.DummyZKFC zkfc = new MiniZKFCCluster.DummyZKFC(conf, target);
     return(zkfc.Run(args));
 }