/** * @param ctx Kernal context. */ public GridOffHeapProcessor(GridKernalContext ctx) { super(ctx); marsh = ctx.config().getMarshaller(); }
/** * @return Marshaller. */ public GridMarshaller marshaller() { return ctx.config().getMarshaller(); }
/** * Creates new instance of deployment communication. * * @param ctx Kernal context. * @param log Logger. */ GridDeploymentCommunication(final GridKernalContext ctx, GridLogger log) { assert log != null; this.ctx = ctx; this.log = log.getLogger(getClass()); peerLsnr = new GridMessageListener() { @Override public void onMessage(UUID nodeId, Object msg) { processDeploymentRequest(nodeId, msg); } }; marsh = ctx.config().getMarshaller(); }
@Override public void writeToOffheap(@Nullable String spaceName, int part, Object key, @Nullable byte[] keyBytes, Object val, @Nullable byte[] valBytes, @Nullable ClassLoader ldr) throws GridException { ctx.offheap().put(spaceName, part, key, keyBytes, valBytes != null ? valBytes : ctx.config().getMarshaller().marshal(val)); }
/** * Marshals object. * * @param obj Object to marshal. * @return Marshalled array. * @throws GridException If failed. */ private byte[] marshal(Object obj) throws GridException { return ctx.config().getMarshaller().marshal(obj); }
/** * @param ctx Kernal context. */ public GridIndexingManager(GridKernalContext ctx) { super(ctx, ctx.config().getIndexingSpi()); marsh = ctx.config().getMarshaller(); }
/** * @param ctx Grid kernal context. */ public GridCheckpointManager(GridKernalContext ctx) { super(ctx, ctx.config().getCheckpointSpi()); marsh = ctx.config().getMarshaller(); }
/** * @param ctx Kernal context. */ public GridDataLoaderProcessor(GridKernalContext ctx) { super(ctx); ctx.io().addMessageListener(TOPIC_DATALOAD, new GridMessageListener() { @SuppressWarnings("unchecked") @Override public void onMessage(UUID nodeId, Object msg) { assert msg instanceof GridDataLoadRequest; processDataLoadRequest(nodeId, (GridDataLoadRequest<K, V>)msg); } }); marsh = ctx.config().getMarshaller(); }
/** * @param nodeId Node ID. * @param topic Topic. * @param msg Message. * @param plc Policy. * @throws GridException In case of error. */ public void send(UUID nodeId, Object topic, GridGgfsCommunicationMessage msg, GridIoPolicy plc) throws GridException { if (!kernalContext().localNodeId().equals(nodeId)) msg.prepareMarshal(kernalContext().config().getMarshaller()); kernalContext().io().send(nodeId, topic, msg, plc); }
/** * @param ctx Grid kernal context. */ @SuppressWarnings("deprecation") public GridIoManager(GridKernalContext ctx) { super(ctx, ctx.config().getCommunicationSpi()); locNodeId = ctx.localNodeId(); discoDelay = ctx.config().getDiscoveryStartupDelay(); marsh = ctx.config().getMarshaller(); }
/** * @param nodeId Node ID. * @param topic Topic. * @param msg Message. * @param plc Policy. * @throws GridException In case of error. */ public void send(UUID nodeId, Object topic, GridGgfsCommunicationMessage msg, GridIoPolicy plc) throws GridException { if (!kernalContext().localNodeId().equals(nodeId)) msg.prepareMarshal(kernalContext().config().getMarshaller()); kernalContext().io().send(nodeId, topic, msg, plc); }
/** * @param ctx Kernal context. */ public GridTaskProcessor(GridKernalContext ctx) { super(ctx); marsh = ctx.config().getMarshaller(); discoLsnr = new TaskDiscoveryListener(); tasksMetaCache = ctx.security().enabled() ? ctx.cache().<GridTaskNameHashKey, String>utilityCache() : null; }
/** * @param obj Object. * @param ctx Kernal context. * @throws GridException In case of error. */ private DeployableObject(Object obj, GridKernalContext ctx) throws GridException { assert obj != null; assert ctx != null; Class cls = U.detectClass(obj); clsName = cls.getName(); GridDeployment dep = ctx.deploy().deploy(cls, U.detectClassLoader(cls)); if (dep == null) throw new GridDeploymentException("Failed to deploy object: " + obj); depInfo = new GridDeploymentInfoBean(dep); bytes = ctx.config().getMarshaller().marshal(obj); }
/** * @param node Node. * @param topic Topic. * @param msg Message. * @param plc Policy. * @throws GridException In case of error. */ public void send(GridNode node, Object topic, GridGgfsCommunicationMessage msg, GridIoPolicy plc) throws GridException { if (!kernalContext().localNodeId().equals(node.id())) msg.prepareMarshal(kernalContext().config().getMarshaller()); kernalContext().io().send(node, topic, msg, plc); }
/** * @param node Node. * @param topic Topic. * @param msg Message. * @param plc Policy. * @throws GridException In case of error. */ public void send(GridNode node, Object topic, GridGgfsCommunicationMessage msg, GridIoPolicy plc) throws GridException { if (!kernalContext().localNodeId().equals(node.id())) msg.prepareMarshal(kernalContext().config().getMarshaller()); kernalContext().io().send(node, topic, msg, plc); }
/** {@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); } }
/** {@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); }
/** * @param nodeId Node ID. * @param ctx Kernal context. * @return Deserialized object. * @throws GridException In case of error. */ <T> T unmarshal(UUID nodeId, GridKernalContext ctx) throws GridException { assert ctx != 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); return ctx.config().getMarshaller().unmarshal(bytes, dep.classLoader()); }
/** {@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 cfg Grid configuration. * @return Components provided in configuration which can implement {@link GridLifecycleAware} interface. */ private Iterable<Object> lifecycleAwares(GridConfiguration cfg) { Collection<Object> objs = new ArrayList<>(); if (!F.isEmpty(cfg.getLifecycleBeans())) F.copy(objs, cfg.getLifecycleBeans()); if (!F.isEmpty(cfg.getSegmentationResolvers())) F.copy(objs, cfg.getSegmentationResolvers()); if (cfg.getClientConnectionConfiguration() != null) F.copy(objs, cfg.getClientConnectionConfiguration().getClientMessageInterceptor(), cfg.getClientConnectionConfiguration().getRestTcpSslContextFactory()); F.copy(objs, cfg.getMarshaller(), cfg.getGridLogger(), cfg.getMBeanServer()); return objs; }