/** * public because of FSHLog. Should be package-private */ public static Writer createWriter(final Configuration conf, final FileSystem fs, final Path path, final boolean overwritable) throws IOException { // Configuration already does caching for the Class lookup. Class<? extends Writer> logWriterClass = conf.getClass("hbase.regionserver.hlog.writer.impl", ProtobufLogWriter.class, Writer.class); try { Writer writer = logWriterClass.newInstance(); writer.init(fs, path, conf, overwritable); return writer; } catch (Exception e) { LOG.debug("Error instantiating log writer.", e); throw new IOException("cannot get log writer", e); } }
@Override protected Writer createWriterInstance(final Path path) throws IOException { // we get called from the FSHLog constructor (!); always roll in this case since // we don't know yet if we're supposed to generally roll and // we need an initial file in the case of doing appends but no rolls. if (!initialized || doFileRolls) { LOG.info("creating new writer instance."); final ProtobufLogWriter writer = new IOTestWriter(); writer.init(fs, path, conf, false); if (!initialized) { LOG.info("storing initial writer instance in case file rolling isn't allowed."); noRollsWriter = writer; } return writer; } else { LOG.info("WAL rolling disabled, returning the first writer."); // Initial assignment happens during the constructor call, so there ought not be // a race for first assignment. return noRollsWriter; } }
@Override protected Writer createWriterInstance(final Path path) throws IOException { // we get called from the FSHLog constructor (!); always roll in this case since // we don't know yet if we're supposed to generally roll and // we need an initial file in the case of doing appends but no rolls. if (!initialized || doFileRolls) { LOG.info("creating new writer instance."); final ProtobufLogWriter writer = new IOTestWriter(); try { writer.init(fs, path, conf, false); } catch (CommonFSUtils.StreamLacksCapabilityException exception) { throw new IOException("Can't create writer instance because underlying FileSystem " + "doesn't support needed stream capabilities.", exception); } if (!initialized) { LOG.info("storing initial writer instance in case file rolling isn't allowed."); noRollsWriter = writer; } return writer; } else { LOG.info("WAL rolling disabled, returning the first writer."); // Initial assignment happens during the constructor call, so there ought not be // a race for first assignment. return noRollsWriter; } }
/** * public because of FSHLog. Should be package-private */ public static Writer createWriter(final Configuration conf, final FileSystem fs, final Path path, final boolean overwritable) throws IOException { // Configuration already does caching for the Class lookup. Class<? extends Writer> logWriterClass = conf.getClass("hbase.regionserver.hlog.writer.impl", ProtobufLogWriter.class, Writer.class); Writer writer = null; try { writer = logWriterClass.getDeclaredConstructor().newInstance(); writer.init(fs, path, conf, overwritable); return writer; } catch (Exception e) { if (e instanceof CommonFSUtils.StreamLacksCapabilityException) { LOG.error("The RegionServer write ahead log provider for FileSystem implementations " + "relies on the ability to call " + e.getMessage() + " for proper operation during " + "component failures, but the current FileSystem does not support doing so. Please " + "check the config value of '" + CommonFSUtils.HBASE_WAL_DIR + "' and ensure " + "it points to a FileSystem mount that has suitable capabilities for output streams."); } else { LOG.debug("Error instantiating log writer.", e); } if (writer != null) { try{ writer.close(); } catch(IOException ee){ LOG.error("cannot close log writer", ee); } } throw new IOException("cannot get log writer", e); } }
@Override protected String getWriterClassName() { return ProtobufLogWriter.class.getSimpleName(); }