use of org.apache.ignite.internal.managers.deployment.GridDeploymentInfo 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();
try {
if (ctx.config().isPeerClassLoadingEnabled()) {
GridDeploymentInfo depInfo = e.deployInfo();
if (depInfo != null) {
depMgr.p2pContext(nodeId, depInfo.classLoaderId(), depInfo.userVersion(), depInfo.deployMode(), depInfo.participants());
}
}
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.internal.managers.deployment.GridDeploymentInfo in project ignite by apache.
the class GridEventConsumeHandler method notifyCallback.
/**
* @param nodeId Node ID.
* @param objs Notification objects.
*/
@Override
public void notifyCallback(UUID nodeId, UUID routineId, Collection<?> objs, GridKernalContext ctx) {
assert nodeId != null;
assert routineId != null;
assert objs != null;
assert ctx != null;
for (Object obj : objs) {
assert obj instanceof EventWrapper;
EventWrapper wrapper = (EventWrapper) obj;
if (wrapper.bytes != null) {
assert ctx.config().isPeerClassLoadingEnabled();
GridCacheAdapter cache = ctx.cache().internalCache(wrapper.cacheName);
ClassLoader ldr = null;
try {
if (cache != null) {
GridCacheDeploymentManager depMgr = cache.context().deploy();
GridDeploymentInfo depInfo = wrapper.depInfo;
if (depInfo != null) {
depMgr.p2pContext(nodeId, depInfo.classLoaderId(), depInfo.userVersion(), depInfo.deployMode(), depInfo.participants());
}
ldr = depMgr.globalLoader();
} else {
U.warn(ctx.log(getClass()), "Received cache event for cache that is not configured locally " + "when peer class loading is enabled: " + wrapper.cacheName + ". Will try to unmarshal " + "with default class loader.");
}
wrapper.p2pUnmarshal(ctx.config().getMarshaller(), U.resolveClassLoader(ldr, ctx.config()));
} catch (IgniteCheckedException e) {
U.error(ctx.log(getClass()), "Failed to unmarshal event.", e);
}
}
if (!cb.apply(nodeId, wrapper.evt)) {
ctx.continuous().stopRoutine(routineId);
break;
}
}
}
use of org.apache.ignite.internal.managers.deployment.GridDeploymentInfo in project ignite by apache.
the class GridContinuousProcessor method processStartRequestV2.
/**
* @param topVer Current topology version.
* @param snd Sender.
* @param msg Start request.
*/
private void processStartRequestV2(final AffinityTopologyVersion topVer, final ClusterNode snd, final StartRoutineDiscoveryMessageV2 msg) {
StartRequestDataV2 reqData = msg.startRequestData();
ContinuousRoutineInfo routineInfo = new ContinuousRoutineInfo(snd.id(), msg.routineId(), reqData.handlerBytes(), reqData.nodeFilterBytes(), reqData.bufferSize(), reqData.interval(), reqData.autoUnsubscribe());
routinesInfo.addRoutineInfo(routineInfo);
final DiscoCache discoCache = ctx.discovery().discoCache(topVer);
// Should not use marshaller and send messages from discovery thread.
ctx.pools().getSystemExecutorService().execute(new Runnable() {
@Override
public void run() {
if (snd.id().equals(ctx.localNodeId())) {
StartFuture fut = startFuts.get(msg.routineId());
if (fut != null)
fut.initRemoteNodes(discoCache);
return;
}
StartRequestDataV2 reqData = msg.startRequestData();
Exception err = null;
IgnitePredicate<ClusterNode> nodeFilter = null;
byte[] cntrs = null;
if (reqData.nodeFilterBytes() != null) {
try {
if (ctx.config().isPeerClassLoadingEnabled() && reqData.className() != null) {
String clsName = reqData.className();
GridDeploymentInfo depInfo = reqData.deploymentInfo();
GridDeployment dep = ctx.deploy().getGlobalDeployment(depInfo.deployMode(), clsName, clsName, depInfo.userVersion(), snd.id(), depInfo.classLoaderId(), depInfo.participants(), null);
if (dep == null) {
throw new IgniteDeploymentCheckedException("Failed to obtain deployment " + "for class: " + clsName);
}
nodeFilter = U.unmarshal(marsh, reqData.nodeFilterBytes(), U.resolveClassLoader(dep.classLoader(), ctx.config()));
} else {
nodeFilter = U.unmarshal(marsh, reqData.nodeFilterBytes(), U.resolveClassLoader(ctx.config()));
}
if (nodeFilter != null)
ctx.resource().injectGeneric(nodeFilter);
} catch (Exception e) {
err = e;
U.error(log, "Failed to unmarshal continuous routine filter [" + "routineId=" + msg.routineId + ", srcNodeId=" + snd.id() + ']', e);
}
}
boolean register = err == null && (nodeFilter == null || nodeFilter.apply(ctx.discovery().localNode()));
if (register) {
try {
GridContinuousHandler hnd = U.unmarshal(marsh, reqData.handlerBytes(), U.resolveClassLoader(ctx.config()));
if (ctx.config().isPeerClassLoadingEnabled())
hnd.p2pUnmarshal(snd.id(), ctx);
if (msg.keepBinary()) {
assert hnd instanceof CacheContinuousQueryHandler : hnd;
((CacheContinuousQueryHandler) hnd).keepBinary(true);
}
registerHandler(snd.id(), msg.routineId, hnd, reqData.bufferSize(), reqData.interval(), reqData.autoUnsubscribe(), false);
if (hnd.isQuery()) {
GridCacheProcessor proc = ctx.cache();
if (proc != null) {
GridCacheAdapter cache = ctx.cache().internalCache(hnd.cacheName());
if (cache != null && !cache.isLocal() && cache.context().userCache()) {
CachePartitionPartialCountersMap cntrsMap = cache.context().topology().localUpdateCounters(false);
cntrs = U.marshal(marsh, cntrsMap);
}
}
}
} catch (Exception e) {
err = e;
U.error(log, "Failed to register continuous routine handler [" + "routineId=" + msg.routineId + ", srcNodeId=" + snd.id() + ']', e);
}
}
sendMessageStartResult(snd, msg.routineId(), cntrs, err);
}
});
}
use of org.apache.ignite.internal.managers.deployment.GridDeploymentInfo in project ignite by apache.
the class GridCacheMessage method prepareObject.
/**
* @param o Object to prepare for marshalling.
* @param ctx Context.
* @throws IgniteCheckedException If failed.
*/
protected final void prepareObject(@Nullable Object o, GridCacheContext ctx) throws IgniteCheckedException {
assert addDepInfo || forceAddDepInfo;
if (!skipPrepare && o != null) {
GridDeploymentInfo d = ctx.deploy().globalDeploymentInfo();
if (d != null) {
prepare(d);
// Global deployment has been injected.
skipPrepare = true;
} else {
Class<?> cls = U.detectClass(o);
ctx.deploy().registerClass(cls);
ClassLoader ldr = U.detectClassLoader(cls);
if (ldr instanceof GridDeploymentInfo)
prepare((GridDeploymentInfo) ldr);
}
}
}
use of org.apache.ignite.internal.managers.deployment.GridDeploymentInfo in project ignite by apache.
the class GridCacheMessage method prepareObject.
/**
* @param o Object to prepare for marshalling.
* @param ctx Context.
* @throws IgniteCheckedException If failed.
*/
protected final void prepareObject(@Nullable Object o, GridCacheSharedContext ctx) throws IgniteCheckedException {
assert addDepInfo || forceAddDepInfo;
if (!skipPrepare && o != null) {
GridDeploymentInfo d = ctx.deploy().globalDeploymentInfo();
if (d != null) {
prepare(d);
// Global deployment has been injected.
skipPrepare = true;
} else {
Class<?> cls = U.detectClass(o);
ctx.deploy().registerClass(cls);
ClassLoader ldr = U.detectClassLoader(cls);
if (ldr instanceof GridDeploymentInfo)
prepare((GridDeploymentInfo) ldr);
}
}
}
Aggregations