if (ZKAssign.transitionNodeOpened(this.server.getZooKeeper(), egi, this.server.getServerName(), this.version) == -1) { LOG.warn("Completed the OPEN of entityGroup "
/** * Creates a znode with OPENED state. * * @param TEST_UTIL * @param entityGroup * @param serverName * @return * @throws java.io.IOException * @throws ZooKeeperConnectionException * @throws org.apache.zookeeper.KeeperException * @throws org.apache.zookeeper.KeeperException.NodeExistsException */ public static ZooKeeperWatcher createAndForceNodeToOpenedState( WaspTestingUtility TEST_UTIL, EntityGroup entityGroup, ServerName serverName) throws ZooKeeperConnectionException, IOException, KeeperException, NodeExistsException { ZooKeeperWatcher zkw = getZooKeeperWatcher(TEST_UTIL); ZKAssign.createNodeOffline(zkw, entityGroup.getEntityGroupInfo(), serverName); int version = ZKAssign.transitionNodeOpening(zkw, entityGroup.getEntityGroupInfo(), serverName); ZKAssign.transitionNodeOpened(zkw, entityGroup.getEntityGroupInfo(), serverName, version); return zkw; }
/** * 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. }
assertNotSame(-1, versionid); versionid = ZKAssign.transitionNodeOpened(this.watcher, ENTITYGROUPINFO, SERVERNAME_B, versionid); assertNotSame(-1, versionid);