@Override public Configuration getConfiguration() { return this.conn.getConfiguration(); }
/** * Contacts a region server and waits up to hbase.hbck.close.timeout ms * (default 120s) to close the region. This bypasses the active hmaster. */ @SuppressWarnings("deprecation") public static void closeRegionSilentlyAndWait(Connection connection, ServerName server, RegionInfo region) throws IOException, InterruptedException { long timeout = connection.getConfiguration() .getLong("hbase.hbck.close.timeout", 120000); ServerManager.closeRegionSilentlyAndWait((ClusterConnection)connection, server, region, timeout); }
Test(final Connection con, final TestOptions options, final Status status) { super(con == null ? HBaseConfiguration.create() : con.getConfiguration(), options, status); this.connection = con; } }
private static Scan getMetaScan(Connection connection, int rowUpperLimit) { Scan scan = new Scan(); int scannerCaching = connection.getConfiguration() .getInt(HConstants.HBASE_META_SCANNER_CACHING, HConstants.DEFAULT_HBASE_META_SCANNER_CACHING); if (connection.getConfiguration().getBoolean(HConstants.USE_META_REPLICAS, HConstants.DEFAULT_USE_META_REPLICAS)) { scan.setConsistency(Consistency.TIMELINE); } if (rowUpperLimit > 0) { scan.setLimit(rowUpperLimit); scan.setReadType(Scan.ReadType.PREAD); } scan.setCaching(scannerCaching); return scan; } /**
public HBaseResourceStore(KylinConfig kylinConfig) throws IOException { super(kylinConfig); metadataUrl = buildMetadataUrl(kylinConfig); tableName = metadataUrl.getIdentifier(); createHTableIfNeeded(tableName); kvSizeLimit = Integer .parseInt(getConnection().getConfiguration().get("hbase.client.keyvalue.maxsize", "10485760")); }
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"); } } }
public BackupSystemTable(Connection conn) throws IOException { this.connection = conn; Configuration conf = this.connection.getConfiguration(); tableName = BackupSystemTable.getTableName(conf); bulkLoadTableName = BackupSystemTable.getTableNameForBulkLoadedData(conf); checkSystemTable(); }
public static boolean snapshotExists(Connection conn) throws IOException { return snapshotExists(conn.getAdmin(), getSnapshotName(conn.getConfiguration())); }
@Test public void testBackupPathIsAccessible() throws Exception { Path path = new Path(PERMISSION_TEST_PATH); FileSystem fs = FileSystem.get(TEST_UTIL.getConnection().getConfiguration()); fs.mkdirs(path); }
@Override public void mergeBackups(String[] backupIds) throws IOException { try (final BackupSystemTable sysTable = new BackupSystemTable(conn)) { checkIfValidForMerge(backupIds, sysTable); //TODO run job on remote cluster BackupMergeJob job = BackupRestoreFactory.getBackupMergeJob(conn.getConfiguration()); job.run(backupIds); } }
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)); } }
@Test(expected = IOException.class) public void testBackupPathIsNotAccessible() throws Exception { Path path = new Path(PERMISSION_TEST_PATH); FileSystem rootFs = FileSystem.get(TEST_UTIL.getConnection().getConfiguration()); rootFs.mkdirs(path.getParent()); rootFs.setPermission(path.getParent(), FsPermission.createImmutable((short) 000)); FileSystem fs = DFSTestUtil.getFileSystemAs(DIANA, TEST_UTIL.getConnection().getConfiguration()); fs.mkdirs(path); } }
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(); }
@Before public void before() throws IOException { backupManager = new BackupManager(conn, conn.getConfiguration()); }
private void addNewRegions() { try { List<HRegionLocation> locations = connection.getRegionLocator(tableName).getAllRegionLocations(); for (HRegionLocation location : locations) { if (location.getRegion().getRegionId() > timestamp) { Optional<MajorCompactionRequest> compactionRequest = MajorCompactionRequest .newRequest(connection.getConfiguration(), location.getRegion(), storesToCompact, timestamp); compactionRequest.ifPresent(request -> clusterCompactionQueues .addToCompactionQueue(location.getServerName(), request)); } } } catch (IOException e) { throw new RuntimeException(e); } }
/** * Trivial test to verify that nobody messes with * {@link ConnectionFactory#createConnection(Configuration)} */ @Test public void testCreateConnection() throws Exception { Configuration configuration = TEST_UTIL.getConfiguration(); Connection c1 = ConnectionFactory.createConnection(configuration); Connection c2 = ConnectionFactory.createConnection(configuration); // created from the same configuration, yet they are different assertTrue(c1 != c2); assertTrue(c1.getConfiguration() == c2.getConfiguration()); }
/** * Returns the number of quotas defined in the HBase quota table. */ long listNumDefinedQuotas(Connection conn) throws IOException { QuotaRetriever scanner = QuotaRetriever.open(conn.getConfiguration()); try { return Iterables.size(scanner); } finally { if (scanner != null) { scanner.close(); } } }
protected void instantiateHTable() throws IOException { mutator = connection.getBufferedMutator( new BufferedMutatorParams(getTableName(connection.getConfiguration())) .writeBufferSize(4 * 1024 * 1024)); }
private void checkSystemTable() throws IOException { try (Admin admin = connection.getAdmin()) { verifyNamespaceExists(admin); Configuration conf = connection.getConfiguration(); if (!admin.tableExists(tableName)) { TableDescriptor backupHTD = BackupSystemTable.getSystemTableDescriptor(conf); admin.createTable(backupHTD); } if (!admin.tableExists(bulkLoadTableName)) { TableDescriptor blHTD = BackupSystemTable.getSystemTableForBulkLoadedDataDescriptor(conf); admin.createTable(blHTD); } waitForSystemTable(admin, tableName); waitForSystemTable(admin, bulkLoadTableName); } }
QuotaSettings getTableSpaceQuota(Connection conn, TableName tn) throws IOException { try (QuotaRetriever scanner = QuotaRetriever.open( conn.getConfiguration(), new QuotaFilter().setTableFilter(tn.getNameAsString()))) { for (QuotaSettings setting : scanner) { if (setting.getTableName().equals(tn) && setting.getQuotaType() == QuotaType.SPACE) { return setting; } } return null; } }