use of org.apache.ignite.IgniteLogger in project ignite by apache.
the class GridToStringBuilderSelfTest method testToStringWithAdditions.
/**
* @throws Exception If failed.
*/
public void testToStringWithAdditions() throws Exception {
TestClass1 obj = new TestClass1();
IgniteLogger log = log();
String manual = obj.toStringWithAdditionalManual();
log.info(manual);
String automatic = obj.toStringWithAdditionalAutomatic();
log.info(automatic);
assertEquals(manual, automatic);
}
use of org.apache.ignite.IgniteLogger in project ignite by apache.
the class GridStartupWithUndefinedIgniteHomeSelfTest method testStartStopWithUndefinedIgniteHome.
/**
* @throws Exception If failed.
*/
public void testStartStopWithUndefinedIgniteHome() throws Exception {
IgniteUtils.nullifyHomeDirectory();
// We can't use U.getIgniteHome() here because
// it will initialize cached value which is forbidden to override.
String igniteHome = IgniteSystemProperties.getString(IGNITE_HOME);
assert igniteHome != null;
U.setIgniteHome(null);
String igniteHome0 = U.getIgniteHome();
assert igniteHome0 == null;
IgniteLogger log = new JavaLogger();
log.info(">>> Test started: " + getName());
log.info("Grid start-stop test count: " + GRID_COUNT);
for (int i = 0; i < GRID_COUNT; i++) {
TcpDiscoverySpi disc = new TcpDiscoverySpi();
disc.setIpFinder(IP_FINDER);
IgniteConfiguration cfg = new IgniteConfiguration();
// Default console logger is used
cfg.setGridLogger(log);
cfg.setDiscoverySpi(disc);
cfg.setConnectorConfiguration(null);
try (Ignite ignite = G.start(cfg)) {
assert ignite != null;
igniteHome0 = U.getIgniteHome();
assert igniteHome0 == null;
X.println("Stopping grid " + ignite.cluster().localNode().id());
}
}
}
use of org.apache.ignite.IgniteLogger in project ignite by apache.
the class GridLog4jInitializedTest method testLogInitialize.
/**
*/
public void testLogInitialize() {
IgniteLogger log = new Log4JLogger();
System.out.println(log.toString());
assertTrue(log.toString().contains("Log4JLogger"));
assertTrue(log.toString().contains("config=null"));
assertTrue(log.isInfoEnabled());
if (log.isDebugEnabled())
log.debug("This is 'debug' message.");
log.info("This is 'info' message.");
log.warning("This is 'warning' message.");
log.warning("This is 'warning' message.", new Exception("It's a test warning exception"));
log.error("This is 'error' message.");
log.error("This is 'error' message.", new Exception("It's a test error exception"));
assert log.getLogger(GridLog4jInitializedTest.class.getName()) instanceof Log4JLogger;
}
use of org.apache.ignite.IgniteLogger in project ignite by apache.
the class Log4j2LoggerSelfTest method testFileConstructor.
/**
* @throws Exception If failed.
*/
public void testFileConstructor() throws Exception {
File xml = GridTestUtils.resolveIgnitePath(LOG_PATH_TEST);
assert xml != null;
assert xml.exists();
IgniteLogger log = new Log4J2Logger(xml).getLogger(getClass());
System.out.println(log.toString());
assertTrue(log.toString().contains("Log4J2Logger"));
assertTrue(log.toString().contains(xml.getPath()));
((LoggerNodeIdAware) log).setNodeId(UUID.randomUUID());
checkLog(log);
}
use of org.apache.ignite.IgniteLogger in project ignite by apache.
the class HibernateAccessStrategyFactory method start.
/**
* @param props Properties.
*/
public void start(Properties props) {
String gridCfg = props.getProperty(GRID_CONFIG_PROPERTY);
String igniteInstanceName = props.getProperty(IGNITE_INSTANCE_NAME_PROPERTY);
if (igniteInstanceName == null)
igniteInstanceName = props.getProperty(GRID_NAME_PROPERTY);
if (gridCfg != null) {
try {
ignite = G.start(gridCfg);
} catch (IgniteException e) {
throw eConverter.convert(e);
}
} else
ignite = Ignition.ignite(igniteInstanceName);
for (Map.Entry<Object, Object> prop : props.entrySet()) {
String key = prop.getKey().toString();
if (key.startsWith(REGION_CACHE_PROPERTY)) {
String regionName = key.substring(REGION_CACHE_PROPERTY.length());
String cacheName = prop.getValue().toString();
if (((IgniteKernal) ignite).getCache(cacheName) == null)
throw new IllegalArgumentException("Cache '" + cacheName + "' specified for region '" + regionName + "' " + "is not configured.");
regionCaches.put(regionName, cacheName);
}
}
String dfltCacheName = props.getProperty(DFLT_CACHE_NAME_PROPERTY);
if (dfltCacheName != null) {
IgniteInternalCache<Object, Object> dfltCache = ((IgniteKernal) ignite).getCache(dfltCacheName);
if (dfltCache == null)
throw new IllegalArgumentException("Cache specified as default is not configured: " + dfltCacheName);
this.dfltCache = new HibernateCacheProxy(dfltCache, keyTransformer);
}
IgniteLogger log = ignite.log().getLogger(getClass());
if (log.isDebugEnabled())
log.debug("HibernateRegionFactory started [igniteInstanceName=" + igniteInstanceName + ']');
}
Aggregations