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;
}
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;
}
});
}
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;
}
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 + ']');
}
Aggregations