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);
}
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);
}
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);
}
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);
}
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));
}
Aggregations