17
17
18
18
package org .apache .ignite .internal .configuration .utils ;
19
19
20
- import java .util .concurrent .CompletableFuture ;
21
- import java .util .concurrent .atomic .AtomicReference ;
22
- import java .util .function .BiConsumer ;
20
+ import static org .apache .ignite .internal .util .CompletableFutures .nullCompletedFuture ;
21
+
23
22
import java .util .function .Function ;
23
+ import java .util .function .ObjLongConsumer ;
24
24
import org .apache .ignite .internal .configuration .SystemDistributedConfiguration ;
25
25
import org .apache .ignite .internal .configuration .SystemDistributedView ;
26
26
import org .apache .ignite .internal .configuration .SystemPropertyView ;
@@ -37,10 +37,10 @@ public class SystemDistributedConfigurationPropertyHolder<T> {
37
37
private final SystemDistributedConfiguration systemDistributedConfig ;
38
38
39
39
/** Current value of target system distributed configuration property. */
40
- private final AtomicReference < T > currentValue = new AtomicReference <>() ;
40
+ private volatile T currentValue ;
41
41
42
42
/** Listener, which receives (newValue, revision) on every configuration update. */
43
- private final BiConsumer < T , Long > valueListener ;
43
+ private final ObjLongConsumer < T > valueListener ;
44
44
45
45
/** Converter to translate {@link String} representation of property value to target type. */
46
46
private final Function <String , T > propertyConverter ;
@@ -56,7 +56,7 @@ public class SystemDistributedConfigurationPropertyHolder<T> {
56
56
*/
57
57
public SystemDistributedConfigurationPropertyHolder (
58
58
SystemDistributedConfiguration systemDistributedConfig ,
59
- BiConsumer < T , Long > valueListener ,
59
+ ObjLongConsumer < T > valueListener ,
60
60
String propertyName ,
61
61
T defaultValue ,
62
62
Function <String , T > propertyConverter
@@ -70,7 +70,7 @@ public SystemDistributedConfigurationPropertyHolder(
70
70
systemDistributedConfig .listen (ctx -> {
71
71
updateSystemProperties (ctx .newValue (), ctx .storageRevision ());
72
72
73
- return CompletableFuture . completedFuture ( null );
73
+ return nullCompletedFuture ( );
74
74
});
75
75
}
76
76
@@ -89,7 +89,7 @@ public void init() {
89
89
* @return Current value.
90
90
*/
91
91
public T currentValue () {
92
- return currentValue . get () ;
92
+ return currentValue ;
93
93
}
94
94
95
95
/**
@@ -103,7 +103,7 @@ private void updateSystemProperties(SystemDistributedView view, long revision) {
103
103
104
104
T value = (systemPropertyView == null ) ? defaultValue : propertyConverter .apply (systemPropertyView .propertyValue ());
105
105
106
- currentValue . set ( value ) ;
106
+ currentValue = value ;
107
107
108
108
if (revision != -1 ) {
109
109
valueListener .accept (value , revision );
0 commit comments