Skip to content

Commit

Permalink
gh-2457 double caching issue (#2595)
Browse files Browse the repository at this point in the history

* gh-2457-double-caching-issue weak initial step, requires synchronisation with FederatedGraphStorage and further testing.

* gh-2457-double-caching-issue remove FederatedGraphStorage local map, using cache only.

* gh-2457-double-caching-issue remove FederatedGraphStorage test fixes

* gh-2457-double-caching-issue remove FederatedGraphStorage review.

* gh-2457-double-caching-removing-graphstorage minimising use of GraphSerialisable.getGraph()

* gh-2457-double-caching-removing-graphstorage gh-2478 JobTracker cache can have Suffix name.

* gh-2457 double caching issue fix for persisting graph names in tests.

* Merge remote-tracking branch 'origin/v2-alpha' into gh-2357-federatedstore-federated-operation-merge-alpha2
!!!With 1 failing class of Tests!!!

* gh-2457 GraphSerialisable not being able to Mock has failing tests. changing GraphSerialisable causes backwards compatability issues.

* gh-2457 Fixed GraphSerialisable equals.

* gh-2457 checkstyle

* gh-2457 PR requests.

* gh-2457 PR requests.

* gh-2457 PR requests.
  • Loading branch information
GCHQDev404 authored Nov 2, 2022
1 parent cb73779 commit 3ee6a5f
Show file tree
Hide file tree
Showing 37 changed files with 761 additions and 600 deletions.
16 changes: 13 additions & 3 deletions core/cache/src/main/java/uk/gov/gchq/gaffer/cache/Cache.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018-2020 Crown Copyright
* Copyright 2018-2022 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 All @@ -17,6 +17,7 @@
package uk.gov.gchq.gaffer.cache;

import uk.gov.gchq.gaffer.cache.exception.CacheOperationException;
import uk.gov.gchq.gaffer.core.exception.GafferRuntimeException;

import java.util.Collections;
import java.util.Set;
Expand Down Expand Up @@ -55,8 +56,17 @@ protected void addToCache(final String key, final V value, final boolean overwri
}

public Set<String> getAllKeys() {
final Set<String> allKeysFromCache = CacheServiceLoader.getService().getAllKeysFromCache(cacheName);
return (null == allKeysFromCache) ? null : Collections.unmodifiableSet(allKeysFromCache);
try {
final Set<String> allKeysFromCache;
if (CacheServiceLoader.isEnabled()) {
allKeysFromCache = CacheServiceLoader.getService().getAllKeysFromCache(cacheName);
} else {
throw new GafferRuntimeException("Cache is not enabled, check it was Initialised");
}
return (null == allKeysFromCache) ? null : Collections.unmodifiableSet(allKeysFromCache);
} catch (final Exception e) {
throw new GafferRuntimeException("Error getting all keys", e);
}
}

/**
Expand Down
30 changes: 28 additions & 2 deletions core/graph/src/main/java/uk/gov/gchq/gaffer/graph/Graph.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

import com.google.common.collect.Lists;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -447,8 +449,7 @@ public String getDescription() {
* Returns all the {@link StoreTrait}s for the contained {@link Store}
* implementation
*
* @return a {@link Set} of all of the {@link StoreTrait}s that the store
* has.
* @return a {@link Set} of all of the {@link StoreTrait}s that the store has.
*/
@Deprecated
public Set<StoreTrait> getStoreTraits() {
Expand Down Expand Up @@ -975,4 +976,29 @@ private Schema cloneSchema(final Schema schema) {
return null != schema ? schema.clone() : null;
}
}

@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}

if (o == null || getClass() != o.getClass()) {
return false;
}

final Graph graph = (Graph) o;

return new EqualsBuilder()
.append(new GraphSerialisable.Builder(this).build(), new GraphSerialisable.Builder(graph).build())
.isEquals();
}

@Override
public int hashCode() {
return new HashCodeBuilder(17, 37)
.append(store)
.append(config)
.toHashCode();
}
}
Loading

0 comments on commit 3ee6a5f

Please sign in to comment.