Refine search
@PluginFactory public static HiveEventCounter createInstance(@PluginAttribute("name") String name, @PluginAttribute("ignoreExceptions") boolean ignoreExceptions, @PluginElement("Layout") Layout layout, @PluginElement("Filters") Filter filter) { if (name == null) { name = APPENDER_NAME; } if (layout == null) { layout = PatternLayout.createDefaultLayout(); } return new HiveEventCounter(name, filter, layout, ignoreExceptions); }
@PluginFactory public static LlapWrappedAppender createAppender( @PluginAttribute("name") final String name, // This isn't really used for anything. @PluginAttribute("renameFileOnClose") final String renameFileOnCloseProvided, @PluginAttribute("renamedFileSuffix") final String renamedFileSuffixProvided, @PluginNode final Node node, @PluginConfiguration final Configuration config ) { if (config == null) { LOGGER.error("PluginConfiguration not expected to be null"); return null; } if (node == null) { LOGGER.error("Node must be specified as an appender specification"); return null; } boolean renameFileOnClose = DEFAULT_RENAME_FILES_ON_CLOSE; if (Strings.isNotBlank(renameFileOnCloseProvided)) { renameFileOnClose = Boolean.parseBoolean(renameFileOnCloseProvided); } String renamedFileSuffix = DEFAULT_RENAMED_FILE_SUFFIX; if (Strings.isNotBlank(renamedFileSuffixProvided)) { renamedFileSuffix = renamedFileSuffixProvided; } return new LlapWrappedAppender(name, node, config, renameFileOnClose, renamedFileSuffix); }
@PluginFactory public static GelfLogAppender createAppender(@PluginConfiguration final Configuration config, @PluginAttribute("name") String name, @PluginElement("Filter") Filter filter, @PluginElement("Field") final GelfLogField[] fields, @PluginElement("DynamicMdcFields") final GelfDynamicMdcLogFields[] dynamicFieldArray, @PluginAttribute("graylogHost") String graylogHost, @PluginAttribute("host") String host, @PluginAttribute("graylogPort") String graylogPort, @PluginAttribute("port") String port, @PluginAttribute("version") String version, @PluginAttribute("extractStackTrace") String extractStackTrace, LOGGER.error("No name provided for " + GelfLogAppender.class.getSimpleName()); return null; LOGGER.error("No host provided for " + GelfLogAppender.class.getSimpleName()); return null; PatternLayout patternLayout = newBuilder().withPattern(originHost).withConfiguration(config) .withNoConsoleNoAnsi(false).withAlwaysWriteExceptions(false).build(); mdcGelfMessageAssembler.setOriginHost(patternLayout.toSerializable(new Log4jLogEvent()));
@PluginFactory public static Script createScript( // @formatter:off @PluginAttribute("name") final String name, @PluginAttribute("language") String language, @PluginValue("scriptText") final String scriptText) { // @formatter:on if (language == null) { LOGGER.info("No script language supplied, defaulting to {}", DEFAULT_LANGUAGE); language = DEFAULT_LANGUAGE; } if (scriptText == null) { LOGGER.error("No scriptText attribute provided for ScriptFile {}", name); return null; } return new Script(name, language, scriptText); }
@PluginFactory public static GelfLogField createField(@PluginConfiguration final Configuration config, @PluginAttribute("name") String name, @PluginAttribute("literal") String literalValue, @PluginAttribute("mdc") String mdc, @PluginAttribute("pattern") String pattern) { final boolean isPattern = Strings.isNotEmpty(pattern); final boolean isLiteralValue = Strings.isNotEmpty(literalValue); final boolean isMDC = Strings.isNotEmpty(mdc); if (Strings.isEmpty(name)) { LOGGER.error("The name is empty"); return null; } if ((isPattern && isLiteralValue) || (isPattern && isMDC) || (isLiteralValue && isMDC)) { LOGGER.error("The pattern, literal, and mdc attributes are mutually exclusive."); return null; } if (isPattern) { PatternLayout patternLayout = newBuilder().withPattern(pattern).withConfiguration(config) .withNoConsoleNoAnsi(false).withAlwaysWriteExceptions(false).build(); return new GelfLogField(name, null, null, patternLayout); } return new GelfLogField(name, literalValue, mdc, null); } }
/** * Returns the appender references. * @param refs The references to return. * @return The appender references. */ @PluginFactory public static String[] createFailovers(@PluginElement("AppenderRef") final AppenderRef... refs) { if (refs == null) { LOGGER.error("failovers must contain an appender reference"); return null; } final String[] arr = new String[refs.length]; for (int i = 0; i < refs.length; ++i) { arr[i] = refs[i].getRef(); } return arr; } }
@PluginFactory public static WriterAppender createAppender(StringLayout layout, final Filter filter, final Writer target, final String name, final boolean follow, final boolean ignore) { if (name == null) { LOGGER.error("No name provided for WriterAppender"); return null; layout = PatternLayout.createDefaultLayout();
@PluginFactory public static PurgePolicy createPurgePolicy( @PluginAttribute("name") final String name) { // Name required for routing. Error out if it is not set. Preconditions.checkNotNull(name, "Name must be specified for " + LlapRoutingAppenderPurgePolicy.class.getName()); LlapRoutingAppenderPurgePolicy llapRoutingAppenderPurgePolicy = new LlapRoutingAppenderPurgePolicy(name); LlapRoutingAppenderPurgePolicy old = INSTANCES.putIfAbsent(name, llapRoutingAppenderPurgePolicy); if (old != null) { LOGGER.debug("Attempt to create multiple instances of " + LlapRoutingAppenderPurgePolicy.class.getName() + " with the name " + name + ". Using original instance"); llapRoutingAppenderPurgePolicy = old; } return llapRoutingAppenderPurgePolicy; } }
@PluginFactory public static HangingAppender createAppender( @PluginAttribute("name") @Required(message = "No name provided for HangingAppender") final String name, @PluginAttribute("delay") final long delay, @PluginAttribute("startupDelay") final long startupDelay, @PluginAttribute("shutdownDelay") final long shutdownDelay, @PluginElement("Layout") final Layout<? extends Serializable> layout, @PluginElement("Filter") final Filter filter) { return new HangingAppender(name, delay, startupDelay, shutdownDelay); }
@PluginFactory public static NameFilter createFilter( @PluginAttribute("loggingLevel") final String loggingLevel) { // Name required for routing. Error out if it is not set. Preconditions.checkNotNull(loggingLevel, "loggingLevel must be specified for " + NameFilter.class.getName()); return new NameFilter(OperationLog.getLoggingLevel(loggingLevel)); } }
/** * Return the array of scripts * @param scripts An array of Scripts. * @return The array of AbstractScripts. */ @PluginFactory public static AbstractScript[] createScripts(@PluginElement("Scripts") final AbstractScript[] scripts) { return scripts; } }
@PluginFactory public static StringAppender createStringAppender( @PluginAttribute("name") String nullablePatternString) { PatternLayout layout; if (nullablePatternString == null) { layout = PatternLayout.createDefaultLayout(); } else { layout = PatternLayout.createLayout(nullablePatternString, null, configuration, null, null, true, false, null, null); } return new StringAppender(APPENDER_NAME, layout, null, false, true, new StringOutputStreamManager(new ByteArrayOutputStream(), "StringStream", layout)); }
@PluginFactory @Deprecated public static PatternLayout createLayout( @PluginAttribute(value = "pattern", defaultString = DEFAULT_CONVERSION_PATTERN) final String pattern, @PluginElement("PatternSelector") final PatternSelector patternSelector, @PluginConfiguration final Configuration config, @PluginElement("Replace") final RegexReplacement replace, @PluginAttribute(value = "charset") final Charset charset, @PluginAttribute(value = "alwaysWriteExceptions", defaultBoolean = true) final boolean alwaysWriteExceptions, @PluginAttribute(value = "noConsoleNoAnsi") final boolean noConsoleNoAnsi, @PluginAttribute("header") final String headerPattern, @PluginAttribute("footer") final String footerPattern) { return newBuilder() .withPattern(pattern) .withPatternSelector(patternSelector)
@PluginFactory public static TestFilter createFilter() { return new TestFilter(); } }
@PluginFactory public static NullAppender createNullAppender() { return new NullAppender("NullAppender", null, PatternLayout.createDefaultLayout(), true); }
@PluginFactory public static InstrumentedAppender createAppender( @PluginAttribute("name") String name) { if (name == null) { LOGGER.error("No name provided for InstrumentedAppender"); return null; } return new InstrumentedAppender(name); }
@PluginFactory public static GelfLogAppender createAppender(@PluginConfiguration final Configuration config, @PluginAttribute("name") String name, @PluginElement("Filter") Filter filter, @PluginElement("Field") final GelfLogField[] fields, @PluginElement("DynamicMdcFields") final GelfDynamicMdcLogFields[] dynamicFieldArray, @PluginAttribute("graylogHost") String graylogHost, @PluginAttribute("host") String host, @PluginAttribute("graylogPort") String graylogPort, @PluginAttribute("port") String port, @PluginAttribute("version") String version, @PluginAttribute("extractStackTrace") String extractStackTrace, LOGGER.error("No name provided for " + GelfLogAppender.class.getSimpleName()); return null; LOGGER.error("No host provided for " + GelfLogAppender.class.getSimpleName()); return null; PatternLayout patternLayout = newBuilder().withPattern(originHost).withConfiguration(config) .withNoConsoleNoAnsi(false).withAlwaysWriteExceptions(false).build(); mdcGelfMessageAssembler.setOriginHost(patternLayout.toSerializable(new Log4jLogEvent()));
@PluginFactory public static GelfLogField createField(@PluginConfiguration final Configuration config, @PluginAttribute("name") String name, @PluginAttribute("literal") String literalValue, @PluginAttribute("mdc") String mdc, @PluginAttribute("pattern") String pattern) { final boolean isPattern = Strings.isNotEmpty(pattern); final boolean isLiteralValue = Strings.isNotEmpty(literalValue); final boolean isMDC = Strings.isNotEmpty(mdc); if (Strings.isEmpty(name)) { LOGGER.error("The name is empty"); return null; } if ((isPattern && isLiteralValue) || (isPattern && isMDC) || (isLiteralValue && isMDC)) { LOGGER.error("The pattern, literal, and mdc attributes are mutually exclusive."); return null; } if (isPattern) { PatternLayout patternLayout = newBuilder().withPattern(pattern).withConfiguration(config) .withNoConsoleNoAnsi(false).withAlwaysWriteExceptions(false).build(); return new GelfLogField(name, null, null, patternLayout); } return new GelfLogField(name, literalValue, mdc, null); } }
/** * The factory method to create the PropertiesRewritePolicy. * @param config The Configuration. * @param props key/value pairs for the new keys and values. * @return The PropertiesRewritePolicy. */ @PluginFactory public static PropertiesRewritePolicy createPolicy(@PluginConfiguration final Configuration config, @PluginElement("Properties") final Property[] props) { if (props == null || props.length == 0) { LOGGER.error("Properties must be specified for the PropertiesRewritePolicy"); return null; } final List<Property> properties = Arrays.asList(props); return new PropertiesRewritePolicy(config, properties); } }
@PluginFactory public static OutputStreamAppender createAppender(Layout<? extends Serializable> layout, final Filter filter, final OutputStream target, final String name, final boolean follow, final boolean ignore) { if (name == null) { LOGGER.error("No name provided for OutputStreamAppender"); return null; layout = PatternLayout.createDefaultLayout();