Class GridResourceProcessor
- java.lang.Object
-
- org.apache.ignite.internal.processors.GridProcessorAdapter
-
- org.apache.ignite.internal.processors.resource.GridResourceProcessor
-
- All Implemented Interfaces:
GridComponent,GridProcessor
public class GridResourceProcessor extends GridProcessorAdapter
Processor for all Ignite and task/job resources.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.ignite.internal.GridComponent
GridComponent.DiscoveryDataExchangeType
-
-
Field Summary
-
Fields inherited from class org.apache.ignite.internal.processors.GridProcessorAdapter
ctx, diagnosticLog, log
-
-
Constructor Summary
Constructors Constructor Description GridResourceProcessor(GridKernalContext ctx)Creates resources processor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcleanup(LifecycleBean lifecycleBean)Cleans up resources from given lifecycle beans.voidcleanup(Service svc)Cleans up resources from given service.voidcleanup(IgniteSpi spi)Cleans up resources from given SPI implementation.voidcleanupGeneric(Object obj)voidinject(Object obj, GridResourceIoc.AnnotationSet annSet, Object... params)voidinject(GridDeployment dep, Class<?> depCls, Object target)Injects resources into generic class.voidinject(GridDeployment dep, Class<?> taskCls, ComputeJob job, ComputeTaskSession ses, GridJobContextImpl jobCtx)Injects held resources into givenjob.voidinject(GridDeployment dep, ComputeTask<?,?> task, GridTaskSessionImpl ses, ComputeLoadBalancer balancer, ComputeTaskContinuousMapper mapper)Injects held resources into given grid task.voidinject(LifecycleBean lifecycleBean)Injects held resources into given lifecycle bean.voidinject(Service svc, ServiceContext svcCtx)Injects resources into service.voidinject(IgniteSpi spi)Injects held resources into given SPI implementation.voidinjectBasicResource(Object target, Class<? extends Annotation> annCls, Object rsrc)This method is declared public as it is used from tests as well.voidinjectCacheName(Object obj, String cacheName)Injects cache name into given object.voidinjectGeneric(Object obj)booleaninjectStoreSession(Object obj, CacheStoreSession ses)Injects cache store session into given object.voidinvokeAnnotated(GridDeployment dep, Object target, Class<? extends Annotation> annCls)booleanisAnnotationPresent(GridDeployment dep, Object target, Class<? extends Annotation> annCls)Checks if annotation presents in specified object.booleanisAnnotationsPresent(GridDeployment dep, Object target, GridResourceIoc.AnnotationSet annSet)Checks if annotations presents in specified object.voidonKernalStart(boolean active)Callback that notifies that kernal has successfully started, including all managers and processors.voidonUndeployed(GridDeployment dep)Callback to be called when class loader is undeployed.voidprintMemoryStats()Prints memory statistics (sizes of internal structures, etc.).<T> Tresolve(T instance)Delegates resource resolving to the provided dependency resolver, which wraps passed instance if necessary.voidsetSpringContext(@Nullable GridSpringResourceContext rsrcCtx)Sets Spring resource context.voidstart()Starts grid component.voidstop(boolean cancel)Stops grid component.-
Methods inherited from class org.apache.ignite.internal.processors.GridProcessorAdapter
assertParameter, collectGridNodeData, collectJoiningNodeData, discoveryDataType, onDisconnected, onGridDataReceived, onJoiningNodeDataReceived, onKernalStop, onReconnected, toString, validateNode, validateNode
-
-
-
-
Constructor Detail
-
GridResourceProcessor
public GridResourceProcessor(GridKernalContext ctx)
Creates resources processor.- Parameters:
ctx- Kernal context.
-
-
Method Detail
-
start
public void start() throws IgniteCheckedExceptionStarts grid component.- Specified by:
startin interfaceGridComponent- Overrides:
startin classGridProcessorAdapter- Throws:
IgniteCheckedException- Throws in case of any errors.
-
onKernalStart
public void onKernalStart(boolean active) throws IgniteCheckedExceptionCallback that notifies that kernal has successfully started, including all managers and processors.- Specified by:
onKernalStartin interfaceGridComponent- Overrides:
onKernalStartin classGridProcessorAdapter- Parameters:
active- Cluster active flag (note: should be used carefully since state can change concurrently).- Throws:
IgniteCheckedException- Thrown in case of any errors.
-
stop
public void stop(boolean cancel)
Stops grid component.- Specified by:
stopin interfaceGridComponent- Overrides:
stopin classGridProcessorAdapter- Parameters:
cancel- Iftrue, then all ongoing tasks or jobs for relevant components need to be cancelled.
-
setSpringContext
public void setSpringContext(@Nullable @Nullable GridSpringResourceContext rsrcCtx)Sets Spring resource context.- Parameters:
rsrcCtx- Spring resource context.
-
onUndeployed
public void onUndeployed(GridDeployment dep)
Callback to be called when class loader is undeployed.- Parameters:
dep- Deployment to release resources for.
-
invokeAnnotated
public void invokeAnnotated(GridDeployment dep, Object target, Class<? extends Annotation> annCls) throws IgniteCheckedException
- Parameters:
dep- Deployment.target- Target object.annCls- Annotation class.- Throws:
IgniteCheckedException- If failed to execute annotated methods.
-
inject
public void inject(GridDeployment dep, Class<?> depCls, Object target) throws IgniteCheckedException
Injects resources into generic class.- Parameters:
dep- Deployment.depCls- Deployed class.target- Target instance to inject into.- Throws:
IgniteCheckedException- Thrown in case of any errors.
-
injectCacheName
public void injectCacheName(Object obj, String cacheName) throws IgniteCheckedException
Injects cache name into given object.- Parameters:
obj- Object.cacheName- Cache name to inject.- Throws:
IgniteCheckedException- If failed to inject.
-
injectStoreSession
public boolean injectStoreSession(Object obj, CacheStoreSession ses) throws IgniteCheckedException
Injects cache store session into given object.- Parameters:
obj- Object.ses- Session to inject.- Returns:
Trueif session was injected.- Throws:
IgniteCheckedException- If failed to inject.
-
injectGeneric
public void injectGeneric(Object obj) throws IgniteCheckedException
- Parameters:
obj- Object to inject.- Throws:
IgniteCheckedException- If failed to inject.
-
inject
public void inject(Object obj, GridResourceIoc.AnnotationSet annSet, Object... params) throws IgniteCheckedException
- Parameters:
obj- Object to inject.annSet- Supported annotations.params- Parameters.- Throws:
IgniteCheckedException- If failed to inject.
-
cleanupGeneric
public void cleanupGeneric(Object obj) throws IgniteCheckedException
- Parameters:
obj- Object.- Throws:
IgniteCheckedException- If failed.
-
inject
public void inject(GridDeployment dep, Class<?> taskCls, ComputeJob job, ComputeTaskSession ses, GridJobContextImpl jobCtx) throws IgniteCheckedException
Injects held resources into givenjob.- Parameters:
dep- Deployment.taskCls- Task class.job- Grid job to inject resources to.ses- Current task session.jobCtx- Job context.- Throws:
IgniteCheckedException- Thrown in case of any errors.
-
inject
public void inject(GridDeployment dep, ComputeTask<?,?> task, GridTaskSessionImpl ses, ComputeLoadBalancer balancer, ComputeTaskContinuousMapper mapper) throws IgniteCheckedException
Injects held resources into given grid task.- Parameters:
dep- Deployed class.task- Grid task.ses- Grid task session.balancer- Load balancer.mapper- Continuous task mapper.- Throws:
IgniteCheckedException- Thrown in case of any errors.
-
isAnnotationPresent
public boolean isAnnotationPresent(GridDeployment dep, Object target, Class<? extends Annotation> annCls)
Checks if annotation presents in specified object.- Parameters:
dep- Class deployment.target- Object to check.annCls- Annotation to find.- Returns:
trueif annotation is presented,falseotherwise.
-
isAnnotationsPresent
public boolean isAnnotationsPresent(GridDeployment dep, Object target, GridResourceIoc.AnnotationSet annSet)
Checks if annotations presents in specified object.- Parameters:
dep- Class deployment.target- Object to check.annSet- Annotations to find.- Returns:
trueif any annotation is presented,falseif it's not.
-
inject
public void inject(IgniteSpi spi) throws IgniteCheckedException
Injects held resources into given SPI implementation.- Parameters:
spi- SPI implementation.- Throws:
IgniteCheckedException- Throw in case of any errors.
-
cleanup
public void cleanup(IgniteSpi spi) throws IgniteCheckedException
Cleans up resources from given SPI implementation. Essentially, this method injectsnulls into SPI implementation.- Parameters:
spi- SPI implementation.- Throws:
IgniteCheckedException- Thrown in case of any errors.
-
inject
public void inject(LifecycleBean lifecycleBean) throws IgniteCheckedException
Injects held resources into given lifecycle bean.- Parameters:
lifecycleBean- Lifecycle bean.- Throws:
IgniteCheckedException- Thrown in case of any errors.
-
cleanup
public void cleanup(LifecycleBean lifecycleBean) throws IgniteCheckedException
Cleans up resources from given lifecycle beans. Essentially, this method injectsnulls into lifecycle bean.- Parameters:
lifecycleBean- Lifecycle bean.- Throws:
IgniteCheckedException- Thrown in case of any errors.
-
inject
public void inject(Service svc, ServiceContext svcCtx) throws IgniteCheckedException
Injects resources into service.- Parameters:
svc- Service to inject.svcCtx- Service context to be injected into the service.- Throws:
IgniteCheckedException- If failed.
-
cleanup
public void cleanup(Service svc) throws IgniteCheckedException
Cleans up resources from given service. Essentially, this method injectsnulls into service bean.- Parameters:
svc- Service.- Throws:
IgniteCheckedException- Thrown in case of any errors.
-
injectBasicResource
public void injectBasicResource(Object target, Class<? extends Annotation> annCls, Object rsrc) throws IgniteCheckedException
This method is declared public as it is used from tests as well. Note, that this method can be used only with unwrapped objects (seeunwrapTarget(Object)).- Parameters:
target- Target object.annCls- Setter annotation.rsrc- Resource to inject.- Throws:
IgniteCheckedException- If injection failed.
-
printMemoryStats
public void printMemoryStats()
Prints memory statistics (sizes of internal structures, etc.). NOTE: this method is for testing and profiling purposes only.- Specified by:
printMemoryStatsin interfaceGridComponent- Overrides:
printMemoryStatsin classGridProcessorAdapter
-
resolve
public <T> T resolve(T instance)
Delegates resource resolving to the provided dependency resolver, which wraps passed instance if necessary.- Parameters:
instance- Instance of delegated class.- Returns:
- Original instance or wrapped if wrapper exists.
-
-