Search in sources :

Example 16 with IgniteLogger

use of org.apache.ignite.IgniteLogger in project ignite by apache.

the class IgfsSecondaryFileSystemInjectionSelfTest method testInjectPrimaryByField.

/**
     * @throws Exception If failed.
     */
@SuppressWarnings({ "UnusedDeclaration" })
public void testInjectPrimaryByField() throws Exception {
    secondary = new TestBaseSecondaryFsMock() {

        @FileSystemResource
        private IgfsImpl igfs;

        @LoggerResource
        private IgniteLogger log;

        @IgniteInstanceResource
        private Ignite ig;

        @Override
        boolean checkInjection(Ignite ignite, IgniteFileSystem primary) {
            return igfs == primary && log instanceof IgniteLogger && ig == ignite;
        }
    };
    Ignite ig = startGrid(0);
    IgniteFileSystem igfs = ig.fileSystem(IGFS_NAME);
    assert secondary.checkInjection(ig, igfs);
}
Also used : LoggerResource(org.apache.ignite.resources.LoggerResource) IgniteInstanceResource(org.apache.ignite.resources.IgniteInstanceResource) Ignite(org.apache.ignite.Ignite) IgniteFileSystem(org.apache.ignite.IgniteFileSystem) FileSystemResource(org.apache.ignite.resources.FileSystemResource) IgniteLogger(org.apache.ignite.IgniteLogger)

Example 17 with IgniteLogger

use of org.apache.ignite.IgniteLogger in project ignite by apache.

the class IgfsSecondaryFileSystemInjectionSelfTest method testInjectPrimaryByMethods.

/**
     * @throws Exception If failed.
     */
@SuppressWarnings({ "UnusedDeclaration" })
public void testInjectPrimaryByMethods() throws Exception {
    secondary = new TestBaseSecondaryFsMock() {

        /** Ignite instance. */
        private Ignite ig;

        /** IGFS instance. */
        private IgniteFileSystem igfs;

        /** Logger injected flag */
        private boolean logSet;

        /**
             * @param igfs Primary IGFS.
             */
        @FileSystemResource
        void setPrimaryIgfs(IgfsImpl igfs) {
            this.igfs = igfs;
        }

        /**
             * @param log Ignite logger.
             */
        @LoggerResource
        void setIgLogger(IgniteLogger log) {
            logSet = log instanceof IgniteLogger;
        }

        /**
             * @param ig Ignite instance.
             */
        @IgniteInstanceResource
        void setIgniteInst(Ignite ig) {
            this.ig = ig;
        }

        @Override
        boolean checkInjection(Ignite ignite, IgniteFileSystem primary) {
            return ignite == ig && primary == igfs && logSet;
        }
    };
    Ignite ig = startGrid(0);
    IgniteFileSystem igfs = ig.fileSystem(IGFS_NAME);
    assert secondary.checkInjection(ig, igfs);
}
Also used : LoggerResource(org.apache.ignite.resources.LoggerResource) IgniteInstanceResource(org.apache.ignite.resources.IgniteInstanceResource) Ignite(org.apache.ignite.Ignite) IgniteFileSystem(org.apache.ignite.IgniteFileSystem) FileSystemResource(org.apache.ignite.resources.FileSystemResource) IgniteLogger(org.apache.ignite.IgniteLogger)

Example 18 with IgniteLogger

use of org.apache.ignite.IgniteLogger in project ignite by apache.

the class GridCacheAbstractLoadTest method initLogger.

/**
     * Initializes logger.
     *
     * @param log Log file name.
     * @return Logger.
     * @throws IgniteCheckedException If file initialization failed.
     */
protected IgniteLogger initLogger(String log) throws IgniteCheckedException {
    Logger impl = Logger.getRootLogger();
    impl.removeAllAppenders();
    String fileName = U.getIgniteHome() + "/work/log/" + log;
    // Configure output that should go to System.out
    RollingFileAppender fileApp;
    String fmt = "[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n";
    try {
        fileApp = new RollingFileAppender(new PatternLayout(fmt), fileName);
        fileApp.setMaxBackupIndex(0);
        fileApp.setAppend(false);
        // fileApp.rollOver();
        fileApp.activateOptions();
    } catch (IOException e) {
        throw new IgniteCheckedException("Unable to initialize file appender.", e);
    }
    LevelRangeFilter lvlFilter = new LevelRangeFilter();
    lvlFilter.setLevelMin(Level.DEBUG);
    fileApp.addFilter(lvlFilter);
    impl.addAppender(fileApp);
    // Configure output that should go to System.out
    ConsoleAppender conApp = new ConsoleAppender(new PatternLayout(fmt), ConsoleAppender.SYSTEM_OUT);
    lvlFilter = new LevelRangeFilter();
    lvlFilter.setLevelMin(Level.DEBUG);
    lvlFilter.setLevelMax(Level.INFO);
    conApp.addFilter(lvlFilter);
    conApp.activateOptions();
    impl.addAppender(conApp);
    // Configure output that should go to System.err
    conApp = new ConsoleAppender(new PatternLayout(fmt), ConsoleAppender.SYSTEM_ERR);
    conApp.setThreshold(Level.WARN);
    conApp.activateOptions();
    impl.addAppender(conApp);
    impl.setLevel(Level.INFO);
    return new GridTestLog4jLogger(false);
}
Also used : ConsoleAppender(org.apache.log4j.ConsoleAppender) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) RollingFileAppender(org.apache.log4j.RollingFileAppender) PatternLayout(org.apache.log4j.PatternLayout) LevelRangeFilter(org.apache.log4j.varia.LevelRangeFilter) IOException(java.io.IOException) IgniteLogger(org.apache.ignite.IgniteLogger) Logger(org.apache.log4j.Logger) GridTestLog4jLogger(org.apache.ignite.testframework.junits.logger.GridTestLog4jLogger) GridTestLog4jLogger(org.apache.ignite.testframework.junits.logger.GridTestLog4jLogger)

Example 19 with IgniteLogger

use of org.apache.ignite.IgniteLogger in project ignite by apache.

the class GridSingleExecutionTest method initLogger.

/**
     * Initializes logger.
     *
     * @param log Log file name.
     * @return Logger.
     * @throws IgniteCheckedException If file initialization failed.
     */
private static IgniteLogger initLogger(String log) throws IgniteCheckedException {
    Logger impl = Logger.getRootLogger();
    impl.removeAllAppenders();
    String fileName = U.getIgniteHome() + "/work/log/" + log;
    // Configure output that should go to System.out
    RollingFileAppender fileApp;
    String fmt = "[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n";
    try {
        fileApp = new RollingFileAppender(new PatternLayout(fmt), fileName);
        fileApp.setMaxBackupIndex(0);
        fileApp.rollOver();
    } catch (IOException e) {
        throw new IgniteCheckedException("Unable to initialize file appender.", e);
    }
    LevelRangeFilter lvlFilter = new LevelRangeFilter();
    lvlFilter.setLevelMin(Level.DEBUG);
    fileApp.addFilter(lvlFilter);
    impl.addAppender(fileApp);
    // Configure output that should go to System.out
    ConsoleAppender conApp = new ConsoleAppender(new PatternLayout(fmt), ConsoleAppender.SYSTEM_OUT);
    lvlFilter = new LevelRangeFilter();
    lvlFilter.setLevelMin(Level.INFO);
    lvlFilter.setLevelMax(Level.INFO);
    conApp.addFilter(lvlFilter);
    impl.addAppender(conApp);
    // Configure output that should go to System.err
    conApp = new ConsoleAppender(new PatternLayout(fmt), ConsoleAppender.SYSTEM_ERR);
    conApp.setThreshold(Level.WARN);
    impl.addAppender(conApp);
    impl.setLevel(Level.INFO);
    Logger.getLogger("org.apache.ignite").setLevel(Level.DEBUG);
    return new GridTestLog4jLogger(false);
}
Also used : ConsoleAppender(org.apache.log4j.ConsoleAppender) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) RollingFileAppender(org.apache.log4j.RollingFileAppender) PatternLayout(org.apache.log4j.PatternLayout) LevelRangeFilter(org.apache.log4j.varia.LevelRangeFilter) IOException(java.io.IOException) IgniteLogger(org.apache.ignite.IgniteLogger) Logger(org.apache.log4j.Logger) GridTestLog4jLogger(org.apache.ignite.testframework.junits.logger.GridTestLog4jLogger) GridTestLog4jLogger(org.apache.ignite.testframework.junits.logger.GridTestLog4jLogger)

Example 20 with IgniteLogger

use of org.apache.ignite.IgniteLogger in project ignite by apache.

the class MarshallerContextLockingSelfTest method beforeTest.

/** {@inheritDoc} */
@Override
protected void beforeTest() throws Exception {
    innerLog = new InnerLogger();
    IgniteConfiguration iCfg = new IgniteConfiguration();
    iCfg.setClientMode(false);
    ctx = new GridTestKernalContext(innerLog, iCfg) {

        @Override
        public IgniteLogger log(Class<?> cls) {
            return innerLog;
        }
    };
    ctx.setSystemExecutorService(Executors.newFixedThreadPool(THREADS));
    ctx.add(new PoolProcessor(ctx));
    ctx.add(new GridClosureProcessor(ctx));
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) GridClosureProcessor(org.apache.ignite.internal.processors.closure.GridClosureProcessor) GridTestKernalContext(org.apache.ignite.testframework.junits.GridTestKernalContext) PoolProcessor(org.apache.ignite.internal.processors.pool.PoolProcessor) IgniteLogger(org.apache.ignite.IgniteLogger)

Aggregations

IgniteLogger (org.apache.ignite.IgniteLogger)49 Ignite (org.apache.ignite.Ignite)11 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)11 IOException (java.io.IOException)9 LoggerResource (org.apache.ignite.resources.LoggerResource)9 Map (java.util.Map)6 IgniteInstanceResource (org.apache.ignite.resources.IgniteInstanceResource)6 HashMap (java.util.HashMap)5 UUID (java.util.UUID)5 IgniteException (org.apache.ignite.IgniteException)5 ClusterNode (org.apache.ignite.cluster.ClusterNode)5 File (java.io.File)4 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)4 Callable (java.util.concurrent.Callable)3 GridLoggerProxy (org.apache.ignite.internal.GridLoggerProxy)3 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)3 IgniteKernal (org.apache.ignite.internal.IgniteKernal)3 Nullable (org.jetbrains.annotations.Nullable)3 InvalidObjectException (java.io.InvalidObjectException)2 ArrayList (java.util.ArrayList)2