/** {@inheritDoc} */ @Override public boolean isPeerClassLoadingEnabled() { assert cfg != null; return cfg.isPeerClassLoadingEnabled(); }
/** * */ private void ackP2pConfiguration() { assert cfg != null; if (cfg.isPeerClassLoadingEnabled()) U.warn( log, "Peer class loading is enabled (disable it in production for performance and " + "deployment consistency reasons)", "Peer class loading is enabled (disable it for better performance)" ); }
@Nullable @Override public Object call() throws GridException { try { if (internal && ctx.config().isPeerClassLoadingEnabled()) ctx.job().internal(true); return job.execute(); } finally { if (internal && ctx.config().isPeerClassLoadingEnabled()) ctx.job().internal(false); } } });
/** {@inheritDoc} */ @Override public void p2pMarshal(GridKernalContext ctx) throws GridException { assert ctx != null; assert ctx.config().isPeerClassLoadingEnabled(); if (filter != null && !U.isGrid(filter.getClass())) filterDep = new DeployableObject(filter, ctx); if (prjPred != null && !U.isGrid(prjPred.getClass())) prjPredDep = new DeployableObject(prjPred, ctx); }
/** {@inheritDoc} */ @Override public void p2pUnmarshal(UUID nodeId, GridKernalContext ctx) throws GridException { assert nodeId != null; assert ctx != null; assert ctx.config().isPeerClassLoadingEnabled(); if (filterDep != null) filter = filterDep.unmarshal(nodeId, ctx); if (prjPredDep != null) prjPred = prjPredDep.unmarshal(nodeId, ctx); }
/** {@inheritDoc} */ @Override public void start() throws GridException { if (ctx.isDaemon()) return; GridConfiguration cfg = ctx.config(); GridDeploymentMode depMode = cfg.getDeploymentMode(); if (cfg.isPeerClassLoadingEnabled() && (depMode == PRIVATE || depMode == ISOLATED) && !F.isEmpty(cfg.getServiceConfiguration())) throw new GridException("Cannot deploy services in PRIVATE or ISOLATED deployment mode: " + depMode); }
/** * @param c Grid configuration. * @return Data transfer object for node P2P configuration properties. */ public static VisorPeerToPeerConfig from(GridConfiguration c) { VisorPeerToPeerConfig cfg = new VisorPeerToPeerConfig(); cfg.p2pEnabled(c.isPeerClassLoadingEnabled()); cfg.p2pMissedResponseCacheSize(c.getPeerClassLoadingMissedResourcesCacheSize()); cfg.p2pLocalClassPathExclude(compactArray(c.getPeerClassLoadingLocalClassPathExclude())); return cfg; }
/** {@inheritDoc} */ @Override public void p2pMarshal(GridKernalContext ctx) throws GridException { 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 GridDeploymentException("Failed to deploy event filter: " + filter); depInfo = new GridDeploymentInfoBean(dep); filterBytes = ctx.config().getMarshaller().marshal(filter); } }
/** * @param ctx Grid kernal context. */ public GridDeploymentManager(GridKernalContext ctx) { super(ctx, ctx.config().getDeploymentSpi()); if (!ctx.config().isPeerClassLoadingEnabled()) { GridDeploymentSpi spi = ctx.config().getDeploymentSpi(); GridIgnoreIfPeerClassLoadingDisabled ann = U.getAnnotation(spi.getClass(), GridIgnoreIfPeerClassLoadingDisabled.class); locDep = ann != null ? new LocalDeployment( ctx.config().getDeploymentMode(), U.gridClassLoader(), GridUuid.fromUuid(ctx.localNodeId()), ctx.userVersion(U.gridClassLoader()), String.class.getName()) : null; } else locDep = null; }
/** {@inheritDoc} */ @Override public void onDiscoveryDataReceived(Object obj) { DiscoveryData data = (DiscoveryData)obj; if (!ctx.isDaemon() && data != null) { for (DiscoveryDataItem item : data.items) { // Register handler only if local node passes projection predicate. if (item.prjPred == null || item.prjPred.apply(ctx.discovery().localNode())) { try { if (ctx.config().isPeerClassLoadingEnabled()) item.hnd.p2pUnmarshal(data.nodeId, ctx); if (registerHandler(data.nodeId, item.routineId, item.hnd, item.bufSize, item.interval, item.autoUnsubscribe, false)) item.hnd.onListenerRegistered(item.routineId, ctx); } catch (GridException e) { U.error(log, "Failed to register continuous handler.", e); } } } } }
/** {@inheritDoc} */ @Override public void p2pMarshal(GridKernalContext ctx) throws GridException { assert ctx != null; assert ctx.config().isPeerClassLoadingEnabled(); if (topic != null) topicBytes = ctx.config().getMarshaller().marshal(topic); predBytes = ctx.config().getMarshaller().marshal(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 GridDeploymentException("Failed to deploy message listener."); depInfo = new GridDeploymentInfoBean(dep); depEnabled = true; }
/** {@inheritDoc} */ @Override public void p2pUnmarshal(UUID nodeId, GridKernalContext ctx) throws GridException { assert nodeId != null; assert ctx != null; assert ctx.config().isPeerClassLoadingEnabled(); if (filterBytes != null) { GridDeployment dep = ctx.deploy().getGlobalDeployment(depInfo.deployMode(), clsName, clsName, depInfo.userVersion(), nodeId, depInfo.classLoaderId(), depInfo.participants(), null); if (dep == null) throw new GridDeploymentException("Failed to obtain deployment for class: " + clsName); filter = ctx.config().getMarshaller().unmarshal(filterBytes, dep.classLoader()); } }
/** * @param ctx Context. * @param cfg Configuration to check for possible performance issues. */ private void suggestOptimizations(GridKernalContext ctx, GridConfiguration cfg) { GridPerformanceSuggestions perf = ctx.performance(); if (ctx.collision().enabled()) perf.add("Disable collision resolution (remove 'collisionSpi' from configuration)"); if (ctx.checkpoint().enabled()) perf.add("Disable checkpoints (remove 'checkpointSpi' from configuration)"); if (cfg.isPeerClassLoadingEnabled()) perf.add("Disable peer class loading (set 'peerClassLoadingEnabled' to false)"); if (cfg.isMarshalLocalJobs()) perf.add("Disable local jobs marshalling (set 'marshalLocalJobs' to false)"); if (cfg.getIncludeEventTypes() != null && cfg.getIncludeEventTypes().length != 0) perf.add("Disable grid events (remove 'includeEventTypes' from configuration)"); if (GridOptimizedMarshaller.available() && !(cfg.getMarshaller() instanceof GridOptimizedMarshaller)) perf.add("Enable optimized marshaller (set 'marshaller' to " + GridOptimizedMarshaller.class.getSimpleName() + ')'); }
&& ctx.config().isPeerClassLoadingEnabled()) { msg = "Failed to execute job due to class or resource loading exception (make sure that task " + "originating node is still in grid and requested class is in the task class path) [jobId=" +
/** {@inheritDoc} */ @Override public void p2pUnmarshal(UUID nodeId, GridKernalContext ctx) throws GridException { assert nodeId != null; assert ctx != null; assert ctx.config().isPeerClassLoadingEnabled(); GridDeployment dep = ctx.deploy().getGlobalDeployment(depInfo.deployMode(), clsName, clsName, depInfo.userVersion(), nodeId, depInfo.classLoaderId(), depInfo.participants(), null); if (dep == null) throw new GridDeploymentException("Failed to obtain deployment for class: " + clsName); ClassLoader ldr = dep.classLoader(); if (topicBytes != null) topic = ctx.config().getMarshaller().unmarshal(topicBytes, ldr); pred = ctx.config().getMarshaller().unmarshal(predBytes, ldr); }
assert ctx.config().isPeerClassLoadingEnabled();
/** * Validates service configuration. * * @param c Service configuration. * @throws GridRuntimeException If validation failed. */ private void validate(GridServiceConfiguration c) throws GridRuntimeException { GridConfiguration cfg = ctx.config(); GridDeploymentMode depMode = cfg.getDeploymentMode(); if (cfg.isPeerClassLoadingEnabled() && (depMode == PRIVATE || depMode == ISOLATED)) throw new GridRuntimeException("Cannot deploy services in PRIVATE or ISOLATED deployment mode: " + depMode); ensure(c.getName() != null, "getName() != null", null); ensure(c.getTotalCount() >= 0, "getTotalCount() >= 0", c.getTotalCount()); ensure(c.getMaxPerNodeCount() >= 0, "getMaxPerNodeCount() >= 0", c.getMaxPerNodeCount()); ensure(c.getService() != null, "getService() != null", c.getService()); ensure(c.getTotalCount() > 0 || c.getMaxPerNodeCount() > 0, "c.getTotalCount() > 0 || c.getMaxPerNodeCount() > 0", null); }
String cacheName = ((GridCacheEvent)evt).cacheName(); if (ctx.config().isPeerClassLoadingEnabled() && U.hasCache(node, cacheName)) { wrapper.p2pMarshal(ctx.config().getMarshaller());
info.value(cctx.kernalContext().config().isPeerClassLoadingEnabled() ? rawGetOrUnmarshalUnlocked(false) : val);
/** {@inheritDoc} */ @Override public void start() throws GridException { GridProtocolHandler.registerDeploymentManager(this); assertParameter(ctx.config().getDeploymentMode() != null, "ctx.config().getDeploymentMode() != null"); if (ctx.config().isPeerClassLoadingEnabled()) assertParameter(ctx.config().getNetworkTimeout() > 0, "networkTimeout > 0"); startSpi(); comm = new GridDeploymentCommunication(ctx, log); comm.start(); locStore = new GridDeploymentLocalStore(getSpi(), ctx, comm); ldrStore = new GridDeploymentPerLoaderStore(getSpi(), ctx, comm); verStore = new GridDeploymentPerVersionStore(getSpi(), ctx, comm); locStore.start(); ldrStore.start(); verStore.start(); if (log.isDebugEnabled()) { log.debug("Local deployment: " + locDep); log.debug(startInfo()); } }