Package org.apache.hadoop.hbase.coordination

Examples of org.apache.hadoop.hbase.coordination.ZkCoordinatedStateManager


      new ZooKeeperWatcher(HTU.getConfiguration(), "mockedServer", this.server, true);
    Mockito.when(server.getZooKeeper()).thenReturn(this.watcher);
    Mockito.doThrow(new RuntimeException("Aborted")).
      when(server).abort(Mockito.anyString(), (Throwable)Mockito.anyObject());

    cp = new ZkCoordinatedStateManager();
    cp.initialize(this.server);
    cp.start();

    mtl = Mockito.mock(MetaTableLocator.class);
View Full Code Here


    Mockito.when(this.serverManager.isServerOnline(SERVERNAME_A)).thenReturn(false);
    am.getRegionStates().logSplit(SERVERNAME_A); // Assume log splitting is done
    am.getRegionStates().createRegionState(REGIONINFO);
    am.gate.set(false);

    BaseCoordinatedStateManager cp = new ZkCoordinatedStateManager();
    cp.initialize(server);
    cp.start();

    OpenRegionCoordination orc = cp.getOpenRegionCoordination();
    ZkOpenRegionCoordination.ZkOpenRegionDetails zkOrd =
      new ZkOpenRegionCoordination.ZkOpenRegionDetails();
    zkOrd.setServerName(server.getServerName());
    zkOrd.setVersion(version);
View Full Code Here

    Mockito.when(server.getConfiguration()).thenReturn(conf);
    Mockito.when(server.getServerName()).thenReturn(ServerName.valueOf("masterMock,1,1"));
    Mockito.when(server.getZooKeeper()).thenReturn(zkWatcher);

    CoordinatedStateManager cp = new ZkCoordinatedStateManager();
    cp.initialize(server);
    cp.start();

    Mockito.when(server.getCoordinatedStateManager()).thenReturn(cp);

    Mockito.when(serverManager.getOnlineServers()).thenReturn(onlineServers);
    Mockito.when(serverManager.getOnlineServersList())
View Full Code Here

    Mockito.when(server.getConfiguration()).thenReturn(conf);
    Mockito.when(server.getServerName()).thenReturn(ServerName.valueOf("masterMock,1,1"));
    Mockito.when(server.getZooKeeper()).thenReturn(zkWatcher);

    CoordinatedStateManager cp = new ZkCoordinatedStateManager();
    cp.initialize(server);
    cp.start();

    Mockito.when(server.getCoordinatedStateManager()).thenReturn(cp);

    Mockito.when(serverManager.getOnlineServers()).thenReturn(onlineServers);
    Mockito.when(serverManager.getOnlineServersList()).thenReturn(
View Full Code Here

        hri.getEncodedNameAsBytes()));

    // Let's start the open handler
    HTableDescriptor htd = getRS().tableDescriptors.get(hri.getTable());

    BaseCoordinatedStateManager csm = new ZkCoordinatedStateManager();
    csm.initialize(getRS());
    csm.start();

    ZkOpenRegionCoordination.ZkOpenRegionDetails zkCrd =
      new ZkOpenRegionCoordination.ZkOpenRegionDetails();
    zkCrd.setServerName(getRS().getServerName());
    zkCrd.setVersionOfOfflineNode(0);

    getRS().service.submit(new OpenRegionHandler(getRS(), getRS(), hri, htd,
      csm.getOpenRegionCoordination(), zkCrd));

    // The open handler should have removed the region from RIT but kept the region closed
    checkRegionIsClosed();

    // The open handler should have updated the value in ZK.
View Full Code Here

    //  1) There is no ZK node
    //  2) The region in RIT was changed.
    // The order is more or less implementation dependant.
    HTableDescriptor htd = getRS().tableDescriptors.get(hri.getTable());

    BaseCoordinatedStateManager csm = new ZkCoordinatedStateManager();
    csm.initialize(getRS());
    csm.start();

    ZkOpenRegionCoordination.ZkOpenRegionDetails zkCrd =
      new ZkOpenRegionCoordination.ZkOpenRegionDetails();
    zkCrd.setServerName(getRS().getServerName());
    zkCrd.setVersionOfOfflineNode(0);

    getRS().service.submit(new OpenRegionHandler(getRS(), getRS(), hri, htd,
      csm.getOpenRegionCoordination(), zkCrd));

    // The open handler should have removed the region from RIT but kept the region closed
    checkRegionIsClosed();

    // We should not find any znode here.
View Full Code Here

       final RegionServerServices rss = HTU.createMockRegionServerService();

       HTableDescriptor htd = TEST_HTD;
       final HRegionInfo hri = TEST_HRI;

       ZkCoordinatedStateManager coordinationProvider = new ZkCoordinatedStateManager();
       coordinationProvider.initialize(server);
       coordinationProvider.start();

       // open a region first so that it can be closed later
       OpenRegion(server, rss, htd, hri, coordinationProvider.getOpenRegionCoordination());

       // close the region
       // Create it CLOSING, which is what Master set before sending CLOSE RPC
       int versionOfClosingNode = ZKAssign.createNodeClosing(server.getZooKeeper(),
         hri, server.getServerName());

       // The CloseRegionHandler will validate the expected version
       // Given it is set to invalid versionOfClosingNode+1,
       // CloseRegionHandler should be M_ZK_REGION_CLOSING

       ZkCloseRegionCoordination.ZkCloseRegionDetails zkCrd =
         new ZkCloseRegionCoordination.ZkCloseRegionDetails();
       zkCrd.setPublishStatusInZk(true);
       zkCrd.setExpectedVersion(versionOfClosingNode+1);

       CloseRegionHandler handler = new CloseRegionHandler(server, rss, hri, false,
         coordinationProvider.getCloseRegionCoordination(), zkCrd);
       handler.process();

       // Handler should remain in M_ZK_REGION_CLOSING
       RegionTransition rt =
         RegionTransition.parseFrom(ZKAssign.getData(server.getZooKeeper(), hri.getEncodedName()));
View Full Code Here

       final RegionServerServices rss = HTU.createMockRegionServerService();

       HTableDescriptor htd = TEST_HTD;
       HRegionInfo hri = TEST_HRI;

       ZkCoordinatedStateManager coordinationProvider = new ZkCoordinatedStateManager();
       coordinationProvider.initialize(server);
       coordinationProvider.start();

       // open a region first so that it can be closed later
       OpenRegion(server, rss, htd, hri, coordinationProvider.getOpenRegionCoordination());

       // close the region
       // Create it CLOSING, which is what Master set before sending CLOSE RPC
       int versionOfClosingNode = ZKAssign.createNodeClosing(server.getZooKeeper(),
         hri, server.getServerName());

       // The CloseRegionHandler will validate the expected version
       // Given it is set to correct versionOfClosingNode,
       // CloseRegionHandlerit should be RS_ZK_REGION_CLOSED

       ZkCloseRegionCoordination.ZkCloseRegionDetails zkCrd =
         new ZkCloseRegionCoordination.ZkCloseRegionDetails();
       zkCrd.setPublishStatusInZk(true);
       zkCrd.setExpectedVersion(versionOfClosingNode);

       CloseRegionHandler handler = new CloseRegionHandler(server, rss, hri, false,
         coordinationProvider.getCloseRegionCoordination(), zkCrd);
       handler.process();
       // Handler should have transitioned it to RS_ZK_REGION_CLOSED
       RegionTransition rt = RegionTransition.parseFrom(
         ZKAssign.getData(server.getZooKeeper(), hri.getEncodedName()));
       assertTrue(rt.getEventType().equals(EventType.RS_ZK_REGION_CLOSED));
View Full Code Here

    HRegion region =
         HRegion.createHRegion(hri, HTU.getDataTestDir(), HTU
            .getConfiguration(), htd);
    assertNotNull(region);
    try {
      ZkCoordinatedStateManager csm = new ZkCoordinatedStateManager();
      csm.initialize(server);
      csm.start();

      ZkOpenRegionCoordination.ZkOpenRegionDetails zkCrd =
        new ZkOpenRegionCoordination.ZkOpenRegionDetails();
      zkCrd.setServerName(server.getServerName());

      OpenRegionHandler handler = new OpenRegionHandler(server, rss, hri,
        htd, csm.getOpenRegionCoordination(), zkCrd) {
        HRegion openRegion() {
          // Open region first, then remove znode as though it'd been hijacked.
          HRegion region = super.openRegion();

          // Don't actually open region BUT remove the znode as though it'd
View Full Code Here

         HRegion.createHRegion(hri, HTU.getDataTestDir(), HTU
            .getConfiguration(), htd);
    assertNotNull(region);
    try {

      ZkCoordinatedStateManager csm = new ZkCoordinatedStateManager();
      csm.initialize(server);
      csm.start();

      ZkOpenRegionCoordination.ZkOpenRegionDetails zkCrd =
        new ZkOpenRegionCoordination.ZkOpenRegionDetails();
      zkCrd.setServerName(server.getServerName());
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.coordination.ZkCoordinatedStateManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.