Search in sources :

Example 51 with IgniteLogger

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

the class GridJobSiblingImpl method cancel.

/**
 * {@inheritDoc}
 */
@Override
public void cancel() {
    GridTaskSessionImpl ses = ctx.session().getSession(sesId);
    Collection<ClusterNode> nodes = ses == null ? ctx.discovery().remoteNodes() : ctx.discovery().nodes(ses.getTopology());
    for (ClusterNode node : nodes) {
        if (!ctx.localNodeId().equals(node.id())) {
            try {
                ctx.io().sendToGridTopic(node, TOPIC_JOB_CANCEL, new GridJobCancelRequest(sesId, jobId), SYSTEM_POOL);
            } catch (ClusterTopologyCheckedException e) {
                IgniteLogger log = ctx.log(GridJobSiblingImpl.class);
                if (log.isDebugEnabled())
                    log.debug("Failed to send cancel request, node left [nodeId=" + node.id() + ", ses=" + ses + ']');
            } catch (IgniteCheckedException e) {
                // Avoid stack trace for left nodes.
                if (ctx.discovery().node(node.id()) != null && ctx.discovery().pingNodeNoError(node.id()))
                    U.error(ctx.log(GridJobSiblingImpl.class), "Failed to send cancel request to node " + "[nodeId=" + node.id() + ", ses=" + ses + ']', e);
            }
        }
    }
    // Cancel local jobs directly.
    ctx.job().cancelJob(sesId, jobId, false);
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteLogger(org.apache.ignite.IgniteLogger) ClusterTopologyCheckedException(org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)

Example 52 with IgniteLogger

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

the class GridLoggerProxy method readResolve.

/**
 * Reconstructs object on unmarshalling.
 *
 * @return Reconstructed object.
 * @throws ObjectStreamException Thrown in case of unmarshalling error.
 */
protected Object readResolve() throws ObjectStreamException {
    try {
        IgniteBiTuple<String, Object> t = stash.get();
        Object ctgrR = t.get2();
        IgniteLogger log = IgnitionEx.localIgnite().log();
        return ctgrR != null ? log.getLogger(ctgrR) : log;
    } catch (IllegalStateException e) {
        throw U.withCause(new InvalidObjectException(e.getMessage()), e);
    } finally {
        stash.remove();
    }
}
Also used : InvalidObjectException(java.io.InvalidObjectException) IgniteLogger(org.apache.ignite.IgniteLogger)

Example 53 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 cls Class to get logger for.
 * @return Logger for the object.
 */
public static IgniteLogger logger(GridKernalContext ctx, AtomicReference<IgniteLogger> logRef, Class<?> cls) {
    IgniteLogger log = logRef.get();
    if (log == null) {
        logRef.compareAndSet(null, ctx.log(cls));
        log = logRef.get();
    }
    return log;
}
Also used : IgniteLogger(org.apache.ignite.IgniteLogger)

Example 54 with IgniteLogger

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

the class IgniteNodeStartUtils method processDefaults.

/**
 * Converts properties map to default specification.
 *
 * @param dflts Properties.
 * @return Specification.
 * @throws IgniteCheckedException If properties are invalid.
 */
private static IgniteRemoteStartSpecification processDefaults(@Nullable Map<String, Object> dflts) throws IgniteCheckedException {
    int port = DFLT_PORT;
    String uname = System.getProperty("user.name");
    String passwd = null;
    File key = null;
    int nodes = DFLT_NODES;
    String igniteHome = null;
    String cfg = DFLT_CFG;
    String script = null;
    IgniteLogger log = null;
    if (dflts != null) {
        if (dflts.get(PORT) != null)
            port = (Integer) dflts.get(PORT);
        if (dflts.get(UNAME) != null)
            uname = (String) dflts.get(UNAME);
        if (dflts.get(PASSWD) != null)
            passwd = (String) dflts.get(PASSWD);
        if (dflts.get(KEY) != null)
            key = (File) dflts.get(KEY);
        if (dflts.get(NODES) != null)
            nodes = (Integer) dflts.get(NODES);
        if (dflts.get(IGNITE_HOME) != null)
            igniteHome = (String) dflts.get(IGNITE_HOME);
        if (dflts.get(CFG) != null)
            cfg = (String) dflts.get(CFG);
        if (dflts.get(SCRIPT) != null)
            script = (String) dflts.get(SCRIPT);
        if (dflts.get(LOGGER) != null)
            log = (IgniteLogger) dflts.get(LOGGER);
    }
    if (port <= 0)
        throw new IgniteCheckedException("Invalid port number: " + port);
    if (nodes <= 0)
        throw new IgniteCheckedException("Invalid number of nodes: " + nodes);
    return new IgniteRemoteStartSpecification(null, port, uname, passwd, key, nodes, igniteHome, cfg, script, log);
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteLogger(org.apache.ignite.IgniteLogger) File(java.io.File)

Example 55 with IgniteLogger

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

the class GridToStringBuilderSelfTest method testToString.

/**
 * @throws Exception If failed.
 */
public void testToString() throws Exception {
    TestClass1 obj = new TestClass1();
    IgniteLogger log = log();
    log.info(obj.toStringManual());
    log.info(obj.toStringAutomatic());
    assertEquals(obj.toStringManual(), obj.toStringAutomatic());
}
Also used : IgniteLogger(org.apache.ignite.IgniteLogger)

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