/** * Fakes the regionserver-side zk transitions of a region open. * @param w ZooKeeperWatcher to use. * @param sn Name of the regionserver doing the 'opening' * @param egInfo EntityGroup we're 'opening'. * @throws org.apache.zookeeper.KeeperException * @throws com.alibaba.wasp.DeserializationException */ static void fakeEntityGroupServerEntityGroupOpenInZK(FMaster master, final ZooKeeperWatcher w, final ServerName sn, final EntityGroupInfo egInfo) throws KeeperException, DeserializationException, InterruptedException { // Wait till the we region is ready to be open in RIT. waitForEntityGroupPendingOpenInRIT(master.getAssignmentManager(), egInfo.getEncodedName()); // Get current versionid else will fail on transition from OFFLINE to OPENING below int versionid = ZKAssign.getVersion(w, egInfo); assertNotSame(-1, versionid); // This uglyness below is what the openregionhandler on FSERVER side does. I // looked at exposing the method over in openregionhandler but its just a // one liner and its deep over in another package so just repeat it below. versionid = ZKAssign.transitionNode(w, egInfo, sn, EventType.M_ZK_ENTITYGROUP_OFFLINE, EventType.FSERVER_ZK_ENTITYGROUP_OPENING, versionid); assertNotSame(-1, versionid); // Move znode from OPENING to OPENED as FSERVER does on successful open. versionid = ZKAssign.transitionNodeOpened(w, egInfo, sn, versionid); assertNotSame(-1, versionid); // We should be done now. The master open handler will notice the // transition and remove this regions znode. }
versionid = ZKAssign.getVersion(this.watcher, ENTITYGROUPINFO); assertNotSame(-1, versionid);