Search in sources :

Example 56 with HRegionServer

use of org.apache.hadoop.hbase.regionserver.HRegionServer in project hbase by apache.

the class HBaseTestingUtil method ensureSomeNonStoppedRegionServersAvailable.

/**
 * Make sure that at least the specified number of region servers are running. We don't count the
 * ones that are currently stopping or are stopped.
 * @param num minimum number of region servers that should be running
 * @return true if we started some servers
 */
public boolean ensureSomeNonStoppedRegionServersAvailable(final int num) throws IOException {
    boolean startedServer = ensureSomeRegionServersAvailable(num);
    int nonStoppedServers = 0;
    for (JVMClusterUtil.RegionServerThread rst : getMiniHBaseCluster().getRegionServerThreads()) {
        HRegionServer hrs = rst.getRegionServer();
        if (hrs.isStopping() || hrs.isStopped()) {
            LOG.info("A region server is stopped or stopping:" + hrs);
        } else {
            nonStoppedServers++;
        }
    }
    for (int i = nonStoppedServers; i < num; ++i) {
        LOG.info("Started new server=" + getMiniHBaseCluster().startRegionServer());
        startedServer = true;
    }
    return startedServer;
}
Also used : JVMClusterUtil(org.apache.hadoop.hbase.util.JVMClusterUtil) RegionServerThread(org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread) HRegionServer(org.apache.hadoop.hbase.regionserver.HRegionServer)

Example 57 with HRegionServer

use of org.apache.hadoop.hbase.regionserver.HRegionServer in project hbase by apache.

the class ReplicationSource method createReplicationEndpoint.

private ReplicationEndpoint createReplicationEndpoint() throws InstantiationException, IllegalAccessException, ClassNotFoundException, IOException {
    RegionServerCoprocessorHost rsServerHost = null;
    if (server instanceof HRegionServer) {
        rsServerHost = ((HRegionServer) server).getRegionServerCoprocessorHost();
    }
    String replicationEndpointImpl = replicationPeer.getPeerConfig().getReplicationEndpointImpl();
    ReplicationEndpoint replicationEndpoint;
    if (replicationEndpointImpl == null) {
        // Default to HBase inter-cluster replication endpoint; skip reflection
        replicationEndpoint = new HBaseInterClusterReplicationEndpoint();
    } else {
        try {
            replicationEndpoint = Class.forName(replicationEndpointImpl).asSubclass(ReplicationEndpoint.class).getDeclaredConstructor().newInstance();
        } catch (NoSuchMethodException | InvocationTargetException e) {
            throw new IllegalArgumentException(e);
        }
    }
    if (rsServerHost != null) {
        ReplicationEndpoint newReplicationEndPoint = rsServerHost.postCreateReplicationEndPoint(replicationEndpoint);
        if (newReplicationEndPoint != null) {
            // Override the newly created endpoint from the hook with configured end point
            replicationEndpoint = newReplicationEndPoint;
        }
    }
    return replicationEndpoint;
}
Also used : RegionServerCoprocessorHost(org.apache.hadoop.hbase.regionserver.RegionServerCoprocessorHost) ReplicationEndpoint(org.apache.hadoop.hbase.replication.ReplicationEndpoint) InvocationTargetException(java.lang.reflect.InvocationTargetException) HRegionServer(org.apache.hadoop.hbase.regionserver.HRegionServer)

Example 58 with HRegionServer

use of org.apache.hadoop.hbase.regionserver.HRegionServer in project hbase by apache.

the class ReplicationSource method initAndStartReplicationEndpoint.

private void initAndStartReplicationEndpoint(ReplicationEndpoint replicationEndpoint) throws IOException, TimeoutException {
    TableDescriptors tableDescriptors = null;
    if (server instanceof HRegionServer) {
        tableDescriptors = ((HRegionServer) server).getTableDescriptors();
    }
    replicationEndpoint.init(new ReplicationEndpoint.Context(server, conf, replicationPeer.getConfiguration(), fs, replicationPeer.getId(), clusterId, replicationPeer, metrics, tableDescriptors, server));
    replicationEndpoint.start();
    replicationEndpoint.awaitRunning(waitOnEndpointSeconds, TimeUnit.SECONDS);
}
Also used : ReplicationEndpoint(org.apache.hadoop.hbase.replication.ReplicationEndpoint) TableDescriptors(org.apache.hadoop.hbase.TableDescriptors) HRegionServer(org.apache.hadoop.hbase.regionserver.HRegionServer)

Example 59 with HRegionServer

use of org.apache.hadoop.hbase.regionserver.HRegionServer in project hbase by apache.

the class SingleProcessHBaseCluster method abortRegionServer.

/**
 * Cause a region server to exit doing basic clean up only on its way out.
 * @param serverNumber Used as index into a list.
 */
public String abortRegionServer(int serverNumber) {
    HRegionServer server = getRegionServer(serverNumber);
    LOG.info("Aborting " + server.toString());
    server.abort("Aborting for tests", new Exception("Trace info"));
    return server.toString();
}
Also used : IOException(java.io.IOException) HRegionServer(org.apache.hadoop.hbase.regionserver.HRegionServer)

Example 60 with HRegionServer

use of org.apache.hadoop.hbase.regionserver.HRegionServer in project hbase by apache.

the class HBaseTestingUtil method expireRegionServerSession.

/**
 * Expire a region server's session
 * @param index which RS
 */
public void expireRegionServerSession(int index) throws Exception {
    HRegionServer rs = getMiniHBaseCluster().getRegionServer(index);
    expireSession(rs.getZooKeeper(), false);
    decrementMinRegionServerCount();
}
Also used : HRegionServer(org.apache.hadoop.hbase.regionserver.HRegionServer)

Aggregations

HRegionServer (org.apache.hadoop.hbase.regionserver.HRegionServer)253 Test (org.junit.Test)188 TableName (org.apache.hadoop.hbase.TableName)70 Table (org.apache.hadoop.hbase.client.Table)67 HRegion (org.apache.hadoop.hbase.regionserver.HRegion)59 IOException (java.io.IOException)53 Region (org.apache.hadoop.hbase.regionserver.Region)49 Configuration (org.apache.hadoop.conf.Configuration)47 ServerName (org.apache.hadoop.hbase.ServerName)46 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)41 RegionInfo (org.apache.hadoop.hbase.client.RegionInfo)41 Put (org.apache.hadoop.hbase.client.Put)39 SingleProcessHBaseCluster (org.apache.hadoop.hbase.SingleProcessHBaseCluster)32 RegionServerThread (org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread)32 JVMClusterUtil (org.apache.hadoop.hbase.util.JVMClusterUtil)23 List (java.util.List)22 HMaster (org.apache.hadoop.hbase.master.HMaster)22 ArrayList (java.util.ArrayList)21 HBaseClassTestRule (org.apache.hadoop.hbase.HBaseClassTestRule)21 Waiter (org.apache.hadoop.hbase.Waiter)21