Skip to content
This repository has been archived by the owner on Mar 27, 2021. It is now read-only.

Commit

Permalink
add Series getter for hashCode, modify write cache conditions, enhanc…
Browse files Browse the repository at this point in the history
…e test (#731)

* add Series getter for hashCode, modify write cache conditions, update tests

* eliminate dup code
  • Loading branch information
adsail authored Dec 18, 2020
1 parent 08a9405 commit 5f757f5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ public HashCode getHashCodeTagOnly() {
return hashCodeTagOnly;
}

@JsonIgnore
public HashCode getHashCode() {
return hashCode;
}

private HashCode generateHashTagOnly() {
final Hasher hasher = HASH_FUNCTION.newHasher();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public abstract class AbstractMetadataBackendIndexResourceIT {
);
protected final Series s3 = Series.of(
"s3",
ImmutableMap.of("role", "baz"),
ImmutableMap.of("role", "bar"),
ImmutableMap.of("podname", "foo-bar-789")
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,21 @@ public AsyncFuture<WriteMetadata> write(
try (Scope ignored = tracer.withSpan(span)) {
span.putAttribute("index", AttributeValue.stringAttributeValue(index));

if (!writeCache.acquire(Pair.of(index, series.getHashCodeTagOnly()),
HashCode hc =
indexResourceIdentifiers ?
series.getHashCode() :
series.getHashCodeTagOnly();

if (!writeCache.acquire(Pair.of(index, hc),
reporter::reportWriteDroppedByCacheHit)) {
span.setStatus(
Status.ALREADY_EXISTS.withDescription("Write dropped by cache hit"));
Status
.ALREADY_EXISTS
.withDescription("Write dropped by cache hit"));
span.end();
continue;
}

indexSpans.add(span);

final XContentBuilder source = XContentFactory.jsonBuilder();
Expand Down

0 comments on commit 5f757f5

Please sign in to comment.