Search in sources :

Example 56 with IgniteLogger

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);
}
Also used : IgniteLogger(org.apache.ignite.IgniteLogger)

Example 57 with IgniteLogger

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());
        }
    }
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) Ignite(org.apache.ignite.Ignite) IgniteLogger(org.apache.ignite.IgniteLogger) JavaLogger(org.apache.ignite.logger.java.JavaLogger) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 58 with IgniteLogger

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;
}
Also used : IgniteLogger(org.apache.ignite.IgniteLogger)

Example 59 with IgniteLogger

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);
}
Also used : IgniteLogger(org.apache.ignite.IgniteLogger) LoggerNodeIdAware(org.apache.ignite.logger.LoggerNodeIdAware) File(java.io.File)

Example 60 with IgniteLogger

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 + ']');
}
Also used : IgniteKernal(org.apache.ignite.internal.IgniteKernal) IgniteException(org.apache.ignite.IgniteException) IgniteLogger(org.apache.ignite.IgniteLogger) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

IgniteLogger (org.apache.ignite.IgniteLogger)60 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)14 Ignite (org.apache.ignite.Ignite)12 IOException (java.io.IOException)10 LoggerResource (org.apache.ignite.resources.LoggerResource)10 IgniteException (org.apache.ignite.IgniteException)8 Map (java.util.Map)6 UUID (java.util.UUID)6 ClusterNode (org.apache.ignite.cluster.ClusterNode)6 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)6 IgniteInstanceResource (org.apache.ignite.resources.IgniteInstanceResource)6 HashMap (java.util.HashMap)5 ClusterTopologyCheckedException (org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)5 IgniteBiInClosure (org.apache.ignite.lang.IgniteBiInClosure)5 File (java.io.File)4 ArrayList (java.util.ArrayList)4 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)4 URL (java.net.URL)3 Callable (java.util.concurrent.Callable)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3