Package org.apache.hadoop.hbase

Examples of org.apache.hadoop.hbase.Server


  @Test
  public void testRemovesEmptyDirectories() throws Exception {
    Configuration conf = UTIL.getConfiguration();
    // no cleaner policies = delete all files
    conf.setStrings(HFileCleaner.MASTER_HFILE_CLEANER_PLUGINS, "");
    Server server = new DummyServer();
    Path archivedHfileDir = new Path(UTIL.getDataTestDir(), HConstants.HFILE_ARCHIVE_DIRECTORY);

    // setup the cleaner
    FileSystem fs = UTIL.getDFSCluster().getFileSystem();
    HFileCleaner cleaner = new HFileCleaner(1000, server, conf, fs, archivedHfileDir);
View Full Code Here


   * @throws NodeExistsException
   * @throws KeeperException
   */
  @Test public void testFailedFlushAborts()
  throws IOException, NodeExistsException, KeeperException {
    final Server server = new MockServer(HTU, false);
    final RegionServerServices rss = new MockRegionServerServices();
    HTableDescriptor htd = TEST_HTD;
    final HRegionInfo hri =
      new HRegionInfo(htd.getName(), HConstants.EMPTY_END_ROW,
        HConstants.EMPTY_END_ROW);
    HRegion region =
      HRegion.createHRegion(hri, HTU.getDataTestDir(),
        HTU.getConfiguration(), htd);
    try {
      assertNotNull(region);
      // Spy on the region so can throw exception when close is called.
      HRegion spy = Mockito.spy(region);
      final boolean abort = false;
      Mockito.when(spy.close(abort)).
      thenThrow(new RuntimeException("Mocked failed close!"));
      // The CloseRegionHandler will try to get an HRegion that corresponds
      // to the passed hri -- so insert the region into the online region Set.
      rss.addToOnlineRegions(spy);
      // Assert the Server is NOT stopped before we call close region.
      assertFalse(server.isStopped());
      CloseRegionHandler handler =
          new CloseRegionHandler(server, rss, hri, false, false, -1);
      boolean throwable = false;
      try {
        handler.process();
      } catch (Throwable t) {
        throwable = true;
      } finally {
        assertTrue(throwable);
        // Abort calls stop so stopped flag should be set.
        assertTrue(server.isStopped());
      }
    } finally {
      HRegion.closeHRegion(region);
    }
  }
View Full Code Here

      * @throws NodeExistsException
      * @throws KeeperException
      */
     @Test public void testZKClosingNodeVersionMismatch()
     throws IOException, NodeExistsException, KeeperException {
       final Server server = new MockServer(HTU);
       final MockRegionServerServices rss = new MockRegionServerServices();
       rss.setFileSystem(HTU.getTestFileSystem());
  
       HTableDescriptor htd = TEST_HTD;
       final HRegionInfo hri = TEST_HRI;
  
       // open a region first so that it can be closed later
       OpenRegion(server, rss, htd, hri);
  
       // 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
       CloseRegionHandler handler =
         new CloseRegionHandler(server, rss, hri, false, true,
         versionOfClosingNode+1);
       handler.process();
  
       // Handler should remain in M_ZK_REGION_CLOSING
       RegionTransitionData data =
         ZKAssign.getData(server.getZooKeeper(), hri.getEncodedName());
       assertTrue(EventType.M_ZK_REGION_CLOSING == data.getEventType());
     }
View Full Code Here

      * @throws NodeExistsException
      * @throws KeeperException
      */
     @Test public void testCloseRegion()
     throws IOException, NodeExistsException, KeeperException {
       final Server server = new MockServer(HTU);
       final MockRegionServerServices rss = new MockRegionServerServices();
       rss.setFileSystem(HTU.getTestFileSystem());
  
       HTableDescriptor htd = TEST_HTD;
       HRegionInfo hri = TEST_HRI;
  
       // open a region first so that it can be closed later
       OpenRegion(server, rss, htd, hri);
  
       // 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
       CloseRegionHandler handler =
         new CloseRegionHandler(server, rss, hri, false, true,
         versionOfClosingNode);
       handler.process();
       // Handler should have transitioned it to RS_ZK_REGION_CLOSED
       RegionTransitionData data =
         ZKAssign.getData(server.getZooKeeper(), hri.getEncodedName());
       assertTrue(EventType.RS_ZK_REGION_CLOSED == data.getEventType());
     }
View Full Code Here

   */
  @Test
  public void testScanDoesNotCleanRegionsWithExistingParents() throws Exception {
    HBaseTestingUtility htu = new HBaseTestingUtility();
    setRootDirAndCleanIt(htu, "testScanDoesNotCleanRegionsWithExistingParents");
    Server server = new MockServer(htu);
    MasterServices services = new MockMasterServices(server);

    final HTableDescriptor htd = createHTableDescriptor();

    // Create regions: aaa->{lastEndKey}, aaa->ccc, aaa->bbb, bbb->ccc, etc.
View Full Code Here

  @Test
  public void testCleanParent() throws IOException, InterruptedException {
    HBaseTestingUtility htu = new HBaseTestingUtility();
    setRootDirAndCleanIt(htu, "testCleanParent");
    Server server = new MockServer(htu);
    try {
      MasterServices services = new MockMasterServices(server);
      CatalogJanitor janitor = new CatalogJanitor(server, services);
      // Create regions.
      HTableDescriptor htd = new HTableDescriptor("table");
      htd.addFamily(new HColumnDescriptor("f"));
      HRegionInfo parent =
        new HRegionInfo(htd.getName(), Bytes.toBytes("aaa"),
            Bytes.toBytes("eee"));
      HRegionInfo splita =
        new HRegionInfo(htd.getName(), Bytes.toBytes("aaa"),
            Bytes.toBytes("ccc"));
      HRegionInfo splitb =
        new HRegionInfo(htd.getName(), Bytes.toBytes("ccc"),
            Bytes.toBytes("eee"));
      // Test that when both daughter regions are in place, that we do not
      // remove the parent.
      List<KeyValue> kvs = new ArrayList<KeyValue>();
      kvs.add(new KeyValue(parent.getRegionName(), HConstants.CATALOG_FAMILY,
          HConstants.SPLITA_QUALIFIER, Writables.getBytes(splita)));
      kvs.add(new KeyValue(parent.getRegionName(), HConstants.CATALOG_FAMILY,
          HConstants.SPLITB_QUALIFIER, Writables.getBytes(splitb)));
      Result r = new Result(kvs);
      // Add a reference under splitA directory so we don't clear out the parent.
      Path rootdir = services.getMasterFileSystem().getRootDir();
      Path tabledir =
        HTableDescriptor.getTableDir(rootdir, htd.getName());
      Path storedir = Store.getStoreHomedir(tabledir, splita.getEncodedName(),
          htd.getColumnFamilies()[0].getName());
      Reference ref = new Reference(Bytes.toBytes("ccc"), Reference.Range.top);
      long now = System.currentTimeMillis();
      // Reference name has this format: StoreFile#REF_NAME_PARSER
      Path p = new Path(storedir, Long.toString(now) + "." + parent.getEncodedName());
      FileSystem fs = services.getMasterFileSystem().getFileSystem();
      Path path = ref.write(fs, p);
      assertTrue(fs.exists(path));
      assertFalse(janitor.cleanParent(parent, r));
      // Remove the reference file and try again.
      assertTrue(fs.delete(p, true));
      assertTrue(janitor.cleanParent(parent, r));
    } finally {
      server.stop("shutdown");
    }
  }
View Full Code Here

  private void parentWithSpecifiedEndKeyCleanedEvenIfDaughterGoneFirst(
  final String rootDir, final byte[] lastEndKey)
  throws IOException, InterruptedException {
    HBaseTestingUtility htu = new HBaseTestingUtility();
    setRootDirAndCleanIt(htu, rootDir);
    Server server = new MockServer(htu);
    MasterServices services = new MockMasterServices(server);
    CatalogJanitor janitor = new CatalogJanitor(server, services);
    final HTableDescriptor htd = createHTableDescriptor();

    // Create regions: aaa->{lastEndKey}, aaa->ccc, aaa->bbb, bbb->ccc, etc.
View Full Code Here

      final String bindAddress, final int port,
      final int numHandlers,
      int metaHandlerCount, final boolean verbose, Configuration conf,
       int highPriorityLevel)
    throws IOException {
    Server server = new Server(instance, ifaces, conf, bindAddress, port,
            numHandlers, metaHandlerCount, verbose,
            highPriorityLevel);
    return server;
  }
View Full Code Here

    List<ServerName> destServers = new ArrayList<ServerName>(1);
    destServers.add(SERVERNAME_A);
    Mockito.when(this.serverManager.createDestinationServersList()).thenReturn(destServers);
    // To avoid cast exception in DisableTableHandler process.
    HTU.getConfiguration().setInt(HConstants.MASTER_PORT, 0);
    Server server = new HMaster(HTU.getConfiguration());
    AssignmentManagerWithExtrasForTesting am = setUpMockedAssignmentManager(server,
        this.serverManager);
    AtomicBoolean gate = new AtomicBoolean(false);
    if (balancer instanceof MockedLoadBalancer) {
      ((MockedLoadBalancer) balancer).setGateVariable(gate);
View Full Code Here

    List<ServerName> destServers = new ArrayList<ServerName>(1);
    destServers.add(SERVERNAME_A);
    Mockito.when(this.serverManager.createDestinationServersList()).thenReturn(destServers);
    Mockito.when(this.serverManager.isServerOnline(SERVERNAME_A)).thenReturn(true);
    HTU.getConfiguration().setInt(HConstants.MASTER_PORT, 0);
    Server server = new HMaster(HTU.getConfiguration());
    Whitebox.setInternalState(server, "serverManager", this.serverManager);
    AssignmentManagerWithExtrasForTesting am = setUpMockedAssignmentManager(server,
        this.serverManager);
    try {
      // set table in enabling state.
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.