Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IGNITE-24187 Fix code style issues in SystemDistributedConfigurationPropertyHolder #5027

Merged
merged 3 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions modules/configuration-system/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ dependencies {

implementation project(':ignite-configuration-api')
implementation project(':ignite-configuration-root')
implementation project(':ignite-core')
implementation libs.auto.service.annotations

testImplementation(testFixtures(project(':ignite-core')))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

package org.apache.ignite.internal.configuration.utils;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.BiConsumer;
import static org.apache.ignite.internal.util.CompletableFutures.nullCompletedFuture;

import java.util.function.Function;
import java.util.function.ObjLongConsumer;
import org.apache.ignite.internal.configuration.SystemDistributedConfiguration;
import org.apache.ignite.internal.configuration.SystemDistributedView;
import org.apache.ignite.internal.configuration.SystemPropertyView;
Expand All @@ -37,10 +37,10 @@ public class SystemDistributedConfigurationPropertyHolder<T> {
private final SystemDistributedConfiguration systemDistributedConfig;

/** Current value of target system distributed configuration property. */
private final AtomicReference<T> currentValue = new AtomicReference<>();
private volatile T currentValue;

/** Listener, which receives (newValue, revision) on every configuration update. */
private final BiConsumer<T, Long> valueListener;
private final ObjLongConsumer<T> valueListener;

/** Converter to translate {@link String} representation of property value to target type. */
private final Function<String, T> propertyConverter;
Expand All @@ -56,7 +56,7 @@ public class SystemDistributedConfigurationPropertyHolder<T> {
*/
public SystemDistributedConfigurationPropertyHolder(
SystemDistributedConfiguration systemDistributedConfig,
BiConsumer<T, Long> valueListener,
ObjLongConsumer<T> valueListener,
String propertyName,
T defaultValue,
Function<String, T> propertyConverter
Expand All @@ -70,7 +70,7 @@ public SystemDistributedConfigurationPropertyHolder(
systemDistributedConfig.listen(ctx -> {
updateSystemProperties(ctx.newValue(), ctx.storageRevision());

return CompletableFuture.completedFuture(null);
return nullCompletedFuture();
});
}

Expand All @@ -89,7 +89,7 @@ public void init() {
* @return Current value.
*/
public T currentValue() {
return currentValue.get();
return currentValue;
}

/**
Expand All @@ -103,7 +103,7 @@ private void updateSystemProperties(SystemDistributedView view, long revision) {

T value = (systemPropertyView == null) ? defaultValue : propertyConverter.apply(systemPropertyView.propertyValue());

currentValue.set(value);
currentValue = value;

if (revision != -1) {
valueListener.accept(value, revision);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.BiConsumer;
import java.util.function.Function;
import java.util.function.ObjLongConsumer;
import org.apache.ignite.internal.configuration.SystemDistributedConfiguration;
import org.apache.ignite.internal.configuration.testframework.ConfigurationExtension;
import org.apache.ignite.internal.configuration.testframework.InjectConfiguration;
Expand All @@ -42,7 +42,7 @@ public class SystemDistributedConfigurationPropertyHolderTest extends BaseIgnite

private static final String DEFAULT_VALUE = "defaultValue";

private static final BiConsumer<String, Long> noOpConsumer = (value, revision) -> {};
private static final ObjLongConsumer<String> noOpConsumer = (value, revision) -> {};

@Test
void testEmptySystemProperties(@InjectConfiguration SystemDistributedConfiguration systemConfig) {
Expand Down