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

ISPN-11845 SingleFileStore location validation should be skipped when global state is disabled #8335

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ public void validate() {

@Override
public void validate(GlobalConfiguration globalConfig) {
Attribute<String> location = attributes.attribute(LOCATION);
if (location.isNull() && !globalConfig.globalState().enabled()) {
throw Log.CONFIG.storeLocationRequired();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove this as the error will always be thrown on startup via PersistenceUtil#getLocation.

Copy link
Member Author

@pferraro pferraro May 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it not preferable to detect invalid configuration when the cache configuration is built, rather than fail (after several store startup attempts) when a cache is started?
In WF, this is equivalent to catching the error during a management operation vs failing to deploy an application.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it is. The correct way is to validate this in the builders, I was trying to save some repetition but this approach makes more sense. The SoftIndexFileStoreConfigurationBuilder will need to be updated to check that the DATA_LOCATION and INDEX_LOCATION in their respective builders are not null. As well the LOCATION and EXPIRATION_LOCATION in the RocksDBStoreConfigurationBuilder.

super.validate(globalConfig);
}

Expand Down
15 changes: 12 additions & 3 deletions core/src/main/java/org/infinispan/persistence/PersistenceUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.infinispan.commons.time.TimeService;
import org.infinispan.commons.util.IntSet;
import org.infinispan.configuration.global.GlobalConfiguration;
import org.infinispan.configuration.global.GlobalStateConfiguration;
import org.infinispan.container.DataContainer;
import org.infinispan.container.entries.InternalCacheEntry;
import org.infinispan.container.impl.InternalEntryFactory;
Expand Down Expand Up @@ -160,11 +161,19 @@ public static Path getQualifiedLocation(GlobalConfiguration globalConfiguration,
}

public static Path getLocation(GlobalConfiguration globalConfiguration, String location) {
Path persistentLocation = Paths.get(globalConfiguration.globalState().persistentLocation());
if (location == null)
return persistentLocation;
GlobalStateConfiguration globalState = globalConfiguration.globalState();
Path persistentLocation = Paths.get(globalState.persistentLocation());
if (location == null) {
if (!globalState.enabled()) {
throw PERSISTENCE.storeLocationRequired();
}
return persistentLocation;
}

Path path = Paths.get(location);
if (!globalState.enabled()) {
return path;
}
pferraro marked this conversation as resolved.
Show resolved Hide resolved
if (path.isAbsolute()) {
// Ensure that the path lives under the global persistent location
if (path.startsWith(persistentLocation)) {
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/java/org/infinispan/util/logging/Log.java
Original file line number Diff line number Diff line change
Expand Up @@ -2002,4 +2002,7 @@ TimeoutException coordinatorTimeoutWaitingForView(int expectedViewId, int curren

@Message(value = "A store cannot be configured with both preload and purgeOnStartup", id = 589)
CacheConfigurationException preloadAndPurgeOnStartupConflict();

@Message(value = "Store must specify a location when global state is disabled", id = 590)
CacheConfigurationException storeLocationRequired();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To allow for better validation of other store location attributes, we should also create an overloaded version of this message.

   @Message(value = "Store must specify the '%s' attribute when global state is disabled", id = 590)
   CacheConfigurationException storeLocationRequired(String attributeName);

}