use of org.apache.ignite.IgniteLogger in project ignite by apache.
the class GridCacheAbstractLoadTest method initLogger.
/**
* Initializes logger.
*
* @param log Log file name.
* @return Logger.
* @throws IgniteCheckedException If file initialization failed.
*/
protected IgniteLogger initLogger(String log) throws IgniteCheckedException {
Logger impl = Logger.getRootLogger();
impl.removeAllAppenders();
String fileName = U.getIgniteHome() + "/work/log/" + log;
// Configure output that should go to System.out
RollingFileAppender fileApp;
String fmt = "[%d{ISO8601}][%-5p][%t][%c{1}] %m%n";
try {
fileApp = new RollingFileAppender(new PatternLayout(fmt), fileName);
fileApp.setMaxBackupIndex(0);
fileApp.setAppend(false);
// fileApp.rollOver();
fileApp.activateOptions();
} catch (IOException e) {
throw new IgniteCheckedException("Unable to initialize file appender.", e);
}
LevelRangeFilter lvlFilter = new LevelRangeFilter();
lvlFilter.setLevelMin(Level.DEBUG);
fileApp.addFilter(lvlFilter);
impl.addAppender(fileApp);
// Configure output that should go to System.out
ConsoleAppender conApp = new ConsoleAppender(new PatternLayout(fmt), ConsoleAppender.SYSTEM_OUT);
lvlFilter = new LevelRangeFilter();
lvlFilter.setLevelMin(Level.DEBUG);
lvlFilter.setLevelMax(Level.INFO);
conApp.addFilter(lvlFilter);
conApp.activateOptions();
impl.addAppender(conApp);
// Configure output that should go to System.err
conApp = new ConsoleAppender(new PatternLayout(fmt), ConsoleAppender.SYSTEM_ERR);
conApp.setThreshold(Level.WARN);
conApp.activateOptions();
impl.addAppender(conApp);
impl.setLevel(Level.INFO);
return new GridTestLog4jLogger(false);
}
use of org.apache.ignite.IgniteLogger in project ignite by apache.
the class GridToStringBuilderSelfTest method testToStringPerformance.
/**
* JUnit.
*/
public void testToStringPerformance() {
TestClass1 obj = new TestClass1();
IgniteLogger log = log();
// Warm up.
obj.toStringAutomatic();
long start = System.currentTimeMillis();
for (int i = 0; i < 100000; i++) obj.toStringManual();
log.info("Manual toString() took: " + (System.currentTimeMillis() - start) + "ms");
start = System.currentTimeMillis();
for (int i = 0; i < 100000; i++) obj.toStringAutomatic();
log.info("Automatic toString() took: " + (System.currentTimeMillis() - start) + "ms");
}
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());
}
}
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);
}
}
notifyLocalListener(entries0, returnValTrans);
}
use of org.apache.ignite.IgniteLogger in project ignite by apache.
the class GridCacheIoManager method handleMessage.
/**
* @param nodeId Sender node ID.
* @param cacheMsg Message.
* @param msgHandlers Message handlers.
* @param plc Message policy.
*/
@SuppressWarnings("unchecked")
private void handleMessage(UUID nodeId, GridCacheMessage cacheMsg, MessageHandlers msgHandlers, byte plc) {
Lock lock = rw.readLock();
lock.lock();
try {
int msgIdx = cacheMsg.lookupIndex();
IgniteBiInClosure<UUID, GridCacheMessage> c = null;
if (msgIdx >= 0) {
Map<Integer, IgniteBiInClosure[]> idxClsHandlers0 = msgHandlers.idxClsHandlers;
IgniteBiInClosure[] cacheClsHandlers = idxClsHandlers0.get(cacheMsg.handlerId());
if (cacheClsHandlers != null)
c = cacheClsHandlers[msgIdx];
}
if (c == null)
c = msgHandlers.clsHandlers.get(new ListenerKey(cacheMsg.handlerId(), cacheMsg.getClass()));
if (c == null) {
if (processMissedHandler(nodeId, cacheMsg))
return;
IgniteLogger log = cacheMsg.messageLogger(cctx);
StringBuilder msg0 = new StringBuilder("Received message without registered handler (will ignore) [");
appendMessageInfo(cacheMsg, nodeId, msg0);
msg0.append(", locTopVer=").append(cctx.exchange().readyAffinityVersion()).append(", msgTopVer=").append(cacheMsg.topologyVersion()).append(", desc=").append(descriptorForMessage(cacheMsg)).append(']');
msg0.append(nl()).append("Registered listeners:");
Map<Integer, IgniteBiInClosure[]> idxClsHandlers0 = msgHandlers.idxClsHandlers;
for (Map.Entry<Integer, IgniteBiInClosure[]> e : idxClsHandlers0.entrySet()) msg0.append(nl()).append(e.getKey()).append("=").append(Arrays.toString(e.getValue()));
if (cctx.kernalContext().isStopping()) {
if (log.isDebugEnabled())
log.debug(msg0.toString());
} else {
U.error(log, msg0.toString());
try {
cacheMsg.onClassError(new IgniteCheckedException("Failed to find message handler for message: " + cacheMsg));
processFailedMessage(nodeId, cacheMsg, c, plc);
} catch (Exception e) {
U.error(log, "Failed to process failed message: " + e, e);
}
}
return;
}
onMessage0(nodeId, cacheMsg, c, plc);
} finally {
lock.unlock();
}
}
use of org.apache.ignite.IgniteLogger in project ignite by apache.
the class GridCacheIoManager method addOrderedHandler.
/**
* Adds ordered message handler.
*
* @param cctx Context.
* @param cacheGrp {@code True} if cache group message, {@code false} if cache message.
* @param topic Topic.
* @param c Handler.
*/
@SuppressWarnings({ "unchecked" })
private void addOrderedHandler(GridCacheSharedContext cctx, boolean cacheGrp, Object topic, IgniteBiInClosure<UUID, ? extends GridCacheMessage> c) {
MessageHandlers msgHandlers = cacheGrp ? grpHandlers : cacheHandlers;
IgniteLogger log0 = log;
if (msgHandlers.orderedHandlers.putIfAbsent(topic, c) == null) {
cctx.gridIO().addMessageListener(topic, new OrderedMessageListener((IgniteBiInClosure<UUID, GridCacheMessage>) c));
if (log0 != null && log0.isTraceEnabled())
log0.trace("Registered ordered cache communication handler [topic=" + topic + ", handler=" + c + ']');
} else if (log0 != null)
U.warn(log0, "Failed to register ordered cache communication handler because it is already " + "registered for this topic [topic=" + topic + ", handler=" + c + ']');
}
Aggregations