Package org.apache.hadoop.hbase.regionserver

Examples of org.apache.hadoop.hbase.regionserver.RegionServerServices


    // Write countPerFamily edits into the three families. Do a flush on one
    // of the families during the load of edits so its seqid is not same as
    // others to test we do right thing when different seqids.
    HLog wal = createWAL(this.conf);
    final AtomicBoolean throwExceptionWhenFlushing = new AtomicBoolean(false);
    RegionServerServices rsServices = Mockito.mock(RegionServerServices.class);
    Mockito.doReturn(false).when(rsServices).isAborted();
    HRegion region = new HRegion(basedir, wal, this.fs, this.conf, hri, htd,
        rsServices) {
      @Override
      protected HStore instantiateHStore(final HColumnDescriptor family) throws IOException {
View Full Code Here


  public static ClusterConnection getConnectionForEnvironment(CoprocessorEnvironment env)
      throws IOException {
    // this bit is a little hacky - just trying to get it going for the moment
    if (env instanceof RegionCoprocessorEnvironment) {
      RegionCoprocessorEnvironment e = (RegionCoprocessorEnvironment) env;
      RegionServerServices services = e.getRegionServerServices();
      if (services instanceof HRegionServer) {
        return new CoprocessorHConnection((HRegionServer) services);
      }
    }
    return ConnectionManager.createConnectionInternal(env.getConfiguration());
View Full Code Here

    // Write countPerFamily edits into the three families. Do a flush on one
    // of the families during the load of edits so its seqid is not same as
    // others to test we do right thing when different seqids.
    HLog wal = createWAL(this.conf);
    final AtomicBoolean throwExceptionWhenFlushing = new AtomicBoolean(false);
    RegionServerServices rsServices = Mockito.mock(RegionServerServices.class);
    Mockito.doReturn(false).when(rsServices).isAborted();
    HRegion region = new HRegion(basedir, wal, this.fs, this.conf, hri, htd,
        rsServices) {
      @Override
      protected Store instantiateHStore(Path tableDir, HColumnDescriptor c)
View Full Code Here

    if (null != list) {
      LOG.trace("Index Manager already contains an entry for the table "
          + ". Hence returning from postOpen");
      return;
    }
    RegionServerServices rss = contx.getEnvironment().getRegionServerServices();
    Configuration conf = rss.getConfiguration();
    IndexedHTableDescriptor tableDescriptor = null;
    try {
      tableDescriptor = IndexUtils.getIndexedHTableDescriptor(tableName, conf);
    } catch (IOException e) {
      rss.abort("Some unidentified scenario while reading from the "
          + "table descriptor . Aborting RegionServer", e);
    }
    if (tableDescriptor != null) {
      list = tableDescriptor.getIndices();
      if (list != null && list.size() > 0) {
View Full Code Here

    // create the region + its WAL
    HRegion region0 = HRegion.createHRegion(hri, hbaseRootDir, this.conf, htd);
    region0.close();
    region0.getLog().closeAndDelete();
    HLog wal = createWAL(this.conf);
    RegionServerServices mockRS = Mockito.mock(RegionServerServices.class);
    // mock out some of the internals of the RSS, so we can run CPs
    Mockito.when(mockRS.getWAL()).thenReturn(wal);
    RegionServerAccounting rsa = Mockito.mock(RegionServerAccounting.class);
    Mockito.when(mockRS.getRegionServerAccounting()).thenReturn(rsa);
    ServerName mockServerName = Mockito.mock(ServerName.class);
    Mockito.when(mockServerName.getServerName()).thenReturn(tableNameStr + "-server-1234");
    Mockito.when(mockRS.getServerName()).thenReturn(mockServerName);
    HRegion region = new HRegion(basedir, wal, this.fs, this.conf, hri, htd, mockRS);
    long seqid = region.initialize();
    // HRegionServer usually does this. It knows the largest seqid across all regions.
    wal.setSequenceNumber(seqid);
   
View Full Code Here

      this.zookeeper = new ZooKeeperWatcher(zkConf, TokenServer.class.getSimpleName(),
          this, true);
      this.rpcServer.start();

      // mock RegionServerServices to provide to coprocessor environment
      final RegionServerServices mockServices = TEST_UTIL.createMockRegionServerService(rpcServer);

      // mock up coprocessor environment
      super.start(new RegionCoprocessorEnvironment() {
        @Override
        public HRegion getRegion() { return null; }
View Full Code Here

   * @throws KeeperException
   */
  @Test public void testFailedFlushAborts()
  throws IOException, NodeExistsException, KeeperException {
    final Server server = new MockServer(HTU, false);
    final RegionServerServices rss = HTU.createMockRegionServerService();
    HTableDescriptor htd = TEST_HTD;
    final HRegionInfo hri =
      new HRegionInfo(htd.getTableName(), HConstants.EMPTY_END_ROW,
        HConstants.EMPTY_END_ROW);
    HRegion region = HTU.createLocalHRegion(hri,  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 IOException("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());

      ZkCoordinatedStateManager consensusProvider = new ZkCoordinatedStateManager();
      consensusProvider.initialize(server);
View Full Code Here

     * @throws DeserializationException
      */
     @Test public void testZKClosingNodeVersionMismatch()
     throws IOException, NodeExistsException, KeeperException, DeserializationException {
       final Server server = new MockServer(HTU);
       final RegionServerServices rss = HTU.createMockRegionServerService();

       HTableDescriptor htd = TEST_HTD;
       final HRegionInfo hri = TEST_HRI;

       ZkCoordinatedStateManager coordinationProvider = new ZkCoordinatedStateManager();
View Full Code Here

     * @throws org.apache.hadoop.hbase.exceptions.DeserializationException
      */
     @Test public void testCloseRegion()
     throws IOException, NodeExistsException, KeeperException, DeserializationException {
       final Server server = new MockServer(HTU);
       final RegionServerServices rss = HTU.createMockRegionServerService();

       HTableDescriptor htd = TEST_HTD;
       HRegionInfo hri = TEST_HRI;

       ZkCoordinatedStateManager coordinationProvider = new ZkCoordinatedStateManager();
View Full Code Here

   * @throws KeeperException
   */
  @Test public void testYankingRegionFromUnderIt()
  throws IOException, NodeExistsException, KeeperException {
    final Server server = new MockServer(HTU);
    final RegionServerServices rss = HTU.createMockRegionServerService();

    HTableDescriptor htd = TEST_HTD;
    final HRegionInfo hri = TEST_HRI;
    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
          // 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;
        }
      };
      rss.getRegionsInTransitionInRS().put(
        hri.getEncodedNameAsBytes(), Boolean.TRUE);
      // Call process without first creating OFFLINE region in zk, see if
      // exception or just quiet return (expected).
      handler.process();
      rss.getRegionsInTransitionInRS().put(
        hri.getEncodedNameAsBytes(), Boolean.TRUE);
      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

TOP

Related Classes of org.apache.hadoop.hbase.regionserver.RegionServerServices

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.