return new ReversedClientScanner(getConfiguration(), scan, getName(), this.connection, this.rpcCallerFactory, this.rpcControllerFactory, pool, connConfiguration.getReplicaCallTimeoutMicroSecondScan()); } else { if (async) { return new ClientAsyncPrefetchScanner(getConfiguration(), scan, getName(), this.connection, this.rpcCallerFactory, this.rpcControllerFactory, pool, connConfiguration.getReplicaCallTimeoutMicroSecondScan()); } else { return new ClientSimpleScanner(getConfiguration(), scan, getName(), this.connection, this.rpcCallerFactory, this.rpcControllerFactory, pool, connConfiguration.getReplicaCallTimeoutMicroSecondScan());
/** * Computes size of each region for table and given column families. * */ public HBaseRegionSizeCalculator(HTable table) throws IOException { this(table, new HBaseAdmin(table.getConfiguration())); }
if (!enabled(table.getConfiguration())) { logger.info("Region size calculation disabled."); return;
return new ReversedClientScanner(getConfiguration(), scan, getName(), this.connection, this.rpcCallerFactory, this.rpcControllerFactory, pool, connConfiguration.getReplicaCallTimeoutMicroSecondScan()); } else { if (async) { return new ClientAsyncPrefetchScanner(getConfiguration(), scan, getName(), this.connection, this.rpcCallerFactory, this.rpcControllerFactory, pool, connConfiguration.getReplicaCallTimeoutMicroSecondScan()); } else { return new ClientSimpleScanner(getConfiguration(), scan, getName(), this.connection, this.rpcCallerFactory, this.rpcControllerFactory, pool, connConfiguration.getReplicaCallTimeoutMicroSecondScan());
@Override public Configuration getConfiguration() { return normalHTable.getConfiguration(); }
public Configuration getConfiguration() { return table.getConfiguration(); }
/** * @param htable the {@link HTable} to scan. */ public void setHTable(HTable htable) { Configuration conf = htable.getConfiguration(); logScannerActivity = conf.getBoolean( ScannerCallable.LOG_SCANNER_ACTIVITY, false); logPerRowCount = conf.getInt(LOG_PER_ROW_COUNT, 100); this.htable = htable; }
/** * Sets the HBase table. * * @param htable The {@link HTable} to scan. */ public void setHTable(HTable htable) { Configuration conf = htable.getConfiguration(); logScannerActivity = conf.getBoolean( ScannerCallable.LOG_SCANNER_ACTIVITY, false); logPerRowCount = conf.getInt(LOG_PER_ROW_COUNT, 100); this.htable = htable; }
public Path getStagingPath(String bulkToken, byte[] family) throws IOException { try { return (Path)Methods.call(endpointClazz, null, "getStagingPath", new Class[]{Configuration.class, String.class, byte[].class}, new Object[]{table.getConfiguration(), bulkToken, family}); } catch (Exception e) { throw new IOException("Failed to getStagingPath", e); } } }
/** * Computes size of each region for table and given column families. * */ public HBaseRegionSizeCalculator(HTable table) throws IOException { this(table, new HBaseAdmin(table.getConfiguration())); }
/** * Gets all the regions and their address for this table. * <p> * This is mainly useful for the MapReduce integration. * @return A map of HRegionInfo with it's server address * @throws IOException if a remote or network exception occurs */ public NavigableMap<HRegionInfo, ServerName> getRegionLocations() throws IOException { return MetaScanner.allTableRegions(getConfiguration(), getTableName(), false); }
/** * Computes size of each region for table and given column families. * * @deprecated Use {@link #RegionSizeCalculator(RegionLocator, Admin)} instead. */ @Deprecated public RegionSizeCalculator(HTable table) throws IOException { HBaseAdmin admin = new HBaseAdmin(table.getConfiguration()); try { init(table, admin); } finally { admin.close(); } }
/** * Computes size of each region for table and given column families. * * @deprecated Use {@link #RegionSizeCalculator(RegionLocator, Admin)} instead. */ @Deprecated public RegionSizeCalculator(HTable table) throws IOException { HBaseAdmin admin = new HBaseAdmin(table.getConfiguration()); try { init(table, admin); } finally { admin.close(); } }
/** * Computes size of each region for table and given column families. * * @deprecated Use {@link #RegionSizeCalculator(RegionLocator, Admin)} instead. */ @Deprecated public RegionSizeCalculator(HTable table) throws IOException { HBaseAdmin admin = new HBaseAdmin(table.getConfiguration()); try { init(table.getRegionLocator(), admin); } finally { admin.close(); } }
/** * {@inheritDoc} */ @Override public ResultScanner getScanner(final Scan scan) throws IOException { if (scan.getCaching() <= 0) { scan.setCaching(getScannerCaching()); } return new ClientScanner(getConfiguration(), scan, getTableName(), this.connection); }
if (!enabled(table.getConfiguration())) { logger.info("Region size calculation disabled."); return;
@Override public RecordReader<ImmutableBytesWritable, Result> createRecordReader(InputSplit split, TaskAttemptContext context) throws IOException { if (getHTable() == null) { throw new IOException("Cannot create a record reader because of a" + " previous error. Please look at the previous logs lines from" + " the task's full log for more details."); } TableSplit tSplit = (TableSplit) split; ThemisTableRecordReader trr = this.themisTableRecordReader; if (trr == null) { trr = new ThemisTableRecordReader(); } Scan sc = new Scan(this.getScan()); sc.setStartRow(tSplit.getStartRow()); sc.setStopRow(tSplit.getEndRow()); trr.setScan(sc); trr.setConf(getHTable().getConfiguration()); trr.setTableName(getHTable().getTableName()); try { trr.initialize(tSplit, context); } catch (InterruptedException e) { throw new InterruptedIOException(e.getMessage()); } return trr; } }
@Override public void connect() throws IOException { super.connect(); HTableDescriptor tdesc = table.getTableDescriptor(); if (!tdesc.hasFamily(columnFamilyBytes)) { HBaseAdmin admin = new HBaseAdmin(table.getConfiguration()); admin.disableTable(table.getTableName()); try { HColumnDescriptor cdesc = new HColumnDescriptor(columnFamilyBytes); admin.addColumn(table.getTableName(), cdesc); } finally { admin.enableTable(table.getTableName()); admin.close(); } } }
@Override public void connect() throws IOException { super.connect(); HTableDescriptor tdesc = table.getTableDescriptor(); if (!tdesc.hasFamily(columnFamilyBytes)) { HBaseAdmin admin = new HBaseAdmin(table.getConfiguration()); admin.disableTable(table.getTableName()); try { HColumnDescriptor cdesc = new HColumnDescriptor(columnFamilyBytes); admin.addColumn(table.getTableName(), cdesc); } finally { admin.enableTable(table.getTableName()); admin.close(); } } }
/** * Truncates HTable while preserving the region pre-splits * @param table HTable to truncate * @return new instance of the truncated HTable * @throws IOException throws IOException in case of any HBase IO problems */ public static HTable truncateTable(HTable table) throws IOException { Configuration conf = table.getConfiguration(); byte[][] presplits = table.getRegionLocator().getStartKeys(); if (presplits.length > 0 && presplits[0].length == 0) { presplits = Arrays.copyOfRange(presplits, 1, presplits.length); } HTableDescriptor desc = table.getTableDescriptor(); table.close(); try (Connection con = ConnectionFactory.createConnection(conf)) { try (Admin admin = con.getAdmin()) { admin.disableTable(desc.getTableName()); admin.deleteTable(desc.getTableName()); admin.createTable(desc, presplits); } } return HalyardTableUtils.getTable(conf, desc.getTableName().getNameAsString(), false, 0); }