org.apache.hadoop.hbase.regionserver.wal.HLog Java Examples

The following examples show how to use org.apache.hadoop.hbase.regionserver.wal.HLog. 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: TransactionProcessorTest.java    From phoenix-tephra with Apache License 2.0 6 votes vote down vote up
private HRegion createRegion(String tableName, byte[] family, long ttl) throws IOException {
  HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(tableName));
  HColumnDescriptor cfd = new HColumnDescriptor(family);
  if (ttl > 0) {
    cfd.setValue(TxConstants.PROPERTY_TTL, String.valueOf(ttl));
  }
  cfd.setMaxVersions(10);
  htd.addFamily(cfd);
  htd.addCoprocessor(TransactionProcessor.class.getName());
  Path tablePath = FSUtils.getTableDir(FSUtils.getRootDir(conf), htd.getTableName());
  Path hlogPath = new Path(FSUtils.getRootDir(conf) + "/hlog");
  FileSystem fs = FileSystem.get(conf);
  assertTrue(fs.mkdirs(tablePath));
  HLog hLog = HLogFactory.createHLog(fs, hlogPath, tableName, conf);
  HRegionInfo regionInfo = new HRegionInfo(TableName.valueOf(tableName));
  HRegionFileSystem regionFS = HRegionFileSystem.createRegionOnFileSystem(conf, fs, tablePath, regionInfo);
  return new HRegion(regionFS, hLog, conf, htd, new MockRegionServerServices(conf, null));
}
 
Example #2
Source File: TransactionProcessorTest.java    From phoenix-tephra with Apache License 2.0 6 votes vote down vote up
private HRegion createRegion(String tableName, byte[] family, long ttl) throws IOException {
  HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(tableName));
  HColumnDescriptor cfd = new HColumnDescriptor(family);
  if (ttl > 0) {
    cfd.setValue(TxConstants.PROPERTY_TTL, String.valueOf(ttl));
  }
  cfd.setMaxVersions(10);
  htd.addFamily(cfd);
  htd.addCoprocessor(TransactionProcessor.class.getName());
  Path tablePath = FSUtils.getTableDir(FSUtils.getRootDir(conf), htd.getTableName());
  Path hlogPath = new Path(FSUtils.getRootDir(conf) + "/hlog");
  FileSystem fs = FileSystem.get(conf);
  assertTrue(fs.mkdirs(tablePath));
  HLog hLog = HLogFactory.createHLog(fs, hlogPath, tableName, conf);
  HRegionInfo regionInfo = new HRegionInfo(TableName.valueOf(tableName));
  HRegionFileSystem regionFS = HRegionFileSystem.createRegionOnFileSystem(conf, fs, tablePath, regionInfo);
  return new HRegion(regionFS, hLog, conf, htd, new MockRegionServerServices(conf, null));
}
 
Example #3
Source File: IndexedRegion.java    From hbase-secondary-index with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
public IndexedRegion(final Path basedir, final HLog log, final FileSystem fs,
      final Configuration conf, final HRegionInfo regionInfo,
      final FlushRequester flushListener) throws IOException {
    super(basedir, log, fs, conf, regionInfo, flushListener);
    this.indexTableDescriptor = new IndexedTableDescriptor(
        regionInfo.getTableDesc());
    this.conf = conf;
    this.tablePool = new HTablePool();
  }
 
Example #4
Source File: THLogSplitter.java    From hbase-secondary-index with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected Reader getReader(final FileSystem fs, final Path logfile, final Configuration conf) throws IOException {
    if (isTrxLog(logfile)) {
        return THLog.getReader(fs, logfile, conf);
    }
    return HLog.getReader(fs, logfile, conf);
}
 
Example #5
Source File: THLog.java    From hbase-secondary-index with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Get a writer for the WAL.
 * 
 * @param path
 * @param conf
 * @return A WAL writer. Close when done with it.
 * @throws IOException
 */
public static Writer createWriter(final FileSystem fs, final Path path,
		final Configuration conf) throws IOException {
	try {
		HLog.Writer writer = new SequenceFileLogWriter(THLogKey.class);
		writer.init(fs, path, conf);
		return writer;
	} catch (Exception e) {
		IOException ie = new IOException("cannot get log writer");
		ie.initCause(e);
		throw ie;
	}
}
 
Example #6
Source File: THLog.java    From hbase-secondary-index with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Get a reader for the WAL.
 * 
 * @param fs
 * @param path
 * @param conf
 * @return A WAL reader. Close when done with it.
 * @throws IOException
 */
public static Reader getReader(final FileSystem fs, final Path path,
		final Configuration conf) throws IOException {
	try {
		HLog.Reader reader = new SequenceFileLogReader(THLogKey.class);
		reader.init(fs, path, conf);
		return reader;
	} catch (Exception e) {
		IOException ie = new IOException("cannot get log reader");
		ie.initCause(e);
		throw ie;
	}
}
 
Example #7
Source File: TransactionalRegionServer.java    From hbase-secondary-index with GNU General Public License v3.0 5 votes vote down vote up
private void initializeTHLog() throws IOException {
	// We keep in the same directory as the core HLog.
	Path oldLogDir = new Path(getRootDir(), HLogSplitter.RECOVERED_EDITS);
	Path logdir = new Path(getRootDir(),
			HLog.getHLogDirectoryName(super.getServerName().getServerName()));

	trxHLog = new THLog(getFileSystem(), logdir, oldLogDir, conf, null);
}
 
Example #8
Source File: TransactionProcessorTest.java    From phoenix-tephra with Apache License 2.0 4 votes vote down vote up
@Override
public HLog getWAL(HRegionInfo regionInfo) throws IOException {
  return null;
}
 
Example #9
Source File: TransactionProcessorTest.java    From phoenix-tephra with Apache License 2.0 4 votes vote down vote up
@Override
public HLog getWAL(HRegionInfo regionInfo) throws IOException {
  return null;
}
 
Example #10
Source File: IndexedKeyValue.java    From phoenix with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * This is a KeyValue that shouldn't actually be replayed, so we always mark it as an {@link HLog#METAFAMILY} so it
 * isn't replayed via the normal replay mechanism
 */
@Override
public boolean matchingFamily(final byte[] family) {
    return Bytes.equals(family, HLog.METAFAMILY);
}
 
Example #11
Source File: THLogSplitter.java    From hbase-secondary-index with GNU General Public License v3.0 4 votes vote down vote up
private synchronized Writer getCoreWriter() throws IOException {
    if (coreWriter == null) {
        coreWriter = HLog.createWriter(fs, logfile, conf);
    }
    return coreWriter;
}
 
Example #12
Source File: TransactionalRegion.java    From hbase-secondary-index with GNU General Public License v3.0 2 votes vote down vote up
/**
 * @param basedir
 * @param log
 * @param fs
 * @param conf
 * @param regionInfo
 * @param flushListener
 */
public TransactionalRegion(final Path basedir, final HLog log, final FileSystem fs, final Configuration conf,
        final HRegionInfo regionInfo, final FlushRequester flushListener) {
    oldTransactionFlushTrigger = conf.getInt(OLD_TRANSACTION_FLUSH, DEFAULT_OLD_TRANSACTION_FLUSH);
}