-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
start using signer for bulkdata access in non static mode
- Loading branch information
1 parent
6bd58a7
commit 4810852
Showing
7 changed files
with
177 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...main/java/com/netflix/hollow/test/consumer/TestBlobRetrieverWithNearestSnapshotMatch.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.netflix.hollow.test.consumer; | ||
|
||
import com.netflix.hollow.api.consumer.HollowConsumer; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class TestBlobRetrieverWithNearestSnapshotMatch extends TestBlobRetriever { | ||
|
||
@Override | ||
public HollowConsumer.Blob retrieveSnapshotBlob(long desiredVersion) { | ||
long version = findNearestSnapshotVersion(desiredVersion); | ||
HollowConsumer.Blob b = snapshots.get(version); | ||
resetStream(b); | ||
return b; | ||
} | ||
|
||
|
||
private long findNearestSnapshotVersion(long desiredVersion) { | ||
List<Long> snapshotVersions = new ArrayList<>(); | ||
snapshotVersions.addAll(snapshots.keySet()); | ||
Collections.sort(snapshotVersions); | ||
int start = 0; | ||
int end = snapshotVersions.size() - 1; | ||
int mid = 0; | ||
while (start + 1< end) { | ||
mid = (start + end) / 2; | ||
if (mid < desiredVersion) { | ||
start = mid; | ||
} else if (mid > desiredVersion){ | ||
end = mid; | ||
} else { | ||
return snapshotVersions.get(mid); | ||
} | ||
} | ||
if (end <= desiredVersion) { | ||
return snapshotVersions.get(end); | ||
} | ||
return snapshotVersions.get(start); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
hollow/src/main/java/com/netflix/hollow/api/error/VersionMismatchException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.netflix.hollow.api.error; | ||
|
||
public class VersionMismatchException extends HollowException { | ||
private final long expectedVersion; | ||
|
||
private final long actualVersion; | ||
|
||
public VersionMismatchException(long expectedVersion, long actualVersion) { | ||
super("toVersion in blob did not match toVersion requested in transition; actualToVersion=" + actualVersion + ", expectedToVersion=" + expectedVersion); | ||
this.expectedVersion = expectedVersion; | ||
this.actualVersion = actualVersion; | ||
} | ||
|
||
public long getExpectedVersion() { | ||
return expectedVersion; | ||
} | ||
|
||
public long getActualVersion() { | ||
return actualVersion; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.