当前位置: 首页>>代码示例>>Java>>正文


Java RootRegionTracker类代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.zookeeper.RootRegionTracker的典型用法代码示例。如果您正苦于以下问题:Java RootRegionTracker类的具体用法?Java RootRegionTracker怎么用?Java RootRegionTracker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RootRegionTracker类属于org.apache.hadoop.hbase.zookeeper包,在下文中一共展示了RootRegionTracker类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRootRegionServerName

import org.apache.hadoop.hbase.zookeeper.RootRegionTracker; //导入依赖的package包/类
private ServerName getRootRegionServerName()
throws IOException, InterruptedException {
  RootRegionTracker rootRegionTracker =
    new RootRegionTracker(this.connection.getZooKeeperWatcher(), new Abortable() {
      @Override
      public void abort(String why, Throwable e) {
        LOG.error(why, e);
        System.exit(1);
      }
      @Override
      public boolean isAborted(){
        return false;
      }
      
    });
  rootRegionTracker.start();
  ServerName sn = null;
  try {
    sn = rootRegionTracker.getRootRegionLocation();
  } finally {
    rootRegionTracker.stop();
  }
  return sn;
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:25,代码来源:HBaseFsck.java

示例2: testVerifyMetaRegionLocationWithException

import org.apache.hadoop.hbase.zookeeper.RootRegionTracker; //导入依赖的package包/类
private void testVerifyMetaRegionLocationWithException(Exception ex)
throws IOException, InterruptedException, KeeperException, ServiceException {
  // Mock an ClientProtocol.
  final ClientProtocol implementation = Mockito.mock(ClientProtocol.class);
  HConnection connection = mockConnection(null, implementation);
  try {
    // If a 'get' is called on mocked interface, throw connection refused.
    Mockito.when(implementation.get((RpcController) Mockito.any(), (GetRequest) Mockito.any())).
      thenThrow(new ServiceException(ex));
    // Now start up the catalogtracker with our doctored Connection.
    final CatalogTracker ct = constructAndStartCatalogTracker(connection);
    try {
      RootRegionTracker.setRootLocation(this.watcher, SN);
      long timeout = UTIL.getConfiguration().
        getLong("hbase.catalog.verification.timeout", 1000);
      Assert.assertFalse(ct.verifyMetaRegionLocation(timeout));
    } finally {
      // Clean out root location or later tests will be confused... they
      // presume start fresh in zk.
      RootRegionTracker.deleteRootLocation(this.watcher);
    }
  } finally {
    // Clear out our doctored connection or could mess up subsequent tests.
    HConnectionManager.deleteConnection(UTIL.getConfiguration(), true);
  }
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:27,代码来源:TestCatalogTracker.java

示例3: testVerifyRootRegionLocationFails

import org.apache.hadoop.hbase.zookeeper.RootRegionTracker; //导入依赖的package包/类
/**
 * Test get of root region fails properly if nothing to connect to.
 * @throws IOException
 * @throws InterruptedException
 * @throws KeeperException
 * @throws ServiceException
 */
@Test
public void testVerifyRootRegionLocationFails()
throws IOException, InterruptedException, KeeperException, ServiceException {
  HConnection connection = Mockito.mock(HConnection.class);
  ServiceException connectException =
    new ServiceException(new ConnectException("Connection refused"));
  final AdminProtocol implementation =
    Mockito.mock(AdminProtocol.class);
  Mockito.when(implementation.getRegionInfo((RpcController)Mockito.any(),
    (GetRegionInfoRequest)Mockito.any())).thenThrow(connectException);
  Mockito.when(connection.getAdmin(Mockito.anyString(),
    Mockito.anyInt(), Mockito.anyBoolean())).
    thenReturn(implementation);
  final CatalogTracker ct = constructAndStartCatalogTracker(connection);
  try {
    RootRegionTracker.setRootLocation(this.watcher,
      new ServerName("example.com", 1234, System.currentTimeMillis()));
    Assert.assertFalse(ct.verifyRootRegionLocation(100));
  } finally {
    // Clean out root location or later tests will be confused... they presume
    // start fresh in zk.
    RootRegionTracker.deleteRootLocation(this.watcher);
  }
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:32,代码来源:TestCatalogTracker.java

示例4: CatalogTracker

import org.apache.hadoop.hbase.zookeeper.RootRegionTracker; //导入依赖的package包/类
CatalogTracker(final ZooKeeperWatcher zk, final Configuration conf,
    HConnection connection, Abortable abortable)
throws IOException {
  this.connection = connection;
  if (abortable == null) {
    // A connection is abortable.
    this.abortable = this.connection;
  }
  Abortable throwableAborter = new Abortable() {

    @Override
    public void abort(String why, Throwable e) {
      throw new RuntimeException(why, e);
    }

    @Override
    public boolean isAborted() {
      return true;
    }

  };
  if (zk == null) {
    // Create our own.  Set flag so we tear it down on stop.
    this.zookeeper =
      new ZooKeeperWatcher(conf, "catalogtracker-on-" + connection.toString(),
        abortable);
    instantiatedzkw = true;
  } else {
    this.zookeeper = zk;
  }
  this.rootRegionTracker = new RootRegionTracker(zookeeper, throwableAborter);
  final CatalogTracker ct = this;
  // Override nodeDeleted so we get notified when meta node deleted
  this.metaNodeTracker = new MetaNodeTracker(zookeeper, throwableAborter) {
    public void nodeDeleted(String path) {
      if (!path.equals(node)) return;
      ct.resetMetaLocation();
    }
  };
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:41,代码来源:CatalogTracker.java

示例5: setupZookeeperTrackers

import org.apache.hadoop.hbase.zookeeper.RootRegionTracker; //导入依赖的package包/类
private synchronized void setupZookeeperTrackers()
    throws ZooKeeperConnectionException{
  // initialize zookeeper and master address manager
  this.zooKeeper = getZooKeeperWatcher();
  masterAddressTracker = new MasterAddressTracker(this.zooKeeper, this);
  masterAddressTracker.start();

  this.rootRegionTracker = new RootRegionTracker(this.zooKeeper, this);
  this.rootRegionTracker.start();

  this.clusterId = new ClusterId(this.zooKeeper, this);
}
 
开发者ID:lifeng5042,项目名称:RStore,代码行数:13,代码来源:HConnectionManager.java

示例6: locateRegion

import org.apache.hadoop.hbase.zookeeper.RootRegionTracker; //导入依赖的package包/类
private HRegionLocation locateRegion(final byte [] tableName,
  final byte [] row, boolean useCache, boolean retry)
throws IOException {
  if (this.closed) throw new IOException(toString() + " closed");
  if (tableName == null || tableName.length == 0) {
    throw new IllegalArgumentException(
        "table name cannot be null or zero length");
  }

  if (Bytes.equals(tableName, HConstants.ROOT_TABLE_NAME)) {
    ZooKeeperKeepAliveConnection zkw = getKeepAliveZooKeeperWatcher();
    try {
      LOG.debug("Looking up root region location in ZK," +
        " connection=" + this);
      ServerName servername =
        RootRegionTracker.blockUntilAvailable(zkw, this.rpcTimeout);

      LOG.debug("Looked up root region location, connection=" + this +
        "; serverName=" + ((servername == null) ? "null" : servername));
      if (servername == null) return null;
      return new HRegionLocation(HRegionInfo.ROOT_REGIONINFO,
        servername.getHostname(), servername.getPort());
    } catch (InterruptedException e) {
      Thread.currentThread().interrupt();
      return null;
    } finally {
      zkw.close();
    }
  } else if (Bytes.equals(tableName, HConstants.META_TABLE_NAME)) {
    return locateRegionInMeta(HConstants.ROOT_TABLE_NAME, tableName, row,
      useCache, metaRegionLock, retry);
  } else {
    // Region not in the cache - have to go to the meta RS
    return locateRegionInMeta(HConstants.META_TABLE_NAME, tableName, row,
      useCache, userRegionLock, retry);
  }
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:38,代码来源:HConnectionManager.java

示例7: getRootRegionServerName

import org.apache.hadoop.hbase.zookeeper.RootRegionTracker; //导入依赖的package包/类
private ServerName getRootRegionServerName()
throws IOException, KeeperException {
  ZooKeeperWatcher zkw = createZooKeeperWatcher();
  ServerName sn = null;
  try {
    sn = RootRegionTracker.getRootRegionLocation(zkw);
  } finally {
    zkw.close();
  }
  return sn;
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:12,代码来源:HBaseFsck.java

示例8: postOpenDeployTasks

import org.apache.hadoop.hbase.zookeeper.RootRegionTracker; //导入依赖的package包/类
@Override
public void postOpenDeployTasks(final HRegion r, final CatalogTracker ct,
    final boolean daughter)
throws KeeperException, IOException {
  checkOpen();
  LOG.info("Post open deploy tasks for region=" + r.getRegionNameAsString() +
    ", daughter=" + daughter);
  // Do checks to see if we need to compact (references or too many files)
  for (Store s : r.getStores().values()) {
    if (s.hasReferences() || s.needsCompaction()) {
      getCompactionRequester().requestCompaction(r, s, "Opening Region");
    }
  }
  // Update ZK, ROOT or META
  if (r.getRegionInfo().isRootRegion()) {
    RootRegionTracker.setRootLocation(getZooKeeper(),
     this.serverNameFromMasterPOV);
  } else if (r.getRegionInfo().isMetaRegion()) {
    MetaEditor.updateMetaLocation(ct, r.getRegionInfo(),
      this.serverNameFromMasterPOV);
  } else {
    if (daughter) {
      // If daughter of a split, update whole row, not just location.
      MetaEditor.addDaughter(ct, r.getRegionInfo(),
        this.serverNameFromMasterPOV);
    } else {
      MetaEditor.updateRegionLocation(ct, r.getRegionInfo(),
        this.serverNameFromMasterPOV);
    }
  }
  LOG.info("Done with post open deploy task for region=" +
    r.getRegionNameAsString() + ", daughter=" + daughter);

}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:35,代码来源:HRegionServer.java

示例9: testBadOriginalRootLocation

import org.apache.hadoop.hbase.zookeeper.RootRegionTracker; //导入依赖的package包/类
/**
 * @throws Exception 
 * @see {https://issues.apache.org/jira/browse/HBASE-3445}
 */
@Test public void testBadOriginalRootLocation() throws Exception {
  UTIL.getConfiguration().setInt("ipc.socket.timeout", 3000);
  // Launch cluster so it does bootstrapping.
  UTIL.startMiniCluster();
  // Shutdown hbase.
  UTIL.shutdownMiniHBaseCluster();
  // Mess with the root location in the running zk.  Set it to be nonsense.
  ZooKeeperWatcher zookeeper = new ZooKeeperWatcher(UTIL.getConfiguration(),
    "Bad Root Location Writer", new Abortable() {
      @Override
      public void abort(String why, Throwable e) {
        LOG.error("Abort was called on 'bad root location writer'", e);
      }
      
      @Override
      public boolean isAborted() {
        return false;
      }
  });
  ServerName nonsense =
    new ServerName("example.org", 1234, System.currentTimeMillis());
  RootRegionTracker.setRootLocation(zookeeper, nonsense);

  // Bring back up the hbase cluster.  See if it can deal with nonsense root
  // location. The cluster should start and be fully available.
  UTIL.startMiniHBaseCluster(1, 1);

  // if we can create a table, it's a good sign that it's working
  UTIL.createTable(
    getClass().getSimpleName().getBytes(), "family".getBytes());

  UTIL.shutdownMiniCluster();
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:38,代码来源:TestCatalogTrackerOnCluster.java

示例10: testThatIfMETAMovesWeAreNotified

import org.apache.hadoop.hbase.zookeeper.RootRegionTracker; //导入依赖的package包/类
/**
 * Test that we get notification if .META. moves.
 * @throws IOException
 * @throws InterruptedException
 * @throws KeeperException
 */
@Test public void testThatIfMETAMovesWeAreNotified()
throws IOException, InterruptedException, KeeperException {
  HConnection connection = Mockito.mock(HConnection.class);
  constructAndStartCatalogTracker(connection);
  try {
    RootRegionTracker.setRootLocation(this.watcher,
      new ServerName("example.com", 1234, System.currentTimeMillis()));
  } finally {
    // Clean out root location or later tests will be confused... they presume
    // start fresh in zk.
    RootRegionTracker.deleteRootLocation(this.watcher);
  }
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:20,代码来源:TestCatalogTracker.java

示例11: CatalogTracker

import org.apache.hadoop.hbase.zookeeper.RootRegionTracker; //导入依赖的package包/类
CatalogTracker(final ZooKeeperWatcher zk, final Configuration conf,
    HConnection connection, Abortable abortable, final int defaultTimeout)
throws IOException {
  this.connection = connection;
  if (abortable == null) {
    // A connection is abortable.
    this.abortable = this.connection;
  }
  Abortable throwableAborter = new Abortable() {

    @Override
    public void abort(String why, Throwable e) {
      throw new RuntimeException(why, e);
    }

    @Override
    public boolean isAborted() {
      return true;
    }

  };
  if (zk == null) {
    // Create our own.  Set flag so we tear it down on stop.
    this.zookeeper =
      new ZooKeeperWatcher(conf, "catalogtracker-on-" + connection.toString(),
        abortable);
    instantiatedzkw = true;
  } else {
    this.zookeeper = zk;
  }
  this.rootRegionTracker = new RootRegionTracker(zookeeper, throwableAborter);
  final CatalogTracker ct = this;
  // Override nodeDeleted so we get notified when meta node deleted
  this.metaNodeTracker = new MetaNodeTracker(zookeeper, throwableAborter) {
    public void nodeDeleted(String path) {
      if (!path.equals(node)) return;
      ct.resetMetaLocation();
    }
  };
  this.defaultTimeout = defaultTimeout;
}
 
开发者ID:lifeng5042,项目名称:RStore,代码行数:42,代码来源:CatalogTracker.java

示例12: CatalogTracker

import org.apache.hadoop.hbase.zookeeper.RootRegionTracker; //导入依赖的package包/类
public CatalogTracker(final ZooKeeperWatcher zk, final Configuration conf,
    HConnection connection, Abortable abortable, final int defaultTimeout)
throws IOException {
  this.connection = connection;
  if (abortable == null) {
    // A connection is abortable.
    this.abortable = this.connection;
  }
  Abortable throwableAborter = new Abortable() {

    @Override
    public void abort(String why, Throwable e) {
      throw new RuntimeException(why, e);
    }

    @Override
    public boolean isAborted() {
      return true;
    }

  };
  if (zk == null) {
    // Create our own.  Set flag so we tear it down on stop.
    this.zookeeper =
      new ZooKeeperWatcher(conf, "catalogtracker-on-" + connection.toString(),
        abortable);
    instantiatedzkw = true;
  } else {
    this.zookeeper = zk;
  }
  this.rootRegionTracker = new RootRegionTracker(zookeeper, throwableAborter);
  final CatalogTracker ct = this;
  // Override nodeDeleted so we get notified when meta node deleted
  this.metaNodeTracker = new MetaNodeTracker(zookeeper, throwableAborter) {
    public void nodeDeleted(String path) {
      if (!path.equals(node)) return;
      ct.resetMetaLocation();
    }
  };
  this.defaultTimeout = defaultTimeout;
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:42,代码来源:CatalogTracker.java

示例13: setRootLocation

import org.apache.hadoop.hbase.zookeeper.RootRegionTracker; //导入依赖的package包/类
private ServerName setRootLocation() throws KeeperException {
  RootRegionTracker.setRootLocation(this.watcher, SN);
  return SN;
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:5,代码来源:TestCatalogTracker.java

示例14: assignRoot

import org.apache.hadoop.hbase.zookeeper.RootRegionTracker; //导入依赖的package包/类
/**
 * Assigns the ROOT region.
 * <p>
 * Assumes that ROOT is currently closed and is not being actively served by
 * any RegionServer.
 * <p>
 * Forcibly unsets the current root region location in ZooKeeper and assigns
 * ROOT to a random RegionServer.
 * @throws KeeperException
 */
public void assignRoot() throws KeeperException {
  RootRegionTracker.deleteRootLocation(this.watcher);
  assign(HRegionInfo.ROOT_REGIONINFO, true);
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:15,代码来源:AssignmentManager.java


注:本文中的org.apache.hadoop.hbase.zookeeper.RootRegionTracker类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。