当前位置: 首页>>代码示例>>Java>>正文


Java U.addLog4jNoOpLogger方法代码示例

本文整理汇总了Java中org.apache.ignite.internal.util.typedef.internal.U.addLog4jNoOpLogger方法的典型用法代码示例。如果您正苦于以下问题:Java U.addLog4jNoOpLogger方法的具体用法?Java U.addLog4jNoOpLogger怎么用?Java U.addLog4jNoOpLogger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.ignite.internal.util.typedef.internal.U的用法示例。


在下文中一共展示了U.addLog4jNoOpLogger方法的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);
}
 
开发者ID:apache,项目名称:ignite,代码行数:60,代码来源:IgnitionEx.java

示例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();
        }
    });
}
 
开发者ID:apache,项目名称:ignite,代码行数:78,代码来源:GridRouterCommandLineStartup.java


注:本文中的org.apache.ignite.internal.util.typedef.internal.U.addLog4jNoOpLogger方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。