Search in sources :

Example 6 with TableDescriptors

use of org.apache.hadoop.hbase.TableDescriptors in project hbase by apache.

the class TestFSTableDescriptors method testNoSuchTable.

@Test
public void testNoSuchTable() throws IOException {
    final String name = "testNoSuchTable";
    FileSystem fs = FileSystem.get(UTIL.getConfiguration());
    // Cleanup old tests if any detrius laying around.
    Path rootdir = new Path(UTIL.getDataTestDir(), name);
    TableDescriptors htds = new FSTableDescriptors(UTIL.getConfiguration(), fs, rootdir);
    assertNull("There shouldn't be any HTD for this table", htds.get(TableName.valueOf("NoSuchTable")));
}
Also used : Path(org.apache.hadoop.fs.Path) TableDescriptors(org.apache.hadoop.hbase.TableDescriptors) FileSystem(org.apache.hadoop.fs.FileSystem) Test(org.junit.Test)

Example 7 with TableDescriptors

use of org.apache.hadoop.hbase.TableDescriptors in project hbase by apache.

the class TestRSGroupBasedLoadBalancer method getMockedMaster.

private static MasterServices getMockedMaster() throws IOException {
    TableDescriptors tds = Mockito.mock(TableDescriptors.class);
    Mockito.when(tds.get(tables[0])).thenReturn(tableDescs.get(0));
    Mockito.when(tds.get(tables[1])).thenReturn(tableDescs.get(1));
    Mockito.when(tds.get(tables[2])).thenReturn(tableDescs.get(2));
    Mockito.when(tds.get(tables[3])).thenReturn(tableDescs.get(3));
    MasterServices services = Mockito.mock(HMaster.class);
    Mockito.when(services.getTableDescriptors()).thenReturn(tds);
    AssignmentManager am = Mockito.mock(AssignmentManager.class);
    Mockito.when(services.getAssignmentManager()).thenReturn(am);
    return services;
}
Also used : TableDescriptors(org.apache.hadoop.hbase.TableDescriptors) AssignmentManager(org.apache.hadoop.hbase.master.AssignmentManager) MasterServices(org.apache.hadoop.hbase.master.MasterServices)

Example 8 with TableDescriptors

use of org.apache.hadoop.hbase.TableDescriptors in project hbase by apache.

the class ReplicationSourceManager method getReplicationSource.

/**
   * Factory method to create a replication source
   * @param conf the configuration to use
   * @param fs the file system to use
   * @param manager the manager to use
   * @param server the server object for this region server
   * @param peerId the id of the peer cluster
   * @return the created source
   * @throws IOException
   */
protected ReplicationSourceInterface getReplicationSource(final Configuration conf, final FileSystem fs, final ReplicationSourceManager manager, final ReplicationQueues replicationQueues, final ReplicationPeers replicationPeers, final Server server, final String peerId, final UUID clusterId, final ReplicationPeerConfig peerConfig, final ReplicationPeer replicationPeer) throws IOException {
    RegionServerCoprocessorHost rsServerHost = null;
    TableDescriptors tableDescriptors = null;
    if (server instanceof HRegionServer) {
        rsServerHost = ((HRegionServer) server).getRegionServerCoprocessorHost();
        tableDescriptors = ((HRegionServer) server).getTableDescriptors();
    }
    ReplicationSourceInterface src;
    try {
        @SuppressWarnings("rawtypes") Class c = Class.forName(conf.get("replication.replicationsource.implementation", ReplicationSource.class.getCanonicalName()));
        src = (ReplicationSourceInterface) c.newInstance();
    } catch (Exception e) {
        LOG.warn("Passed replication source implementation throws errors, " + "defaulting to ReplicationSource", e);
        src = new ReplicationSource();
    }
    ReplicationEndpoint replicationEndpoint = null;
    try {
        String replicationEndpointImpl = peerConfig.getReplicationEndpointImpl();
        if (replicationEndpointImpl == null) {
            // Default to HBase inter-cluster replication endpoint
            replicationEndpointImpl = HBaseInterClusterReplicationEndpoint.class.getName();
        }
        @SuppressWarnings("rawtypes") Class c = Class.forName(replicationEndpointImpl);
        replicationEndpoint = (ReplicationEndpoint) c.newInstance();
        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;
            }
        }
    } catch (Exception e) {
        LOG.warn("Passed replication endpoint implementation throws errors" + " while initializing ReplicationSource for peer: " + peerId, e);
        throw new IOException(e);
    }
    MetricsSource metrics = new MetricsSource(peerId);
    // init replication source
    src.init(conf, fs, manager, replicationQueues, replicationPeers, server, peerId, clusterId, replicationEndpoint, metrics);
    // init replication endpoint
    replicationEndpoint.init(new ReplicationEndpoint.Context(replicationPeer.getConfiguration(), fs, peerId, clusterId, replicationPeer, metrics, tableDescriptors, server));
    return src;
}
Also used : IOException(java.io.IOException) ReplicationException(org.apache.hadoop.hbase.replication.ReplicationException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) IOException(java.io.IOException) HRegionServer(org.apache.hadoop.hbase.regionserver.HRegionServer) RegionServerCoprocessorHost(org.apache.hadoop.hbase.regionserver.RegionServerCoprocessorHost) ReplicationEndpoint(org.apache.hadoop.hbase.replication.ReplicationEndpoint) TableDescriptors(org.apache.hadoop.hbase.TableDescriptors)

Aggregations

TableDescriptors (org.apache.hadoop.hbase.TableDescriptors)8 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)4 FileSystem (org.apache.hadoop.fs.FileSystem)3 Path (org.apache.hadoop.fs.Path)3 Test (org.junit.Test)3 HColumnDescriptor (org.apache.hadoop.hbase.HColumnDescriptor)2 LockManager (org.apache.hadoop.hbase.master.locking.LockManager)2 IOException (java.io.IOException)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1 Connection (org.apache.hadoop.hbase.client.Connection)1 AssignmentManager (org.apache.hadoop.hbase.master.AssignmentManager)1 MasterServices (org.apache.hadoop.hbase.master.MasterServices)1 HRegionServer (org.apache.hadoop.hbase.regionserver.HRegionServer)1 RegionServerCoprocessorHost (org.apache.hadoop.hbase.regionserver.RegionServerCoprocessorHost)1 ReplicationEndpoint (org.apache.hadoop.hbase.replication.ReplicationEndpoint)1 ReplicationException (org.apache.hadoop.hbase.replication.ReplicationException)1