Skip to content

Commit

Permalink
gh-2890 cache improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
GCHQDev404 committed Mar 2, 2023
1 parent 5d22bf1 commit f3f4384
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2022 Crown Copyright
* Copyright 2017-2023 Crown Copyright
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -39,7 +39,6 @@ public class FederatedStoreProperties extends StoreProperties {
*/
public static final String CUSTOM_PROPERTIES_AUTHS = "gaffer.federatedstore.customPropertiesAuths";
public static final String CUSTOM_PROPERTIES_AUTHS_DEFAULT = null;

public static final String CACHE_SERVICE_CLASS_DEFAULT = HashMapCacheService.class.getCanonicalName();
public static final String STORE_CONFIGURED_MERGE_FUNCTIONS = "gaffer.federatedstore.storeConfiguredMergeFunctions";
public static final String STORE_CONFIGURED_GRAPHIDS = "gaffer.federatedstore.storeConfiguredGraphIds";
Expand All @@ -64,10 +63,6 @@ public void setCustomPropertyAuths(final String auths) {
set(CUSTOM_PROPERTIES_AUTHS, auths);
}

public String getCacheServiceClass() {
return get(CACHE_SERVICE_CLASS, CACHE_SERVICE_CLASS_DEFAULT);
}

public String getCustomPropsValue() {
return this.get(CUSTOM_PROPERTIES_AUTHS, CUSTOM_PROPERTIES_AUTHS_DEFAULT);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
import uk.gov.gchq.gaffer.store.operation.handler.OperationHandler;
import uk.gov.gchq.gaffer.user.User;

import static java.util.Objects.isNull;
import static java.util.Objects.nonNull;
import static uk.gov.gchq.gaffer.federatedstore.FederatedStoreProperties.CACHE_SERVICE_CLASS_DEFAULT;
import static uk.gov.gchq.gaffer.store.StoreProperties.CACHE_SERVICE_CLASS;

/**
Expand Down Expand Up @@ -98,10 +100,11 @@ private void overwriteCacheProperty(final OP operation, final Store store) {
* FederatedStore can't survive if a subgraph changes the static
* cache to another cache, or re-initialises the cache.
*/
final String cacheServiceClass = isNull(store.getProperties()) ? null : store.getProperties().getCacheServiceClass(CACHE_SERVICE_CLASS_DEFAULT);
final StoreProperties storeProperties = operation.getStoreProperties();
if (nonNull(storeProperties) && storeProperties.containsKey(CACHE_SERVICE_CLASS)) {
LOGGER.info(String.format("%s is removing %s from properties of the operation and substituting the FederatedStore's cache", this.getClass().getSimpleName(), CACHE_SERVICE_CLASS));
storeProperties.setCacheServiceClass(store.getProperties().getCacheServiceClass());
if (nonNull(storeProperties) && !storeProperties.getCacheServiceClass(cacheServiceClass).equals(cacheServiceClass)) {
LOGGER.info(String.format("Removing %s from properties of the operation and substituting the FederatedStore's cache", CACHE_SERVICE_CLASS));
storeProperties.setCacheServiceClass(cacheServiceClass);
operation.setStoreProperties(storeProperties);
}
}
Expand Down

0 comments on commit f3f4384

Please sign in to comment.