Java Code Examples for org.apache.hadoop.hbase.client.Connection#getConfiguration()
The following examples show how to use
org.apache.hadoop.hbase.client.Connection#getConfiguration() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BackupSystemTable.java From hbase with Apache License 2.0 | 6 votes |
public static void restoreFromSnapshot(Connection conn) throws IOException { Configuration conf = conn.getConfiguration(); LOG.debug("Restoring " + BackupSystemTable.getTableNameAsString(conf) + " from snapshot"); try (Admin admin = conn.getAdmin()) { String snapshotName = BackupSystemTable.getSnapshotName(conf); if (snapshotExists(admin, snapshotName)) { admin.disableTable(BackupSystemTable.getTableName(conf)); admin.restoreSnapshot(snapshotName); admin.enableTable(BackupSystemTable.getTableName(conf)); LOG.debug("Done restoring backup system table"); } else { // Snapshot does not exists, i.e completeBackup failed after // deleting backup system table snapshot // In this case we log WARN and proceed LOG.warn( "Could not restore backup system table. Snapshot " + snapshotName + " does not exists."); } } }
Example 2
Source File: TableBackupClient.java From hbase with Apache License 2.0 | 6 votes |
public void init(final Connection conn, final String backupId, BackupRequest request) throws IOException { if (request.getBackupType() == BackupType.FULL) { backupManager = new BackupManager(conn, conn.getConfiguration()); } else { backupManager = new IncrementalBackupManager(conn, conn.getConfiguration()); } this.backupId = backupId; this.tableList = request.getTableList(); this.conn = conn; this.conf = conn.getConfiguration(); this.fs = CommonFSUtils.getCurrentFileSystem(conf); backupInfo = backupManager.createBackupInfo(backupId, request.getBackupType(), tableList, request.getTargetRootDir(), request.getTotalTasks(), request.getBandwidth()); if (tableList == null || tableList.isEmpty()) { this.tableList = new ArrayList<>(backupInfo.getTables()); } // Start new session backupManager.startBackupSession(); }
Example 3
Source File: BackupClientFactory.java From hbase with Apache License 2.0 | 6 votes |
public static TableBackupClient create(Connection conn, String backupId, BackupRequest request) throws IOException { Configuration conf = conn.getConfiguration(); try { String clsName = conf.get(TableBackupClient.BACKUP_CLIENT_IMPL_CLASS); if (clsName != null) { Class<? extends TableBackupClient> clientImpl; clientImpl = Class.forName(clsName).asSubclass(TableBackupClient.class); TableBackupClient client = clientImpl.getDeclaredConstructor().newInstance(); client.init(conn, backupId, request); return client; } } catch (Exception e) { throw new IOException(e); } BackupType type = request.getBackupType(); if (type == BackupType.FULL) { return new FullTableBackupClient(conn, backupId, request); } else { return new IncrementalTableBackupClient(conn, backupId, request); } }
Example 4
Source File: CanaryTool.java From hbase with Apache License 2.0 | 6 votes |
public RegionMonitor(Connection connection, String[] monitorTargets, boolean useRegExp, Sink sink, ExecutorService executor, boolean writeSniffing, TableName writeTableName, boolean treatFailureAsError, HashMap<String, Long> configuredReadTableTimeouts, long configuredWriteTableTimeout, long allowedFailures) { super(connection, monitorTargets, useRegExp, sink, executor, treatFailureAsError, allowedFailures); Configuration conf = connection.getConfiguration(); this.writeSniffing = writeSniffing; this.writeTableName = writeTableName; this.writeDataTTL = conf.getInt(HConstants.HBASE_CANARY_WRITE_DATA_TTL_KEY, DEFAULT_WRITE_DATA_TTL); this.regionsLowerLimit = conf.getFloat(HConstants.HBASE_CANARY_WRITE_PERSERVER_REGIONS_LOWERLIMIT_KEY, 1.0f); this.regionsUpperLimit = conf.getFloat(HConstants.HBASE_CANARY_WRITE_PERSERVER_REGIONS_UPPERLIMIT_KEY, 1.5f); this.checkPeriod = conf.getInt(HConstants.HBASE_CANARY_WRITE_TABLE_CHECK_PERIOD_KEY, DEFAULT_WRITE_TABLE_CHECK_PERIOD); this.rawScanEnabled = conf.getBoolean(HConstants.HBASE_CANARY_READ_RAW_SCAN_KEY, false); this.configuredReadTableTimeouts = new HashMap<>(configuredReadTableTimeouts); this.configuredWriteTableTimeout = configuredWriteTableTimeout; this.readAllCF = conf.getBoolean(HConstants.HBASE_CANARY_READ_ALL_CF, true); }
Example 5
Source File: CanaryTool.java From hbase with Apache License 2.0 | 6 votes |
protected ZookeeperMonitor(Connection connection, String[] monitorTargets, boolean useRegExp, Sink sink, ExecutorService executor, boolean treatFailureAsError, long allowedFailures) { super(connection, monitorTargets, useRegExp, sink, executor, treatFailureAsError, allowedFailures); Configuration configuration = connection.getConfiguration(); znode = configuration.get(ZOOKEEPER_ZNODE_PARENT, DEFAULT_ZOOKEEPER_ZNODE_PARENT); timeout = configuration .getInt(HConstants.ZK_SESSION_TIMEOUT, HConstants.DEFAULT_ZK_SESSION_TIMEOUT); ConnectStringParser parser = new ConnectStringParser(ZKConfig.getZKQuorumServersString(configuration)); hosts = Lists.newArrayList(); for (InetSocketAddress server : parser.getServerAddresses()) { hosts.add(server.toString()); } if (allowedFailures > (hosts.size() - 1) / 2) { LOG.warn( "Confirm allowable number of failed ZooKeeper nodes, as quorum will " + "already be lost. Setting of {} failures is unexpected for {} ensemble size.", allowedFailures, hosts.size()); } }
Example 6
Source File: BackupSystemTable.java From hbase with Apache License 2.0 | 5 votes |
public static void deleteSnapshot(Connection conn) throws IOException { Configuration conf = conn.getConfiguration(); LOG.debug("Deleting " + BackupSystemTable.getSnapshotName(conf) + " from the system"); try (Admin admin = conn.getAdmin()) { String snapshotName = BackupSystemTable.getSnapshotName(conf); if (snapshotExists(admin, snapshotName)) { admin.deleteSnapshot(snapshotName); LOG.debug("Done deleting backup system table snapshot"); } else { LOG.error("Snapshot " + snapshotName + " does not exists"); } } }
Example 7
Source File: RestoreTablesClient.java From hbase with Apache License 2.0 | 5 votes |
public RestoreTablesClient(Connection conn, RestoreRequest request) { this.targetRootDir = request.getBackupRootDir(); this.backupId = request.getBackupId(); this.sTableArray = request.getFromTables(); this.tTableArray = request.getToTables(); if (tTableArray == null || tTableArray.length == 0) { this.tTableArray = sTableArray; } this.isOverwrite = request.isOverwrite(); this.conn = conn; this.conf = conn.getConfiguration(); }
Example 8
Source File: BackupSystemTable.java From hbase with Apache License 2.0 | 4 votes |
public static void snapshot(Connection conn) throws IOException { try (Admin admin = conn.getAdmin()) { Configuration conf = conn.getConfiguration(); admin.snapshot(BackupSystemTable.getSnapshotName(conf), BackupSystemTable.getTableName(conf)); } }
Example 9
Source File: PerformanceEvaluation.java From hbase with Apache License 2.0 | 4 votes |
Test(final Connection con, final TestOptions options, final Status status) { super(con == null ? HBaseConfiguration.create() : con.getConfiguration(), options, status); this.connection = con; }
Example 10
Source File: RebuildIndexConnectionPropsIT.java From phoenix with Apache License 2.0 | 4 votes |
@Test public void testRebuildIndexConnectionProperties() throws Exception { try (PhoenixConnection rebuildIndexConnection = MetaDataRegionObserver.getRebuildIndexConnection(hbaseTestUtil.getMiniHBaseCluster().getConfiguration())) { try (PhoenixConnection regularConnection = DriverManager.getConnection(url).unwrap(PhoenixConnection.class)) { String rebuildUrl = rebuildIndexConnection.getURL(); // assert that we are working with non-test urls assertFalse(PhoenixEmbeddedDriver.isTestUrl(url)); assertFalse(PhoenixEmbeddedDriver.isTestUrl(rebuildUrl)); // assert that the url ends with expected string assertTrue( rebuildUrl.contains(MetaDataRegionObserver.REBUILD_INDEX_APPEND_TO_URL_STRING)); // assert that the url for regular connection vs the rebuild connection is different assertFalse(rebuildUrl.equals(regularConnection.getURL())); Configuration rebuildQueryServicesConfig = rebuildIndexConnection.getQueryServices().getConfiguration(); // assert that the properties are part of the query services config assertEquals( Long.toString(QueryServicesOptions.DEFAULT_INDEX_REBUILD_QUERY_TIMEOUT), rebuildQueryServicesConfig.get(QueryServices.THREAD_TIMEOUT_MS_ATTRIB)); assertEquals( Long.toString( QueryServicesOptions.DEFAULT_INDEX_REBUILD_CLIENT_SCANNER_TIMEOUT), rebuildQueryServicesConfig.get(HConstants.HBASE_CLIENT_SCANNER_TIMEOUT_PERIOD)); assertEquals(Long.toString(QueryServicesOptions.DEFAULT_INDEX_REBUILD_RPC_TIMEOUT), rebuildQueryServicesConfig.get(HConstants.HBASE_RPC_TIMEOUT_KEY)); assertEquals( Long.toString(NUM_RPC_RETRIES), rebuildQueryServicesConfig.get(HConstants.HBASE_CLIENT_RETRIES_NUMBER)); ConnectionQueryServices rebuildQueryServices = rebuildIndexConnection.getQueryServices(); Connection rebuildIndexHConnection = (Connection) Whitebox.getInternalState(rebuildQueryServices, "connection"); Connection regularHConnection = (Connection) Whitebox.getInternalState( regularConnection.getQueryServices(), "connection"); // assert that a new HConnection was created assertFalse( regularHConnection.toString().equals(rebuildIndexHConnection.toString())); Configuration rebuildHConnectionConfig = rebuildIndexHConnection.getConfiguration(); // assert that the HConnection has the desired properties needed for rebuilding // indices assertEquals( Long.toString( QueryServicesOptions.DEFAULT_INDEX_REBUILD_CLIENT_SCANNER_TIMEOUT), rebuildHConnectionConfig.get(HConstants.HBASE_CLIENT_SCANNER_TIMEOUT_PERIOD)); assertEquals(Long.toString(QueryServicesOptions.DEFAULT_INDEX_REBUILD_RPC_TIMEOUT), rebuildHConnectionConfig.get(HConstants.HBASE_RPC_TIMEOUT_KEY)); assertEquals( Long.toString(NUM_RPC_RETRIES), rebuildHConnectionConfig.get(HConstants.HBASE_CLIENT_RETRIES_NUMBER)); } } }