本文整理汇总了Java中org.apache.ignite.internal.util.typedef.internal.U.removeLog4jNoOpLogger方法的典型用法代码示例。如果您正苦于以下问题:Java U.removeLog4jNoOpLogger方法的具体用法?Java U.removeLog4jNoOpLogger怎么用?Java U.removeLog4jNoOpLogger使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ignite.internal.util.typedef.internal.U
的用法示例。
在下文中一共展示了U.removeLog4jNoOpLogger方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
* Starts all grids specified within given Spring XML configuration file URL. If grid with given name
* is already started, then exception is thrown. In this case all instances that may
* have been started so far will be stopped too.
* <p>
* Usually Spring XML configuration file will contain only one Grid definition. Note that
* Grid configuration bean(s) is retrieved form configuration file by type, so the name of
* the Grid configuration bean is ignored.
*
* @param springCfgUrl Spring XML configuration file URL. This cannot be {@code null}.
* @param igniteInstanceName Ignite instance name that will override default.
* @param springCtx Optional Spring application context, possibly {@code null}.
* @param ldr Optional class loader that will be used by default.
* Spring bean definitions for bean injection are taken from this context.
* If provided, this context can be injected into grid tasks and grid jobs using
* {@link SpringApplicationContextResource @SpringApplicationContextResource} annotation.
* @return Started grid. If Spring configuration contains multiple grid instances,
* then the 1st found instance is returned.
* @throws IgniteCheckedException If grid could not be started or configuration
* read. This exception will be thrown also if grid with given name has already
* been started or Spring XML configuration file is invalid.
*/
public static Ignite start(URL springCfgUrl, @Nullable String igniteInstanceName,
@Nullable GridSpringResourceContext springCtx, @Nullable ClassLoader ldr) throws IgniteCheckedException {
A.notNull(springCfgUrl, "springCfgUrl");
boolean isLog4jUsed = U.gridClassLoader().getResource("org/apache/log4j/Appender.class") != null;
IgniteBiTuple<Object, Object> t = null;
if (isLog4jUsed) {
try {
t = U.addLog4jNoOpLogger();
}
catch (IgniteCheckedException ignore) {
isLog4jUsed = false;
}
}
Collection<Handler> savedHnds = null;
if (!isLog4jUsed)
savedHnds = U.addJavaNoOpLogger();
IgniteBiTuple<Collection<IgniteConfiguration>, ? extends GridSpringResourceContext> cfgMap;
try {
cfgMap = loadConfigurations(springCfgUrl);
}
finally {
if (isLog4jUsed && t != null)
U.removeLog4jNoOpLogger(t);
if (!isLog4jUsed)
U.removeJavaNoOpLogger(savedHnds);
}
return startConfigurations(cfgMap, springCfgUrl, igniteInstanceName, springCtx, ldr);
}
示例2: main
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
* Wrapper method to run router from command-line.
*
* @param args Command-line arguments.
* @throws IgniteCheckedException If failed.
*/
public static void main(String[] args) throws IgniteCheckedException {
X.println(
" __________ ________________ ",
" / _/ ___/ |/ / _/_ __/ __/ ",
" _/ // (_ / // / / / / _/ ",
"/___/\\___/_/|_/___/ /_/ /___/ ",
" ",
"Ignite Router Command Line Loader",
"ver. " + ACK_VER_STR,
COPYRIGHT,
" "
);
IgniteSpringHelper spring = SPRING.create(false);
if (args.length < 1) {
X.error("Missing XML configuration path.");
System.exit(1);
}
String cfgPath = args[0];
URL cfgUrl = U.resolveIgniteUrl(cfgPath);
if (cfgUrl == null) {
X.error("Spring XML file not found (is IGNITE_HOME set?): " + cfgPath);
System.exit(1);
}
boolean isLog4jUsed = U.gridClassLoader().getResource("org/apache/log4j/Appender.class") != null;
IgniteBiTuple<Object, Object> t = null;
Collection<Handler> savedHnds = null;
if (isLog4jUsed) {
try {
t = U.addLog4jNoOpLogger();
}
catch (Exception ignored) {
isLog4jUsed = false;
}
}
if (!isLog4jUsed)
savedHnds = U.addJavaNoOpLogger();
Map<Class<?>, Object> beans;
try {
beans = spring.loadBeans(cfgUrl, IgniteLogger.class, GridTcpRouterConfiguration.class);
}
finally {
if (isLog4jUsed && t != null)
U.removeLog4jNoOpLogger(t);
if (!isLog4jUsed)
U.removeJavaNoOpLogger(savedHnds);
}
final GridRouterCommandLineStartup routerStartup = new GridRouterCommandLineStartup();
routerStartup.start(beans);
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override public void run() {
routerStartup.stop();
}
});
}