Examples of HConnection


Examples of org.apache.hadoop.hbase.HConnection

 
  public ReturnMsg execute(final Configuration conf) {
    if (this.tableName == null)
      return new ReturnMsg(0, "Syntax error : Please check 'Describe' syntax");
    try {
      HConnection conn = HConnectionManager.getConnection(conf);
      if (!conn.tableExists(this.tableName)) {
        return new ReturnMsg(0, "Table not found");
      }
      HTableDescriptor [] tables = conn.listTables();
      HColumnDescriptor [] columns = null;
      for (int i = 0; i < tables.length; i++) {
        if (tables[i].getName().equals(this.tableName)) {
          columns = tables[i].getFamilies().values().
            toArray(new HColumnDescriptor [] {});
View Full Code Here

Examples of org.apache.hadoop.hbase.client.HConnection

          + System.getProperty("file.separator") + htd.getNameAsString()
          + System.getProperty("file.separator") + regionToDeleteInFS);
      getDFSCluster().getFileSystem().delete(tableDir);
    }
    // flush cache of regions
    HConnection conn = table.getConnection();
    conn.clearRegionCache();
    // assign all the new regions IF table is enabled.
    HBaseAdmin admin = getHBaseAdmin();
    if (admin.isTableEnabled(table.getTableName())) {
      for(HRegionInfo hri : newRegions) {
        admin.assign(hri.getRegionName());
View Full Code Here

Examples of org.apache.hadoop.hbase.client.HConnection

    // Return a good result first and then return null to indicate end of scan
    Mockito.when(implementation.next(Mockito.anyLong(), Mockito.anyInt())).
      thenReturn(new Result [] {r}, (Result [])null);

    // Get a connection w/ mocked up common methods.
    HConnection connection =
      HConnectionTestingUtility.getMockedConnectionAndDecorate(HTU.getConfiguration(),
        implementation, SERVERNAME_B, REGIONINFO);

    // Make it so we can get a catalogtracker from servermanager.. .needed
    // down in guts of server shutdown handler.
View Full Code Here

Examples of org.apache.hadoop.hbase.client.HConnection

      Mockito.when(ri.next(Mockito.anyLong(), Mockito.anyInt())).thenReturn(new Result[] { r });
      // If a get, return the above result too for REGIONINFO
      Mockito.when(ri.get((byte[]) Mockito.any(), (Get) Mockito.any())).thenReturn(r);
    }
    // Get a connection w/ mocked up common methods.
    HConnection connection = HConnectionTestingUtility.
      getMockedConnectionAndDecorate(HTU.getConfiguration(), ri, SERVERNAME_B,
        REGIONINFO);
    // Make it so we can get the connection from our mocked catalogtracker
    Mockito.when(ct.getConnection()).thenReturn(connection);
    // Create and startup an executor. Used by AM handling zk callbacks.
View Full Code Here

Examples of org.apache.hadoop.hbase.client.HConnection

    throws IOException {
    ClusterStatus status = admin.getMaster().getClusterStatus();
    Collection<ServerName> regionServers = status.getServers();
    Map<ServerName, List<String>> mm =
        new HashMap<ServerName, List<String>>();
    HConnection connection = admin.getConnection();
    for (ServerName hsi : regionServers) {
      HRegionInterface server =
        connection.getHRegionConnection(hsi.getHostname(), hsi.getPort());

      // list all online regions from this region server
      List<HRegionInfo> regions = server.getOnlineRegions();
      List<String> regionNames = new ArrayList<String>();
      for (HRegionInfo hri : regions) {
View Full Code Here

Examples of org.apache.hadoop.hbase.client.HConnection

   * @throws InterruptedException
   * @throws KeeperException
   */
  @Test public void testThatIfMETAMovesWeAreNotified()
  throws IOException, InterruptedException, KeeperException {
    HConnection connection = Mockito.mock(HConnection.class);
    constructAndStartCatalogTracker(connection);
    try {
      RootLocationEditor.setRootLocation(this.watcher,
        new ServerName("example.com", 1234, System.currentTimeMillis()));
    } finally {
View Full Code Here

Examples of org.apache.hadoop.hbase.client.HConnection

   * @throws InterruptedException
   */
  @Test public void testInterruptWaitOnMetaAndRoot()
  throws IOException, InterruptedException {
    HRegionInterface implementation = Mockito.mock(HRegionInterface.class);
    HConnection connection = mockConnection(implementation);
    try {
      final CatalogTracker ct = constructAndStartCatalogTracker(connection);
      ServerName hsa = ct.getRootLocation();
      Assert.assertNull(hsa);
      ServerName meta = ct.getMetaLocation();
View Full Code Here

Examples of org.apache.hadoop.hbase.client.HConnection

  @Test
  public void testServerNotRunningIOException()
  throws IOException, InterruptedException, KeeperException {
    // Mock an HRegionInterface.
    final HRegionInterface implementation = Mockito.mock(HRegionInterface.class);
    HConnection connection = mockConnection(implementation);
    try {
      // If a 'getRegionInfo' is called on mocked HRegionInterface, throw IOE
      // the first time.  'Succeed' the second time we are called.
      Mockito.when(implementation.getRegionInfo((byte[]) Mockito.any())).
        thenThrow(new IOException("Server not running, aborting")).
        thenReturn(new HRegionInfo());

      // After we encounter the above 'Server not running', we should catch the
      // IOE and go into retrying for the meta mode.  We'll do gets on -ROOT- to
      // get new meta location.  Return something so this 'get' succeeds
      // (here we mock up getRegionServerWithRetries, the wrapper around
      // the actual get).

      // TODO: Refactor.  This method has been moved out of HConnection.
      // It works for now but has been deprecated.
      Mockito.when(connection.getRegionServerWithRetries((ServerCallable<Result>)Mockito.any())).
        thenReturn(getMetaTableRowResult());

      // Now start up the catalogtracker with our doctored Connection.
      final CatalogTracker ct = constructAndStartCatalogTracker(connection);
      try {
View Full Code Here

Examples of org.apache.hadoop.hbase.client.HConnection

  private void testVerifyMetaRegionLocationWithException(Exception ex)
  throws IOException, InterruptedException, KeeperException {
    // Mock an HRegionInterface.
    final HRegionInterface implementation = Mockito.mock(HRegionInterface.class);
    HConnection connection = mockConnection(implementation);
    try {
      // If a 'get' is called on mocked interface, throw connection refused.
      Mockito.when(implementation.get((byte[]) Mockito.any(), (Get) Mockito.any())).
        thenThrow(ex);
      // Now start up the catalogtracker with our doctored Connection.
View Full Code Here

Examples of org.apache.hadoop.hbase.client.HConnection

   * @throws KeeperException
   */
  @Test
  public void testVerifyRootRegionLocationFails()
  throws IOException, InterruptedException, KeeperException {
    HConnection connection = Mockito.mock(HConnection.class);
    ConnectException connectException =
      new ConnectException("Connection refused");
    final HRegionInterface implementation =
      Mockito.mock(HRegionInterface.class);
    Mockito.when(implementation.getRegionInfo((byte [])Mockito.any())).
      thenThrow(connectException);
    Mockito.when(connection.getHRegionConnection(Mockito.anyString(),
      Mockito.anyInt(), Mockito.anyBoolean())).
      thenReturn(implementation);
    final CatalogTracker ct = constructAndStartCatalogTracker(connection);
    try {
      RootLocationEditor.setRootLocation(this.watcher,
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.