use of org.apache.ignite.internal.managers.deployment.GridDeploymentInfoBean in project ignite by apache.
the class GridMessageListenHandler method p2pMarshal.
/** {@inheritDoc} */
@Override
public void p2pMarshal(GridKernalContext ctx) throws IgniteCheckedException {
assert ctx != null;
assert ctx.config().isPeerClassLoadingEnabled();
if (topic != null)
topicBytes = U.marshal(ctx.config().getMarshaller(), topic);
predBytes = U.marshal(ctx.config().getMarshaller(), pred);
// Deploy only listener, as it is very likely to be of some user class.
GridPeerDeployAware pda = U.peerDeployAware(pred);
clsName = pda.deployClass().getName();
GridDeployment dep = ctx.deploy().deploy(pda.deployClass(), pda.classLoader());
if (dep == null)
throw new IgniteDeploymentCheckedException("Failed to deploy message listener.");
depInfo = new GridDeploymentInfoBean(dep);
depEnabled = true;
}
use of org.apache.ignite.internal.managers.deployment.GridDeploymentInfoBean in project ignite by apache.
the class GridEventConsumeHandler method p2pMarshal.
/** {@inheritDoc} */
@Override
public void p2pMarshal(GridKernalContext ctx) throws IgniteCheckedException {
assert ctx != null;
assert ctx.config().isPeerClassLoadingEnabled();
if (filter != null) {
Class cls = U.detectClass(filter);
clsName = cls.getName();
GridDeployment dep = ctx.deploy().deploy(cls, U.detectClassLoader(cls));
if (dep == null)
throw new IgniteDeploymentCheckedException("Failed to deploy event filter: " + filter);
depInfo = new GridDeploymentInfoBean(dep);
filterBytes = U.marshal(ctx.config().getMarshaller(), filter);
}
}
use of org.apache.ignite.internal.managers.deployment.GridDeploymentInfoBean in project ignite by apache.
the class GridCacheDeploymentManager method prepare.
/**
* Prepares deployable object.
*
* @param deployable Deployable object.
*/
public void prepare(GridCacheDeployable deployable) {
assert depEnabled;
// Only set deployment info if it was not set automatically.
if (deployable.deployInfo() == null) {
GridDeploymentInfoBean dep = globalDeploymentInfo();
if (dep == null) {
GridDeployment locDep0 = locDep.get();
if (locDep0 != null) {
// Will copy sequence number to bean.
dep = new GridDeploymentInfoBean(locDep0);
dep.localDeploymentOwner(locDepOwner);
}
}
if (dep != null)
deployable.prepare(dep);
if (log.isDebugEnabled())
log.debug("Prepared grid cache deployable [dep=" + dep + ", deployable=" + deployable + ']');
}
}
use of org.apache.ignite.internal.managers.deployment.GridDeploymentInfoBean in project ignite by apache.
the class GridContinuousProcessor method startRoutine.
/**
* @param hnd Handler.
* @param bufSize Buffer size.
* @param interval Time interval.
* @param autoUnsubscribe Automatic unsubscribe flag.
* @param locOnly Local only flag.
* @param prjPred Projection predicate.
* @return Future.
*/
@SuppressWarnings("TooBroadScope")
public IgniteInternalFuture<UUID> startRoutine(GridContinuousHandler hnd, boolean locOnly, int bufSize, long interval, boolean autoUnsubscribe, @Nullable IgnitePredicate<ClusterNode> prjPred) {
assert hnd != null;
assert bufSize > 0;
assert interval >= 0;
// Generate ID.
final UUID routineId = UUID.randomUUID();
// Register routine locally.
locInfos.put(routineId, new LocalRoutineInfo(prjPred, hnd, bufSize, interval, autoUnsubscribe));
if (locOnly) {
try {
registerHandler(ctx.localNodeId(), routineId, hnd, bufSize, interval, autoUnsubscribe, true);
return new GridFinishedFuture<>(routineId);
} catch (IgniteCheckedException e) {
unregisterHandler(routineId, hnd, true);
return new GridFinishedFuture<>(e);
}
}
// Whether local node is included in routine.
boolean locIncluded = prjPred == null || prjPred.apply(ctx.discovery().localNode());
StartRequestData reqData = new StartRequestData(prjPred, hnd.clone(), bufSize, interval, autoUnsubscribe);
try {
if (ctx.config().isPeerClassLoadingEnabled()) {
// Handle peer deployment for projection predicate.
if (prjPred != null && !U.isGrid(prjPred.getClass())) {
Class cls = U.detectClass(prjPred);
String clsName = cls.getName();
GridDeployment dep = ctx.deploy().deploy(cls, U.detectClassLoader(cls));
if (dep == null)
throw new IgniteDeploymentCheckedException("Failed to deploy projection predicate: " + prjPred);
reqData.className(clsName);
reqData.deploymentInfo(new GridDeploymentInfoBean(dep));
reqData.p2pMarshal(marsh);
}
// Handle peer deployment for other handler-specific objects.
reqData.handler().p2pMarshal(ctx);
}
} catch (IgniteCheckedException e) {
return new GridFinishedFuture<>(e);
}
// Register per-routine notifications listener if ordered messaging is used.
registerMessageListener(hnd);
StartFuture fut = new StartFuture(ctx, routineId);
startFuts.put(routineId, fut);
try {
if (locIncluded || hnd.isQuery())
registerHandler(ctx.localNodeId(), routineId, hnd, bufSize, interval, autoUnsubscribe, true);
ctx.discovery().sendCustomEvent(new StartRoutineDiscoveryMessage(routineId, reqData, reqData.handler().keepBinary()));
} catch (IgniteCheckedException e) {
startFuts.remove(routineId);
locInfos.remove(routineId);
unregisterHandler(routineId, hnd, true);
fut.onDone(e);
return fut;
}
// Handler is registered locally.
fut.onLocalRegistered();
return fut;
}
Aggregations