@Override public HTableDescriptor newTableDescriptor(String tableName) { TableName tn = TableName.valueOf(tableName); return new HTableDescriptor(tn); }
/** * Create a Cell that is larger than all other possible Cells for the given Cell's row. * @param cell * @return Last possible Cell on passed Cell's row. */ public static Cell createLastOnRow(final Cell cell) { if (cell instanceof ByteBufferExtendedCell) { return new LastOnRowByteBufferExtendedCell(((ByteBufferExtendedCell) cell).getRowByteBuffer(), ((ByteBufferExtendedCell) cell).getRowPosition(), cell.getRowLength()); } return new LastOnRowCell(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength()); }
@Override public ExtendedCell deepClone() { Cell clonedBaseCell = ((ExtendedCell) this.cell).deepClone(); if (clonedBaseCell instanceof ByteBufferExtendedCell) { return new TagRewriteByteBufferExtendedCell((ByteBufferExtendedCell) clonedBaseCell, this.tags); } return new TagRewriteCell(clonedBaseCell, this.tags); }
private HRegion initHRegion(byte [] tableName, String callingMethod, byte[] ... families) throws IOException { HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(tableName)); for(byte [] family : families) { htd.addFamily(new HColumnDescriptor(family)); } HRegionInfo info = new HRegionInfo(htd.getTableName(), null, null, false); return HBTU.createLocalHRegion(info, htd); }
private Cell newCellWithNotExistColumnFamily(Cell cell) { return ExtendedCellBuilderFactory.create(CellBuilderType.SHALLOW_COPY) .setRow(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength()) .setFamily(CF_NOT_EXIST_BYTES, 0, CF_NOT_EXIST_BYTES.length) .setQualifier(CellUtil.cloneQualifier(cell)).setTimestamp(cell.getTimestamp()) .setType(cell.getType().getCode()).setValue(CellUtil.cloneValue(cell)).build(); }
@Override public void addColumnFamilyToTableDescriptor(HTableDescriptor tdesc, HColumnDescriptor cdesc) { tdesc.addFamily(cdesc); }
/** * @return Get the long out of the passed in Cell */ private static long getLongValue(final Cell cell) throws DoNotRetryIOException { int len = cell.getValueLength(); if (len != Bytes.SIZEOF_LONG) { // throw DoNotRetryIOException instead of IllegalArgumentException throw new DoNotRetryIOException("Field is not a long, it's " + len + " bytes wide"); } return PrivateCellUtil.getValueAsLong(cell); }
private Cell createCell(byte[] row, byte[] qualifier, long ts, long sequenceId, byte[] value) throws IOException { Cell c = CellBuilderFactory.create(CellBuilderType.DEEP_COPY).setRow(row).setFamily(family) .setQualifier(qualifier).setTimestamp(ts).setType(Cell.Type.Put) .setValue(value).build(); PrivateCellUtil.setSequenceId(c, sequenceId); return c; }
public HRegion createNewHRegion(HTableDescriptor desc, byte [] startKey, byte [] endKey, Configuration conf) throws IOException { HRegionInfo hri = new HRegionInfo(desc.getTableName(), startKey, endKey); return HBaseTestingUtility.createRegionAndWAL(hri, testDir, conf, desc); }
public static Cell createFirstOnNextRow(final Cell cell) { byte[] nextRow = new byte[cell.getRowLength() + 1]; CellUtil.copyRowTo(cell, nextRow, 0); nextRow[nextRow.length - 1] = 0;// maybe not necessary return new FirstOnRowCell(nextRow, 0, (short) nextRow.length); }
/** * Start up a minicluster of hbase, dfs and zookeeper clusters with given slave node number. * All other options will use default values, defined in {@link StartMiniClusterOption.Builder}. * @param numSlaves slave node number, for both HBase region server and HDFS data node. * @see #startMiniCluster(StartMiniClusterOption option) * @see #shutdownMiniDFSCluster() */ public MiniHBaseCluster startMiniCluster(int numSlaves) throws Exception { StartMiniClusterOption option = StartMiniClusterOption.builder() .numRegionServers(numSlaves).numDataNodes(numSlaves).build(); return startMiniCluster(option); }
private void start(String testName) { ResourceChecker rc = new ResourceChecker(testName); rc.addResourceAnalyzer(new ThreadResourceAnalyzer()); rc.addResourceAnalyzer(new OpenFileDescriptorResourceAnalyzer()); rc.addResourceAnalyzer(new MaxFileDescriptorResourceAnalyzer()); rc.addResourceAnalyzer(new SystemLoadAverageResourceAnalyzer()); rc.addResourceAnalyzer(new ProcessCountResourceAnalyzer()); rc.addResourceAnalyzer(new AvailableMemoryMBResourceAnalyzer()); addResourceAnalyzer(rc); rcs.put(testName, rc); rc.start(); }
/** * Starts up mini hbase cluster using default options. * Default options can be found in {@link StartMiniClusterOption.Builder}. * @see #startMiniHBaseCluster(StartMiniClusterOption) * @see #shutdownMiniHBaseCluster() */ public MiniHBaseCluster startMiniHBaseCluster() throws IOException, InterruptedException { return startMiniHBaseCluster(StartMiniClusterOption.builder().build()); }
protected CommandProvider getCommandProvider(ServiceType service) throws IOException { switch (service) { case HADOOP_DATANODE: case HADOOP_NAMENODE: return new HadoopShellCommandProvider(getConf()); case ZOOKEEPER_SERVER: return new ZookeeperShellCommandProvider(getConf()); default: return new HBaseShellCommandProvider(getConf()); } }
private HRegionInfo createRandomRegion(final String name) { HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(name)); String [] families = new String [] {"info", "anchor"}; for (int i = 0; i < families.length; i++) { htd.addFamily(new HColumnDescriptor(families[i])); } return new HRegionInfo(htd.getTableName(), HConstants.EMPTY_START_ROW, HConstants.EMPTY_END_ROW); }
private Cell newCellWithDifferentColumnFamily(Cell cell) { return ExtendedCellBuilderFactory.create(CellBuilderType.SHALLOW_COPY) .setRow(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength()) .setFamily(CF2_BYTES, 0, CF2_BYTES.length).setQualifier(CellUtil.cloneQualifier(cell)) .setTimestamp(cell.getTimestamp()).setType(cell.getType().getCode()) .setValue(CellUtil.cloneValue(cell)).build(); }
@Override public HTableDescriptor newTableDescriptor(String tableName) { TableName tn = TableName.valueOf(tableName); return new HTableDescriptor(tn); }
@Override public void addColumnFamilyToTableDescriptor(HTableDescriptor tdesc, HColumnDescriptor cdesc) { tdesc.addFamily(cdesc); }
private void initHRegion (byte [] tableName, String callingMethod, int [] maxVersions, byte[] ... families) throws IOException { HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(tableName)); int i=0; for(byte [] family : families) { HColumnDescriptor hcd = new HColumnDescriptor(family); hcd.setMaxVersions(maxVersions != null ? maxVersions[i++] : 1); htd.addFamily(hcd); } HRegionInfo info = new HRegionInfo(htd.getTableName(), null, null, false); region = TEST_UTIL.createLocalHRegion(info, htd); }
@Override public HTableDescriptor newTableDescriptor(String tableName) { TableName tn = TableName.valueOf(tableName); return new HTableDescriptor(tn); }