public static RouterState newInstance() {
    RouterState record = StateStoreSerializer.newRecord(RouterState.class);
    record.init();
    return record;
  }
@Test
  public void testStateStoreResilience() throws Exception {
    StateStoreService service = new StateStoreService();
    Configuration conf = new Configuration();
    conf.setClass(RBFConfigKeys.FEDERATION_STORE_DRIVER_CLASS,
        MockStateStoreDriver.class,
        StateStoreDriver.class);
    conf.setBoolean(RBFConfigKeys.DFS_ROUTER_METRICS_ENABLE, false);
    service.init(conf);
    MockStateStoreDriver driver = (MockStateStoreDriver) service.getDriver();
    driver.clearAll();
    // Add two records for block1
    driver.put(MembershipState.newInstance("routerId", "ns1",
        "ns1-ha1", "cluster1", "block1", "rpc1",
        "service1", "lifeline1", "https", "nn01",
        FederationNamenodeServiceState.ACTIVE, false), false, false);
    driver.put(MembershipState.newInstance("routerId", "ns1",
        "ns1-ha2", "cluster1", "block1", "rpc2",
        "service2", "lifeline2", "https", "nn02",
        FederationNamenodeServiceState.STANDBY, false), false, false);
    // load the cache
    service.loadDriver();
    MembershipNamenodeResolver resolver = new MembershipNamenodeResolver(conf, service);
    service.refreshCaches(true);

    // look up block1
    List<? extends FederationNamenodeContext> result =
        resolver.getNamenodesForBlockPoolId("block1");
    assertEquals(2, result.size());

    // cause io errors and then reload the cache
    driver.setGiveErrors(true);
    long previousUpdate = service.getCacheUpdateTime();
    service.refreshCaches(true);
    assertEquals(previousUpdate, service.getCacheUpdateTime());

    // make sure the old cache is still there
    result = resolver.getNamenodesForBlockPoolId("block1");
    assertEquals(2, result.size());
    service.stop();
  }