Search in sources :

Example 1 with IgniteLogger

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

the class GridDiagnostic method runBackgroundCheck.

/**
     * @param igniteInstanceName Grid instance name. Can be {@code null}.
     * @param exec Executor service.
     * @param parentLog Parent logger.
     */
static void runBackgroundCheck(String igniteInstanceName, Executor exec, IgniteLogger parentLog) {
    assert exec != null;
    assert parentLog != null;
    final IgniteLogger log = parentLog.getLogger(GridDiagnostic.class);
    try {
        exec.execute(new GridWorker(igniteInstanceName, "grid-diagnostic-1", log) {

            @Override
            public void body() {
                try {
                    InetAddress locHost = U.getLocalHost();
                    if (!locHost.isReachable(REACH_TIMEOUT)) {
                        U.warn(log, "Default local host is unreachable. This may lead to delays on " + "grid network operations. Check your OS network setting to correct it.", "Default local host is unreachable.");
                    }
                } catch (IOException ignore) {
                    U.warn(log, "Failed to perform network diagnostics. It is usually caused by serious " + "network configuration problem. Check your OS network setting to correct it.", "Failed to perform network diagnostics.");
                }
            }
        });
        exec.execute(new GridWorker(igniteInstanceName, "grid-diagnostic-2", log) {

            @Override
            public void body() {
                try {
                    InetAddress locHost = U.getLocalHost();
                    if (locHost.isLoopbackAddress()) {
                        U.warn(log, "Default local host is a loopback address. This can be a sign of " + "potential network configuration problem.", "Default local host is a loopback address.");
                    }
                } catch (IOException ignore) {
                    U.warn(log, "Failed to perform network diagnostics. It is usually caused by serious " + "network configuration problem. Check your OS network setting to correct it.", "Failed to perform network diagnostics.");
                }
            }
        });
        exec.execute(new GridWorker(igniteInstanceName, "grid-diagnostic-4", log) {

            @Override
            public void body() {
                // Sufficiently tested OS.
                if (!U.isSufficientlyTestedOs()) {
                    U.warn(log, "This operating system has been tested less rigorously: " + U.osString() + ". Our team will appreciate the feedback if you experience any problems running " + "ignite in this environment.", "This OS is tested less rigorously: " + U.osString());
                }
            }
        });
        exec.execute(new GridWorker(igniteInstanceName, "grid-diagnostic-5", log) {

            @Override
            public void body() {
                // Fix for GG-1075.
                if (F.isEmpty(U.allLocalMACs()))
                    U.warn(log, "No live network interfaces detected. If IP-multicast discovery is used - " + "make sure to add 127.0.0.1 as a local address.", "No live network interfaces. Add 127.0.0.1 as a local address.");
            }
        });
        exec.execute(new GridWorker(igniteInstanceName, "grid-diagnostic-6", log) {

            @Override
            public void body() {
                if (System.getProperty("com.sun.management.jmxremote") != null) {
                    String portStr = System.getProperty("com.sun.management.jmxremote.port");
                    if (portStr != null)
                        try {
                            Integer.parseInt(portStr);
                            return;
                        } catch (NumberFormatException ignore) {
                        // No-op.
                        }
                    U.warn(log, "JMX remote management is enabled but JMX port is either not set or invalid. " + "Check system property 'com.sun.management.jmxremote.port' to make sure it specifies " + "valid TCP/IP port.", "JMX remote port is invalid - JMX management is off.");
                }
            }
        });
        final long HALF_GB = 512 * /*MB*/
        1024 * 1024;
        exec.execute(new GridWorker(igniteInstanceName, "grid-diagnostic-7", log) {

            @Override
            public void body() {
                long initBytes = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getInit();
                long initMb = initBytes / 1024 / 1024;
                if (initBytes < HALF_GB)
                    U.quietAndWarn(log, String.format("Initial heap size is %dMB (should be no less than 512MB, " + "use -Xms512m -Xmx512m).", initMb));
            }
        });
    } catch (RejectedExecutionException e) {
        U.error(log, "Failed to start background network diagnostics check due to thread pool execution " + "rejection. In most cases it indicates a severe configuration problem with Ignite.", "Failed to start background network diagnostics.", e);
    }
}
Also used : IOException(java.io.IOException) IgniteLogger(org.apache.ignite.IgniteLogger) GridWorker(org.apache.ignite.internal.util.worker.GridWorker) InetAddress(java.net.InetAddress) RejectedExecutionException(java.util.concurrent.RejectedExecutionException)

Example 2 with IgniteLogger

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

the class GridCacheIoManager method addHandler.

/**
     * Adds message handler.
     *
     * @param cacheId Cache ID.
     * @param type Type of message.
     * @param c Handler.
     */
@SuppressWarnings({ "unchecked" })
public void addHandler(int cacheId, Class<? extends GridCacheMessage> type, IgniteBiInClosure<UUID, ? extends GridCacheMessage> c) {
    int msgIdx = messageIndex(type);
    if (msgIdx != -1) {
        Map<Integer, IgniteBiInClosure[]> idxClsHandlers0 = idxClsHandlers;
        IgniteBiInClosure[] cacheClsHandlers = idxClsHandlers0.get(cacheId);
        if (cacheClsHandlers == null) {
            cacheClsHandlers = new IgniteBiInClosure[GridCacheMessage.MAX_CACHE_MSG_LOOKUP_INDEX];
            idxClsHandlers0.put(cacheId, cacheClsHandlers);
        }
        if (cacheClsHandlers[msgIdx] != null)
            throw new IgniteException("Duplicate cache message ID found [cacheId=" + cacheId + ", type=" + type + ']');
        cacheClsHandlers[msgIdx] = c;
        idxClsHandlers = idxClsHandlers0;
        return;
    } else {
        ListenerKey key = new ListenerKey(cacheId, type);
        if (clsHandlers.putIfAbsent(key, (IgniteBiInClosure<UUID, GridCacheMessage>) c) != null)
            assert false : "Handler for class already registered [cacheId=" + cacheId + ", cls=" + type + ", old=" + clsHandlers.get(key) + ", new=" + c + ']';
    }
    IgniteLogger log0 = log;
    if (log0 != null && log0.isTraceEnabled())
        log0.trace("Registered cache communication handler [cacheId=" + cacheId + ", type=" + type + ", msgIdx=" + msgIdx + ", handler=" + c + ']');
}
Also used : IgniteException(org.apache.ignite.IgniteException) IgniteBiInClosure(org.apache.ignite.lang.IgniteBiInClosure) IgniteLogger(org.apache.ignite.IgniteLogger)

Example 3 with IgniteLogger

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

the class CacheContinuousQueryHandler method notifyCallback0.

/**
     * @param nodeId Node id.
     * @param ctx Kernal context.
     * @param entries Entries.
     */
private void notifyCallback0(UUID nodeId, final GridKernalContext ctx, Collection<CacheContinuousQueryEntry> entries) {
    final GridCacheContext cctx = cacheContext(ctx);
    if (cctx == null) {
        IgniteLogger log = ctx.log(CU.CONTINUOUS_QRY_LOG_CATEGORY);
        if (log.isDebugEnabled())
            log.debug("Failed to notify callback, cache is not found: " + cacheId);
        return;
    }
    final Collection<CacheEntryEvent<? extends K, ? extends V>> entries0 = new ArrayList<>(entries.size());
    for (CacheContinuousQueryEntry e : entries) {
        GridCacheDeploymentManager depMgr = cctx.deploy();
        ClassLoader ldr = depMgr.globalLoader();
        if (ctx.config().isPeerClassLoadingEnabled()) {
            GridDeploymentInfo depInfo = e.deployInfo();
            if (depInfo != null) {
                depMgr.p2pContext(nodeId, depInfo.classLoaderId(), depInfo.userVersion(), depInfo.deployMode(), depInfo.participants(), depInfo.localDeploymentOwner());
            }
        }
        try {
            e.unmarshal(cctx, ldr);
            Collection<CacheEntryEvent<? extends K, ? extends V>> evts = handleEvent(ctx, e);
            if (evts != null && !evts.isEmpty())
                entries0.addAll(evts);
        } catch (IgniteCheckedException ex) {
            if (ignoreClsNotFound)
                assert internal;
            else
                U.error(ctx.log(CU.CONTINUOUS_QRY_LOG_CATEGORY), "Failed to unmarshal entry.", ex);
        }
    }
    if (!entries0.isEmpty())
        locLsnr.onUpdated(entries0);
}
Also used : GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) GridCacheDeploymentManager(org.apache.ignite.internal.processors.cache.GridCacheDeploymentManager) ArrayList(java.util.ArrayList) GridDeploymentInfo(org.apache.ignite.internal.managers.deployment.GridDeploymentInfo) IgniteLogger(org.apache.ignite.IgniteLogger) CacheEntryEvent(javax.cache.event.CacheEntryEvent)

Example 4 with IgniteLogger

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

the class PlatformProcessorImpl method loggerLog.

/** {@inheritDoc} */
@Override
public void loggerLog(int level, String message, String category, String errorInfo) {
    IgniteLogger log = ctx.grid().log();
    if (category != null)
        log = log.getLogger(category);
    Throwable err = errorInfo == null ? null : new IgniteException("Platform error:" + errorInfo);
    switch(level) {
        case PlatformLogger.LVL_TRACE:
            log.trace(message);
            break;
        case PlatformLogger.LVL_DEBUG:
            log.debug(message);
            break;
        case PlatformLogger.LVL_INFO:
            log.info(message);
            break;
        case PlatformLogger.LVL_WARN:
            log.warning(message, err);
            break;
        case PlatformLogger.LVL_ERROR:
            log.error(message, err);
            break;
        default:
            assert false;
    }
}
Also used : IgniteException(org.apache.ignite.IgniteException) IgniteLogger(org.apache.ignite.IgniteLogger)

Example 5 with IgniteLogger

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

the class IgniteUtils method logger.

/**
     * Initializes logger into/from log reference passed in.
     *
     * @param ctx Context.
     * @param logRef Log reference.
     * @param obj Object to get logger for.
     * @return Logger for the object.
     */
public static IgniteLogger logger(GridKernalContext ctx, AtomicReference<IgniteLogger> logRef, Object obj) {
    IgniteLogger log = logRef.get();
    if (log == null) {
        logRef.compareAndSet(null, ctx.log(obj.getClass()));
        log = logRef.get();
    }
    return log;
}
Also used : 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