Package org.apache.hadoop.hbase.regionserver

Examples of org.apache.hadoop.hbase.regionserver.HRegionServer$PeriodicMemstoreFlusher


      throws Exception {
    byte[] TABLENAME = Bytes.toBytes("TestHBACloseRegion");
    createTableWithDefaultConf(TABLENAME);

    HRegionInfo info = null;
    HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(TABLENAME);
    List<HRegionInfo> onlineRegions = rs.getOnlineRegions();
    for (HRegionInfo regionInfo : onlineRegions) {
      if (!regionInfo.isMetaTable()) {
        info = regionInfo;
        admin.closeRegionWithEncodedRegionName(regionInfo.getEncodedName(), rs
            .getServerName().getServerName());
      }
    }
    boolean isInList = rs.getOnlineRegions().contains(info);
    long timeout = System.currentTimeMillis() + 10000;
    while ((System.currentTimeMillis() < timeout) && (isInList)) {
      Thread.sleep(100);
      isInList = rs.getOnlineRegions().contains(info);
    }
    assertFalse("The region should not be present in online regions list.",
        isInList);
  }
View Full Code Here


  public void testCloseRegionIfInvalidRegionNameIsPassed() throws Exception {
    byte[] TABLENAME = Bytes.toBytes("TestHBACloseRegion1");
    createTableWithDefaultConf(TABLENAME);

    HRegionInfo info = null;
    HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(TABLENAME);
    List<HRegionInfo> onlineRegions = rs.getOnlineRegions();
    for (HRegionInfo regionInfo : onlineRegions) {
      if (!regionInfo.isMetaTable()) {
        if (regionInfo.getRegionNameAsString().contains("TestHBACloseRegion1")) {
          info = regionInfo;
          admin.closeRegionWithEncodedRegionName("sample", rs.getServerName()
              .getServerName());
        }
      }
    }
    onlineRegions = rs.getOnlineRegions();
    assertTrue("The region should be present in online regions list.",
        onlineRegions.contains(info));
  }
View Full Code Here

  public void testCloseRegionThatFetchesTheHRIFromMeta() throws Exception {
    byte[] TABLENAME = Bytes.toBytes("TestHBACloseRegion2");
    createTableWithDefaultConf(TABLENAME);

    HRegionInfo info = null;
    HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(TABLENAME);
    List<HRegionInfo> onlineRegions = rs.getOnlineRegions();
    for (HRegionInfo regionInfo : onlineRegions) {
      if (!regionInfo.isMetaTable()) {

        if (regionInfo.getRegionNameAsString().contains("TestHBACloseRegion2")) {
          info = regionInfo;
          admin.closeRegion(regionInfo.getRegionNameAsString(), rs
              .getServerName().getServerName());
        }
      }
    }

    boolean isInList = rs.getOnlineRegions().contains(info);
    long timeout = System.currentTimeMillis() + 10000;
    while ((System.currentTimeMillis() < timeout) && (isInList)) {
      Thread.sleep(100);
      isInList = rs.getOnlineRegions().contains(info);
    }

    assertFalse("The region should not be present in online regions list.",
      isInList);
  }
View Full Code Here

  @Test
  public void testCloseRegionWhenServerNameIsNull() throws Exception {
    byte[] TABLENAME = Bytes.toBytes("TestHBACloseRegion3");
    createTableWithDefaultConf(TABLENAME);

    HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(TABLENAME);

    try {
      List<HRegionInfo> onlineRegions = rs.getOnlineRegions();
      for (HRegionInfo regionInfo : onlineRegions) {
        if (!regionInfo.isMetaTable()) {
          if (regionInfo.getRegionNameAsString()
              .contains("TestHBACloseRegion3")) {
            admin.closeRegionWithEncodedRegionName(regionInfo.getEncodedName(),
View Full Code Here

  @Test
  public void testCloseRegionWhenServerNameIsEmpty() throws Exception {
    byte[] TABLENAME = Bytes.toBytes("TestHBACloseRegionWhenServerNameIsEmpty");
    createTableWithDefaultConf(TABLENAME);

    HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(TABLENAME);

    try {
      List<HRegionInfo> onlineRegions = rs.getOnlineRegions();
      for (HRegionInfo regionInfo : onlineRegions) {
        if (!regionInfo.isMetaTable()) {
          if (regionInfo.getRegionNameAsString()
              .contains("TestHBACloseRegionWhenServerNameIsEmpty")) {
            admin.closeRegionWithEncodedRegionName(regionInfo.getEncodedName(),
View Full Code Here

  public void testCloseRegionWhenEncodedRegionNameIsNotGiven() throws Exception {
    byte[] TABLENAME = Bytes.toBytes("TestHBACloseRegion4");
    createTableWithDefaultConf(TABLENAME);

    HRegionInfo info = null;
    HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(TABLENAME);

    List<HRegionInfo> onlineRegions = rs.getOnlineRegions();
    for (HRegionInfo regionInfo : onlineRegions) {
      if (!regionInfo.isMetaTable()) {
        if (regionInfo.getRegionNameAsString().contains("TestHBACloseRegion4")) {
          info = regionInfo;
          admin.closeRegionWithEncodedRegionName(regionInfo
              .getRegionNameAsString(), rs.getServerName().getServerName());
        }
      }
    }
    onlineRegions = rs.getOnlineRegions();
    assertTrue("The region should be present in online regions list.",
        onlineRegions.contains(info));
  }
View Full Code Here

    StringBuilder v = new StringBuilder(className);
    while (v.length() < 1000) {
      v.append(className);
    }
    byte[] value = Bytes.toBytes(v.toString());
    HRegionServer regionServer = startAndWriteData("TestLogRolling", value);
    LOG.info("after writing there are "
        + HLogUtilsForTests.getNumLogFiles(regionServer.getWAL()) + " log files");

    // flush all regions

    List<HRegion> regions = new ArrayList<HRegion>(regionServer
        .getOnlineRegionsLocalContext());
    for (HRegion r : regions) {
      r.flushcache();
    }
    admin.rollHLogWriter(regionServer.getServerName().getServerName());
    int count = HLogUtilsForTests.getNumLogFiles(regionServer.getWAL());
    LOG.info("after flushing all regions and rolling logs there are " +
        count + " log files");
    assertTrue(("actual count: " + count), count <= 3);
  }
View Full Code Here

  private HRegionServer startAndWriteData(String tableName, byte[] value)
      throws IOException {
    // When the META table can be opened, the region servers are running
    new HTable(
      TEST_UTIL.getConfiguration(), HConstants.META_TABLE_NAME).close();
    HRegionServer regionServer = TEST_UTIL.getHBaseCluster()
        .getRegionServerThreads().get(0).getRegionServer();

    // Create the test table and open it
    HTableDescriptor desc = new HTableDescriptor(tableName);
    desc.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY));
View Full Code Here

   */
  @Test
  public void testNonServerLocalLookup() throws Exception {
    Configuration conf = UTIL.getConfiguration();
    // make a fake server that should never be called
    HRegionServer server = Mockito.mock(HRegionServer.class);
    ServerName name = new ServerName("not.a.server.hostname", 12345, -1L);
    Mockito.when(server.getServerName()).thenReturn(name);
    CoprocessorHConnection connection = new CoprocessorHConnection(conf, server);

    // make sure we get the mock server when doing a direct lookup
    assertEquals("Didn't get the mock server from the connection", server,
      connection.getHRegionConnection(name.getHostname(), name.getPort()));
View Full Code Here

  @Test
  public void testLocalServerLookup() throws Exception {
    Configuration conf = UTIL.getConfiguration();
    // get a real rs
    HRegionServer server =
        UTIL.getMiniHBaseCluster().getLiveRegionServerThreads().get(0).getRegionServer();
    // fake the connection to look like we are living on that server
    CoprocessorHConnection connection = new CoprocessorHConnection(conf, server);

    // create a table that exists
    byte[] tableName = Bytes.toBytes("testLocalServerLookup");
    byte[] family = Bytes.toBytes("family");
    UTIL.createTable(tableName, family);

    // if we can write to the table correctly, then our connection is doing the right thing
    HTable table = new HTable(tableName, connection);
    Put p = new Put(Bytes.toBytes("row"));
    p.add(family, null, null);
    table.put(p);
    table.flushCommits();

    //make sure we get the actual server when doing a direct lookup
    ServerName name = server.getServerName();
    assertEquals("Didn't get the expected server from the connection", server,
      connection.getHRegionConnection(name.getHostname(), name.getPort()));

    // cleanup
    table.close();
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.regionserver.HRegionServer$PeriodicMemstoreFlusher

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.