Search in sources :

Example 46 with IgniteLogger

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

the class GridResourceLoggerInjector method resource.

/**
     * @param ann Annotation.
     * @param target Target.
     * @return Logger.
     */
@SuppressWarnings("IfMayBeConditional")
private IgniteLogger resource(LoggerResource ann, Object target) {
    Class<?> cls = ann.categoryClass();
    String cat = ann.categoryName();
    IgniteLogger rsrc = getResource();
    if (cls != null && cls != Void.class)
        rsrc = rsrc.getLogger(cls);
    else if (cat != null && !cat.isEmpty())
        rsrc = rsrc.getLogger(cat);
    else
        rsrc = rsrc.getLogger(target.getClass());
    return rsrc;
}
Also used : IgniteLogger(org.apache.ignite.IgniteLogger)

Example 47 with IgniteLogger

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

the class GridLoggerInjectionSelfTest method testClosureField.

/**
     * Test that closure gets right log category injected on all nodes using field injection.
     *
     * @throws Exception If failed.
     */
public void testClosureField() throws Exception {
    Ignite ignite = grid(0);
    ignite.compute().call(new IgniteCallable<Object>() {

        @LoggerResource(categoryClass = GridLoggerInjectionSelfTest.class)
        private IgniteLogger log;

        @Override
        public Object call() throws Exception {
            if (log instanceof GridLoggerProxy) {
                Object category = U.field(log, "ctgr");
                assertTrue("Logger created for the wrong category.", category.toString().contains(GridLoggerInjectionSelfTest.class.getName()));
            } else
                fail("This test should be run with proxy logger.");
            return null;
        }
    });
}
Also used : LoggerResource(org.apache.ignite.resources.LoggerResource) GridLoggerProxy(org.apache.ignite.internal.GridLoggerProxy) Ignite(org.apache.ignite.Ignite) IgniteLogger(org.apache.ignite.IgniteLogger) IOException(java.io.IOException)

Example 48 with IgniteLogger

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

the class IgnitePutAllBenchmark method test.

/** {@inheritDoc} */
@Override
public boolean test(Map<Object, Object> ctx) throws Exception {
    List<Map<Integer, Integer>> putMaps = (List<Map<Integer, Integer>>) ctx.get(PUT_MAPS_KEY);
    if (putMaps == null) {
        putMaps = new ArrayList<>(PUT_MAPS_CNT);
        ctx.put(PUT_MAPS_KEY, putMaps);
    }
    Map<Integer, Integer> vals;
    if (putMaps.size() == PUT_MAPS_CNT)
        vals = putMaps.get(nextRandom(PUT_MAPS_CNT));
    else {
        vals = new TreeMap<>();
        ClusterNode node = args.collocated() ? aff.mapKeyToNode(nextRandom(args.range())) : null;
        Map<ClusterNode, Integer> stripesMap = null;
        if (args.singleStripe())
            stripesMap = U.newHashMap(srvrCnt);
        for (; vals.size() < args.batch(); ) {
            int key = nextRandom(args.range());
            if (args.collocated() && !aff.isPrimary(node, key))
                continue;
            if (args.singleStripe()) {
                int part = aff.partition(key);
                ClusterNode node0 = node != null ? node : aff.mapPartitionToNode(part);
                Integer stripe0 = stripesMap.get(node0);
                int stripe = part % stripesCnt;
                if (stripe0 != null) {
                    if (stripe0 != stripe)
                        continue;
                } else
                    stripesMap.put(node0, stripe);
            }
            vals.put(key, key);
        }
        putMaps.add(vals);
        if (putMaps.size() == PUT_MAPS_CNT) {
            IgniteLogger log = ignite().log();
            if (log.isInfoEnabled())
                log.info("Put maps set generated.");
        }
    }
    cache.putAll(vals);
    return true;
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) List(java.util.List) ArrayList(java.util.ArrayList) IgniteLogger(org.apache.ignite.IgniteLogger) TreeMap(java.util.TreeMap) Map(java.util.Map)

Example 49 with IgniteLogger

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

the class IgnitePutAllBenchmark method setUp.

/** {@inheritDoc} */
@Override
public void setUp(BenchmarkConfiguration cfg) throws Exception {
    super.setUp(cfg);
    aff = ignite().affinity(cache().getName());
    Collection<ClusterNode> nodes = ignite().cluster().forServers().nodes();
    stripesCnt = ignite().cluster().forServers().forRandom().metrics().getTotalCpus();
    srvrCnt = nodes.size();
    IgniteLogger log = ignite().log();
    if (log.isInfoEnabled())
        log.info("Servers info [srvrsCnt=" + srvrCnt + ", stripesCnt=" + stripesCnt + ']');
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) 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