Package org.apache.hadoop.hbase

Examples of org.apache.hadoop.hbase.Server


 
  @Test
  public void testNodeFailoverWorkerCopyQueuesFromRSUsingMulti() throws Exception {
    LOG.debug("testNodeFailoverWorkerCopyQueuesFromRSUsingMulti");
    conf.setBoolean(HConstants.ZOOKEEPER_USEMULTI, true);
    final Server server = new DummyServer("hostname0.example.org");
    AtomicBoolean replicating = new AtomicBoolean(true);
    ReplicationZookeeper rz = new ReplicationZookeeper(server, replicating);
    // populate some znodes in the peer znode
    files.add("log1");
    files.add("log2");
    for (String file : files) {
      rz.addLogToList(file, "1");
    }
    // create 3 DummyServers
    Server s1 = new DummyServer("dummyserver1.example.org");
    Server s2 = new DummyServer("dummyserver2.example.org");
    Server s3 = new DummyServer("dummyserver3.example.org");

    // create 3 DummyNodeFailoverWorkers
    DummyNodeFailoverWorker w1 = new DummyNodeFailoverWorker(
        server.getServerName().getServerName(), s1);
    DummyNodeFailoverWorker w2 = new DummyNodeFailoverWorker(
View Full Code Here


  @Test
  public void testNodeFailoverDeadServerParsing() throws Exception {
    LOG.debug("testNodeFailoverDeadServerParsing");
    conf.setBoolean(HConstants.ZOOKEEPER_USEMULTI, true);
    final Server server = new DummyServer("ec2-54-234-230-108.compute-1.amazonaws.com");
    AtomicBoolean replicating = new AtomicBoolean(true);
    ReplicationZookeeper rz = new ReplicationZookeeper(server, replicating);
    // populate some znodes in the peer znode
    files.add("log1");
    files.add("log2");
    for (String file : files) {
      rz.addLogToList(file, "1");
    }
    // create 3 DummyServers
    Server s1 = new DummyServer("ip-10-8-101-114.ec2.internal");
    Server s2 = new DummyServer("ec2-107-20-52-47.compute-1.amazonaws.com");
    Server s3 = new DummyServer("ec2-23-20-187-167.compute-1.amazonaws.com");

    // simulate three server fail sequentially
    ReplicationZookeeper rz1 = new ReplicationZookeeper(s1, new AtomicBoolean(true));
    SortedMap<String, SortedSet<String>> testMap =
        rz1.copyQueuesFromRSUsingMulti(server.getServerName().getServerName());
View Full Code Here

  @Test
  public void testShouldNotCompeleteOpenedRegionSuccessfullyIfVersionMismatches()
      throws Exception {
    try {
      TEST_UTIL.startMiniZKCluster();
      final Server server = new MockServer();
      HTableDescriptor htd = new HTableDescriptor(
          "testShouldNotCompeleteOpenedRegionSuccessfullyIfVersionMismatches");
      final HRegionInfo hri = new HRegionInfo(htd, HConstants.EMPTY_END_ROW,
          HConstants.EMPTY_END_ROW);
      HRegion region = HRegion.createHRegion(hri, HBaseTestingUtility
          .getTestDir(), server.getConfiguration());
      assertNotNull(region);
      AssignmentManager am = Mockito.mock(AssignmentManager.class);
      when(am.isRegionInTransition(hri)).thenReturn(
          new RegionState(region.getRegionInfo(), RegionState.State.OPEN,
              System.currentTimeMillis()));
      // create a node with OPENED state
      zkw = HBaseTestingUtility.createAndForceNodeToOpenedState(TEST_UTIL,
          region, server.getServerName());
      when(am.getZKTable()).thenReturn(new ZKTable(zkw));
      Stat stat = new Stat();
      String nodeName = ZKAssign.getNodeName(zkw, hri.getEncodedName());
      ZKUtil.getDataAndWatch(zkw, nodeName, stat);
      // use the version for the OpenedRegionHandler
      OpenedRegionHandler handler = new OpenedRegionHandler(server, am, region
          .getRegionInfo(), new HServerInfo(new HServerAddress(
          new InetSocketAddress(1111)), 0, ""), stat.getVersion());

      // Once again overwrite the same znode so that the version changes.
      ZKAssign.transitionNode(zkw, region.getRegionInfo(), server
          .getServerName(), EventType.RS_ZK_REGION_OPENED,
          EventType.RS_ZK_REGION_OPENED, stat.getVersion());

      // Should not invoke assignmentmanager.regionOnline. If it is invoked as
      // per current mocking it will throw null pointer exception.
View Full Code Here

    LogFactory.getLog(TestClockSkewDetection.class);

  @Test
  public void testClockSkewDetection() throws Exception {
    final Configuration conf = HBaseConfiguration.create();
    ServerManager sm = new ServerManager(new Server() {
      @Override
      public CatalogTracker getCatalogTracker() {
        return null;
      }
View Full Code Here

   * @throws NodeExistsException
   * @throws KeeperException
   */
  @Test public void testOpenRegionHandlerYankingRegionFromUnderIt()
  throws IOException, NodeExistsException, KeeperException {
    final Server server = new MockServer();
    final RegionServerServices rss = new MockRegionServerServices();

    HTableDescriptor htd =
      new HTableDescriptor("testOpenRegionHandlerYankingRegionFromUnderIt");
    final HRegionInfo hri =
      new HRegionInfo(htd, HConstants.EMPTY_END_ROW, HConstants.EMPTY_END_ROW);
    OpenRegionHandler handler = new OpenRegionHandler(server, rss, hri) {
      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
        // been hijacked on us.
        ZooKeeperWatcher zkw = this.server.getZooKeeper();
        String node = ZKAssign.getNodeName(zkw, hri.getEncodedName());
        try {
          ZKUtil.deleteNodeFailSilent(zkw, node);
        } catch (KeeperException e) {
          throw new RuntimeException("Ugh failed delete of " + node, e);
        }
        return region;
      }
    };
    // Call process without first creating OFFLINE region in zk, see if
    // exception or just quiet return (expected).
    handler.process();
    ZKAssign.createNodeOffline(server.getZooKeeper(), hri, server.getServerName());
    // Call process again but this time yank the zk znode out from under it
    // post OPENING; again will expect it to come back w/o NPE or exception.
    handler.process();
  }
View Full Code Here

  public void testExecutorService() throws Exception {
    int maxThreads = 5;
    int maxTries = 10;
    int sleepInterval = 10;

    Server mockedServer = mock(Server.class);
    when(mockedServer.getConfiguration()).thenReturn(HBaseConfiguration.create());

    // Start an executor service pool with max 5 threads
    ExecutorService executorService = new ExecutorService("unit_test");
    executorService.startExecutorService(
      ExecutorType.MASTER_SERVER_OPERATIONS, maxThreads);
View Full Code Here

      when(spiedUponSt).openDaughterRegion((Server)Mockito.anyObject(),
        (RegionServerServices)Mockito.anyObject(), (HRegion)Mockito.anyObject());

    // Run the execute.  Look at what it returns.
    boolean expectedException = false;
    Server mockServer = Mockito.mock(Server.class);
    when(mockServer.getConfiguration()).thenReturn(TEST_UTIL.getConfiguration());
    try {
      spiedUponSt.execute(mockServer, null);
    } catch (IOException e) {
      if (e.getCause() != null &&
          e.getCause() instanceof MockedFailedDaughterOpen) {
View Full Code Here

    // Start transaction.
    SplitTransaction st = prepareGOOD_SPLIT_ROW();

    // Run the execute.  Look at what it returns.
    Server mockServer = Mockito.mock(Server.class);
    when(mockServer.getConfiguration()).thenReturn(TEST_UTIL.getConfiguration());
    PairOfSameType<HRegion> daughters = st.execute(mockServer, null);
    // Do some assertions about execution.
    assertTrue(this.fs.exists(st.getSplitDir()));
    // Assert the parent region is closed.
    assertTrue(this.parent.isClosed());
View Full Code Here

    SplitTransaction spiedUponSt = spy(st);
    when(spiedUponSt.createDaughterRegion(spiedUponSt.getSecondDaughter(), null)).
      thenThrow(new MockedFailedDaughterCreation());
    // Run the execute.  Look at what it returns.
    boolean expectedException = false;
    Server mockServer = Mockito.mock(Server.class);
    when(mockServer.getConfiguration()).thenReturn(TEST_UTIL.getConfiguration());
    try {
      spiedUponSt.execute(mockServer, null);
    } catch (MockedFailedDaughterCreation e) {
      expectedException = true;
    }
View Full Code Here

  }

  @Test
  public void testCleanParent() throws IOException {
    HBaseTestingUtility htu = new HBaseTestingUtility();
    Server server = new MockServer(htu);
    MasterServices services = new MockMasterServices(server);
    CatalogJanitor janitor = new CatalogJanitor(server, services);
    // Create regions.
    HTableDescriptor htd = new HTableDescriptor("table");
    htd.addFamily(new HColumnDescriptor("family"));
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.Server

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.