Class DistributedEnumProperty<T extends Enum>
- java.lang.Object
-
- org.apache.ignite.internal.processors.configuration.distributed.DistributedEnumProperty<T>
-
- Type Parameters:
T- Type of enum.
- All Implemented Interfaces:
DistributedChangeableProperty<T>,DistributedProperty<T>
public class DistributedEnumProperty<T extends Enum> extends Object implements DistributedChangeableProperty<T>
Distributed enum implementation for storing into meta storage. The implementation will serialize by its integer ordinal.
-
-
Constructor Summary
Constructors Constructor Description DistributedEnumProperty(String name, String desc, IgniteClosure<Integer,T> fromOrdinalFunc, IgniteClosure<T,Integer> toOrdinalFunc, Class<T> enumCls)Property constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(DistributePropertyListener<? super T> listener)Stringdescription()Tget()StringgetName()TgetOrDefault(T dfltVal)voidlocalUpdate(Serializable newVal)Update only local value without updating remote cluster.voidonAttached()This property have been attached to processor.voidonReadyForUpdate(@NotNull PropertyUpdateClosure updater)On this property ready to be update on cluster wide.Tparse(String str)booleanpropagate(T newVal)Change value across whole cluster.GridFutureAdapter<?>propagateAsync(T newVal)Change value across whole cluster.GridFutureAdapter<?>propagateAsync(T expectedVal, T newVal)Change value across whole cluster.StringtoString()
-
-
-
Constructor Detail
-
DistributedEnumProperty
public DistributedEnumProperty(String name, String desc, IgniteClosure<Integer,T> fromOrdinalFunc, IgniteClosure<T,Integer> toOrdinalFunc, Class<T> enumCls)
Property constructor.- Parameters:
name- Name of property.desc- Property description.fromOrdinalFunc- Function reflects an integer to an enumiration value.toOrdinalFunc- Function converts an enumeration value to an integer.
-
-
Method Detail
-
onAttached
public void onAttached()
This property have been attached to processor.- Specified by:
onAttachedin interfaceDistributedChangeableProperty<T extends Enum>
-
onReadyForUpdate
public void onReadyForUpdate(@NotNull @NotNull PropertyUpdateClosure updater)On this property ready to be update on cluster wide.- Specified by:
onReadyForUpdatein interfaceDistributedChangeableProperty<T extends Enum>- Parameters:
updater- Consumer for update value across cluster.
-
localUpdate
public void localUpdate(Serializable newVal)
Update only local value without updating remote cluster.- Specified by:
localUpdatein interfaceDistributedChangeableProperty<T extends Enum>- Parameters:
newVal- New value.
-
propagate
public boolean propagate(T newVal) throws IgniteCheckedException
Change value across whole cluster.- Specified by:
propagatein interfaceDistributedProperty<T extends Enum>- Parameters:
newVal- Value which this property should be changed on.- Returns:
trueif value was successfully updated andfalseif cluster wide update was failed, perhaps some concurrent operation was changed this value in same moment.- Throws:
DetachedPropertyException- If this property have not been attached to processor yet, please callDistributedConfigurationProcessor.registerProperty(DistributedChangeableProperty)before this method.NotWritablePropertyException- If this property don't ready to cluster wide update yet, perhaps cluster is not active yet.IgniteCheckedException- If failed during cluster wide update.
-
propagateAsync
public GridFutureAdapter<?> propagateAsync(T newVal) throws IgniteCheckedException
Change value across whole cluster.- Specified by:
propagateAsyncin interfaceDistributedProperty<T extends Enum>- Parameters:
newVal- Value which this property should be changed on.- Returns:
- Future for update operation.
- Throws:
DetachedPropertyException- If this property have not been attached to processor yet, please callDistributedConfigurationProcessor.registerProperty(DistributedChangeableProperty)before this method.NotWritablePropertyException- If this property don't ready to cluster wide update yet, perhaps cluster is not active yet.IgniteCheckedException- If failed during cluster wide update.
-
propagateAsync
public GridFutureAdapter<?> propagateAsync(T expectedVal, T newVal) throws IgniteCheckedException
Change value across whole cluster.- Specified by:
propagateAsyncin interfaceDistributedProperty<T extends Enum>- Parameters:
expectedVal- Value from which this property should be changed.newVal- Value which this property should be changed on.- Returns:
- Future for update operation.
- Throws:
DetachedPropertyException- If this property have not been attached to processor yet, please callDistributedConfigurationProcessor.registerProperty(DistributedChangeableProperty)before this method.NotWritablePropertyException- If this property don't ready to cluster wide update yet, perhaps cluster is not active yet.IgniteCheckedException- If failed during cluster wide update.
-
get
public T get()
- Specified by:
getin interfaceDistributedProperty<T extends Enum>- Returns:
- Current property value.
-
getOrDefault
public T getOrDefault(T dfltVal)
- Specified by:
getOrDefaultin interfaceDistributedProperty<T extends Enum>- Parameters:
dfltVal- Default value when current value is null.- Returns:
- Current property value.
-
getName
public String getName()
- Specified by:
getNamein interfaceDistributedProperty<T extends Enum>- Returns:
- Name of property.
-
description
public String description()
- Specified by:
descriptionin interfaceDistributedProperty<T extends Enum>- Returns:
- Property description.
-
addListener
public void addListener(DistributePropertyListener<? super T> listener)
- Specified by:
addListenerin interfaceDistributedProperty<T extends Enum>- Parameters:
listener- Update listener.
-
parse
public T parse(String str)
- Specified by:
parsein interfaceDistributedChangeableProperty<T extends Enum>- Parameters:
str- String representation of the property value.- Returns:
- Property value.
-
-