use of org.apache.ignite.IgniteLogger in project ignite by apache.
the class GridCacheIoManager method addHandler.
/**
* @param hndId Message handler ID.
* @param type Type of message.
* @param c Handler.
* @param msgHandlers Message handlers.
*/
@SuppressWarnings({ "unchecked" })
private void addHandler(int hndId, Class<? extends GridCacheMessage> type, IgniteBiInClosure<UUID, ? extends GridCacheMessage> c, MessageHandlers msgHandlers) {
int msgIdx = messageIndex(type);
if (msgIdx != -1) {
Map<Integer, IgniteBiInClosure[]> idxClsHandlers0 = msgHandlers.idxClsHandlers;
IgniteBiInClosure[] cacheClsHandlers = idxClsHandlers0.get(hndId);
if (cacheClsHandlers == null) {
cacheClsHandlers = new IgniteBiInClosure[GridCacheMessage.MAX_CACHE_MSG_LOOKUP_INDEX];
idxClsHandlers0.put(hndId, cacheClsHandlers);
}
if (cacheClsHandlers[msgIdx] != null)
throw new IgniteException("Duplicate cache message ID found [hndId=" + hndId + ", type=" + type + ']');
cacheClsHandlers[msgIdx] = c;
msgHandlers.idxClsHandlers = idxClsHandlers0;
return;
} else {
ListenerKey key = new ListenerKey(hndId, type);
if (msgHandlers.clsHandlers.putIfAbsent(key, (IgniteBiInClosure<UUID, GridCacheMessage>) c) != null)
assert false : "Handler for class already registered [hndId=" + hndId + ", cls=" + type + ", old=" + msgHandlers.clsHandlers.get(key) + ", new=" + c + ']';
}
IgniteLogger log0 = log;
if (log0 != null && log0.isTraceEnabled())
log0.trace("Registered cache communication handler [hndId=" + hndId + ", type=" + type + ", msgIdx=" + msgIdx + ", handler=" + c + ']');
}
use of org.apache.ignite.IgniteLogger in project ignite by apache.
the class CacheContinuousQueryHandler method sendBackupAcknowledge.
/**
* @param t Acknowledge information.
* @param routineId Routine ID.
* @param ctx Context.
*/
private void sendBackupAcknowledge(final IgniteBiTuple<Map<Integer, Long>, Set<AffinityTopologyVersion>> t, final UUID routineId, final GridKernalContext ctx) {
if (t != null) {
ctx.closure().runLocalSafe(new Runnable() {
@Override
public void run() {
GridCacheContext<K, V> cctx = cacheContext(ctx);
CacheContinuousQueryBatchAck msg = new CacheContinuousQueryBatchAck(cctx.cacheId(), routineId, t.get1());
for (AffinityTopologyVersion topVer : t.get2()) {
for (ClusterNode node : ctx.discovery().cacheGroupAffinityNodes(cctx.groupId(), topVer)) {
if (!node.isLocal()) {
try {
cctx.io().send(node, msg, GridIoPolicy.SYSTEM_POOL);
} catch (ClusterTopologyCheckedException ignored) {
IgniteLogger log = ctx.log(CU.CONTINUOUS_QRY_LOG_CATEGORY);
if (log.isDebugEnabled())
log.debug("Failed to send acknowledge message, node left " + "[msg=" + msg + ", node=" + node + ']');
} catch (IgniteCheckedException e) {
IgniteLogger log = ctx.log(CU.CONTINUOUS_QRY_LOG_CATEGORY);
U.error(log, "Failed to send acknowledge message " + "[msg=" + msg + ", node=" + node + ']', e);
}
}
}
}
}
});
}
}
use of org.apache.ignite.IgniteLogger in project ignite by apache.
the class GridDhtAssignmentFetchFuture method requestFromNextNode.
/**
* Requests affinity from next node in the list.
*/
private void requestFromNextNode() {
boolean complete;
// Avoid 'protected field is accessed in synchronized context' warning.
IgniteLogger log0 = log;
synchronized (this) {
while (!availableNodes.isEmpty()) {
ClusterNode node = availableNodes.poll();
try {
if (log0.isDebugEnabled())
log0.debug("Sending affinity fetch request to remote node [locNodeId=" + ctx.localNodeId() + ", node=" + node + ']');
ctx.io().send(node, new GridDhtAffinityAssignmentRequest(id, grpId, topVer, needPartState), AFFINITY_POOL);
// Close window for listener notification.
if (ctx.discovery().node(node.id()) == null) {
U.warn(log0, "Failed to request affinity assignment from remote node (node left grid, will " + "continue to another node): " + node);
continue;
}
pendingNode = node;
break;
} catch (ClusterTopologyCheckedException ignored) {
U.warn(log0, "Failed to request affinity assignment from remote node (node left grid, will " + "continue to another node): " + node);
} catch (IgniteCheckedException e) {
if (ctx.discovery().reconnectSupported() && X.hasCause(e, IOException.class)) {
onDone(new IgniteNeedReconnectException(ctx.localNode(), e));
return;
}
U.warn(log0, "Failed to request affinity assignment from remote node (will " + "continue to another node): " + node);
}
}
complete = pendingNode == null;
}
// Affinity should be calculated from scratch.
if (complete)
onDone((GridDhtAffinityAssignmentResponse) null);
}
use of org.apache.ignite.IgniteLogger in project ignite by apache.
the class IgniteDrDataStreamerCacheUpdater method receive.
/**
* {@inheritDoc}
*/
@Override
public void receive(IgniteCache<KeyCacheObject, CacheObject> cache0, Collection<Map.Entry<KeyCacheObject, CacheObject>> col) {
try {
String cacheName = cache0.getConfiguration(CacheConfiguration.class).getName();
GridKernalContext ctx = ((IgniteKernal) cache0.unwrap(Ignite.class)).context();
IgniteLogger log = ctx.log(IgniteDrDataStreamerCacheUpdater.class);
GridCacheAdapter internalCache = ctx.cache().internalCache(cacheName);
CacheOperationContext opCtx = ((IgniteCacheProxy) cache0).context().operationContextPerCall();
IgniteInternalCache cache = opCtx != null ? new GridCacheProxyImpl(internalCache.context(), internalCache, opCtx) : internalCache;
assert !F.isEmpty(col);
if (log.isDebugEnabled())
log.debug("Running DR put job [nodeId=" + ctx.localNodeId() + ", cacheName=" + cacheName + ']');
CacheObjectContext cacheObjCtx = cache.context().cacheObjectContext();
for (Map.Entry<KeyCacheObject, CacheObject> entry0 : col) {
GridCacheRawVersionedEntry entry = (GridCacheRawVersionedEntry) entry0;
entry.unmarshal(cacheObjCtx, ctx.config().getMarshaller());
KeyCacheObject key = entry.getKey();
// Ensure that receiver to not receive special-purpose values for TTL and expire time.
assert entry.ttl() != CU.TTL_NOT_CHANGED && entry.ttl() != CU.TTL_ZERO && entry.ttl() >= 0;
assert entry.expireTime() != CU.EXPIRE_TIME_CALCULATE && entry.expireTime() >= 0;
CacheObject cacheVal = entry.getValue();
GridCacheDrInfo val = cacheVal != null ? entry.ttl() != CU.TTL_ETERNAL ? new GridCacheDrExpirationInfo(cacheVal, entry.version(), entry.ttl(), entry.expireTime()) : new GridCacheDrInfo(cacheVal, entry.version()) : null;
if (val == null)
cache.removeAllConflict(Collections.singletonMap(key, entry.version()));
else
cache.putAllConflict(Collections.singletonMap(key, val));
}
if (log.isDebugEnabled())
log.debug("DR put job finished [nodeId=" + ctx.localNodeId() + ", cacheName=" + cacheName + ']');
} catch (IgniteCheckedException e) {
throw U.convertException(e);
}
}
use of org.apache.ignite.IgniteLogger in project ignite by apache.
the class CacheContinuousWithTransformerFailoverTest method testTransformerException.
/**
* @throws Exception If failed.
*/
public void testTransformerException() throws Exception {
try {
startGrids(1);
Ignite ignite = ignite(0);
IgniteCache<Integer, Integer> cache = ignite.cache(DEFAULT_CACHE_NAME);
final CountDownLatch latch = new CountDownLatch(10);
ContinuousQueryWithTransformer<Integer, Integer, Integer> qry = new ContinuousQueryWithTransformer<>();
qry.setLocalListener(new EventListener<Integer>() {
/**
*/
@LoggerResource
private IgniteLogger log;
@Override
public void onUpdated(Iterable<? extends Integer> evts) throws CacheEntryListenerException {
for (Integer evt : evts) {
log.debug("" + evt);
}
}
});
qry.setRemoteTransformerFactory(FactoryBuilder.factoryOf(new IgniteClosure<CacheEntryEvent<? extends Integer, ? extends Integer>, Integer>() {
@Override
public Integer apply(CacheEntryEvent<? extends Integer, ? extends Integer> evt) {
latch.countDown();
throw new RuntimeException("Test error.");
}
}));
qry.setRemoteFilterFactory(FactoryBuilder.factoryOf(new CacheEntryEventSerializableFilter<Integer, Integer>() {
@Override
public boolean evaluate(CacheEntryEvent<? extends Integer, ? extends Integer> evt) {
return true;
}
}));
try (QueryCursor<Cache.Entry<Integer, Integer>> ignored = cache.query(qry)) {
for (int i = 0; i < 10; i++) cache.put(i, i);
assertTrue(latch.await(10, SECONDS));
}
} finally {
stopAllGrids();
}
}
Aggregations