@Test public void testSplit() throws IOException { final byte [] tableName = Bytes.toBytes(getName()); final byte [] rowName = tableName; Path logdir = new Path(hbaseDir, HConstants.HREGION_LOGDIR_NAME); HLog log = new HLog(fs, logdir, oldLogDir, conf); final int howmany = 3; HRegionInfo[] infos = new HRegionInfo[3]; Path tabledir = new Path(hbaseDir, getName()); fs.mkdirs(tabledir); for(int i = 0; i < howmany; i++) { infos[i] = new HRegionInfo(new HTableDescriptor(tableName), Bytes.toBytes("" + i), Bytes.toBytes("" + (i+1)), false); fs.mkdirs(new Path(tabledir, infos[i].getEncodedName())); LOG.info("allo " + new Path(tabledir, infos[i].getEncodedName()).toString()); } try { for (int ii = 0; ii < howmany; ii++) { for (int i = 0; i < howmany; i++) { for (int j = 0; j < howmany; j++) { WALEdit edit = new WALEdit(); byte [] family = Bytes.toBytes("column"); byte [] qualifier = Bytes.toBytes(Integer.toString(j)); byte [] column = Bytes.toBytes("column:" + Integer.toString(j)); edit.add(new KeyValue(rowName, family, qualifier, System.currentTimeMillis(), column)); LOG.info("Region " + i + ": " + edit); log.append(infos[i], tableName, edit, System.currentTimeMillis()); } } log.rollWriter(); } log.close(); HLogSplitter logSplitter = HLogSplitter.createLogSplitter(conf, hbaseDir, logdir, this.oldLogDir, this.fs); List<Path> splits = logSplitter.splitLog(); verifySplits(splits, howmany); log = null; } finally { if (log != null) { log.closeAndDelete(); } } }
private static void split(final Configuration conf, final Path p) throws IOException { FileSystem fs = FileSystem.get(conf); if (!fs.exists(p)) { throw new FileNotFoundException(p.toString()); } final Path baseDir = new Path(conf.get(HConstants.HBASE_DIR)); final Path oldLogDir = new Path(baseDir, HConstants.HREGION_OLDLOGDIR_NAME); if (!fs.getFileStatus(p).isDir()) { throw new IOException(p + " is not a directory"); } HLogSplitter logSplitter = HLogSplitter.createLogSplitter( conf, baseDir, p, oldLogDir, fs); logSplitter.splitLog(); }
HLog implements Syncable { private static void split(final Configuration conf, final Path p) throws IOException { FileSystem fs = FileSystem.get(conf); if (!fs.exists(p)) { throw new FileNotFoundException(p.toString()); } final Path baseDir = new Path(conf.get(HConstants.HBASE_DIR)); final Path oldLogDir = new Path(baseDir, HConstants.HREGION_OLDLOGDIR_NAME); if (!fs.getFileStatus(p).isDir()) { throw new IOException(p + " is not a directory"); } HLogSplitter logSplitter = HLogSplitter.createLogSplitter( conf, baseDir, p, oldLogDir, fs); logSplitter.splitLog(); } }
HLog implements Syncable { private static void split(final Configuration conf, final Path p) throws IOException { FileSystem fs = FileSystem.get(conf); if (!fs.exists(p)) { throw new FileNotFoundException(p.toString()); } final Path baseDir = new Path(conf.get(HConstants.HBASE_DIR)); final Path oldLogDir = new Path(baseDir, HConstants.HREGION_OLDLOGDIR_NAME); if (!fs.getFileStatus(p).isDir()) { throw new IOException(p + " is not a directory"); } HLogSplitter logSplitter = HLogSplitter.createLogSplitter( conf, baseDir, p, oldLogDir, fs); logSplitter.splitLog(); } HLog(final FileSystem fs, final Path dir, final Path oldLogDir,
              final Configuration conf);  HLog(final FileSystem fs, final Path dir, final Path oldLogDir,
      final Configuration conf, final List<WALObserver> listeners,
      final String prefix);  HLog(final FileSystem fs, final Path dir, final Path oldLogDir,
      final Configuration conf, final List<WALObserver> listeners,
      final boolean failIfLogDirExists, final String prefix); }
HLog implements Syncable { private static void split(final Configuration conf, final Path p) throws IOException { FileSystem fs = FileSystem.get(conf); if (!fs.exists(p)) { throw new FileNotFoundException(p.toString()); } final Path baseDir = new Path(conf.get(HConstants.HBASE_DIR)); final Path oldLogDir = new Path(baseDir, HConstants.HREGION_OLDLOGDIR_NAME); if (!fs.getFileStatus(p).isDir()) { throw new IOException(p + " is not a directory"); } HLogSplitter logSplitter = HLogSplitter.createLogSplitter( conf, baseDir, p, oldLogDir, fs); logSplitter.splitLog(); } HLog(final FileSystem fs, final Path dir, final Path oldLogDir,
              final Configuration conf);  HLog(final FileSystem fs, final Path dir, final Path oldLogDir,
      final Configuration conf, final List<WALObserver> listeners,
      final String prefix);  HLog(final FileSystem fs, final Path dir, final Path oldLogDir,
      final Configuration conf, final List<WALObserver> listeners,
      final boolean failIfLogDirExists, final String prefix); static long getWriteOps(); static long getWriteTime(); static long getSyncOps(); static long getSyncTime(); void registerWALActionsListener(final WALObserver listener); boolean unregisterWALActionsListener(final WALObserver listener); long getFilenum(); void setSequenceNumber(final long newvalue); long getSequenceNumber(); byte [][] rollWriter(); static Reader getReader(final FileSystem fs,
    final Path path, Configuration conf); static Writer createWriter(final FileSystem fs,
      final Path path, Configuration conf); void closeAndDelete(); void close(); void append(HRegionInfo regionInfo, WALEdit logEdit,
    final long now,
    final boolean isMetaRegion); void append(HRegionInfo regionInfo, HLogKey logKey, WALEdit logEdit); void append(HRegionInfo info, byte [] tableName, WALEdit edits,
    final long now); void sync(); void hsync(); long startCacheFlush(); void completeCacheFlush(final byte [] encodedRegionName,
      final byte [] tableName, final long logSeqId, final boolean isMetaRegion); void abortCacheFlush(); static boolean isMetaFamily(byte [] family); @SuppressWarnings("unchecked") static Class<? extends HLogKey> getKeyClass(Configuration conf); static HLogKey newKey(Configuration conf); static String getHLogDirectoryName(HServerInfo info); static String getHLogDirectoryName(String serverAddress,
      long startCode); static String getHLogDirectoryName(String serverName); static boolean validateHLogFilename(String filename); static NavigableSet<Path> getSplitEditFilesSorted(final FileSystem fs,
      final Path regiondir); static Path moveAsideBadEditsFile(final FileSystem fs,
      final Path edits); static Path getRegionDirRecoveredEditsDir(final Path regiondir); static void main(String[] args); }
HLog implements Syncable { private static void split(final Configuration conf, final Path p) throws IOException { FileSystem fs = FileSystem.get(conf); if (!fs.exists(p)) { throw new FileNotFoundException(p.toString()); } final Path baseDir = new Path(conf.get(HConstants.HBASE_DIR)); final Path oldLogDir = new Path(baseDir, HConstants.HREGION_OLDLOGDIR_NAME); if (!fs.getFileStatus(p).isDir()) { throw new IOException(p + " is not a directory"); } HLogSplitter logSplitter = HLogSplitter.createLogSplitter( conf, baseDir, p, oldLogDir, fs); logSplitter.splitLog(); } HLog(final FileSystem fs, final Path dir, final Path oldLogDir,
              final Configuration conf);  HLog(final FileSystem fs, final Path dir, final Path oldLogDir,
      final Configuration conf, final List<WALObserver> listeners,
      final String prefix);  HLog(final FileSystem fs, final Path dir, final Path oldLogDir,
      final Configuration conf, final List<WALObserver> listeners,
      final boolean failIfLogDirExists, final String prefix); static long getWriteOps(); static long getWriteTime(); static long getSyncOps(); static long getSyncTime(); void registerWALActionsListener(final WALObserver listener); boolean unregisterWALActionsListener(final WALObserver listener); long getFilenum(); void setSequenceNumber(final long newvalue); long getSequenceNumber(); byte [][] rollWriter(); static Reader getReader(final FileSystem fs,
    final Path path, Configuration conf); static Writer createWriter(final FileSystem fs,
      final Path path, Configuration conf); void closeAndDelete(); void close(); void append(HRegionInfo regionInfo, WALEdit logEdit,
    final long now,
    final boolean isMetaRegion); void append(HRegionInfo regionInfo, HLogKey logKey, WALEdit logEdit); void append(HRegionInfo info, byte [] tableName, WALEdit edits,
    final long now); void sync(); void hsync(); long startCacheFlush(); void completeCacheFlush(final byte [] encodedRegionName,
      final byte [] tableName, final long logSeqId, final boolean isMetaRegion); void abortCacheFlush(); static boolean isMetaFamily(byte [] family); @SuppressWarnings("unchecked") static Class<? extends HLogKey> getKeyClass(Configuration conf); static HLogKey newKey(Configuration conf); static String getHLogDirectoryName(HServerInfo info); static String getHLogDirectoryName(String serverAddress,
      long startCode); static String getHLogDirectoryName(String serverName); static boolean validateHLogFilename(String filename); static NavigableSet<Path> getSplitEditFilesSorted(final FileSystem fs,
      final Path regiondir); static Path moveAsideBadEditsFile(final FileSystem fs,
      final Path edits); static Path getRegionDirRecoveredEditsDir(final Path regiondir); static void main(String[] args); static final byte [] METAFAMILY; static final long FIXED_OVERHEAD; }