private void tryMigrate(ZKWatcher watcher, String zkPath) throws IOException, KeeperException {
    if (zkPath == null) {
      // this means we do not store this state in zk, skip migrating
      return;
    }
    Result result = get();
    if (result.isEmpty()) {
      // migrate
      migrate(watcher, zkPath);
    }
    // we may fail in the middle so even if the value is available in master local region, we may
    // still leave a znode on zookeeper, so always try to delete the znode here since it is not very
    // expensive
    try {
      ZKUtil.deleteNodeFailSilent(watcher, zkPath);
    } catch (Exception e) {
      LOG.warn("failed to delete migrated zk state node {}, ignore and continue", zkPath);
    }
  }
A state storage which stores the state in master local region.
<p/>
We used to store some persistent state on zookeeper, so here we provide the ability to migrate
the state from zookeeper.
<p/>
Since parsing the state may introduce some extra overhead, we make this class abstract and the
get and set state methods protected. Sub classes should store their state in decoded format to
save the extra parsing overhead.
hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterStateStore.java