Deprecate read preference hedge options by jyemin · Pull Request #1655 · mongodb/mongo-java-driver
Expand Up
@@ -54,13 +54,15 @@ public abstract class TaggableReadPreference extends ReadPreference {
private final List<TagSet> tagSetList = new ArrayList<>(); private final Long maxStalenessMS; @SuppressWarnings("deprecation") private final ReadPreferenceHedgeOptions hedgeOptions;
TaggableReadPreference() { this.maxStalenessMS = null; this.hedgeOptions = null; }
@SuppressWarnings("deprecation") TaggableReadPreference(final List<TagSet> tagSetList, @Nullable final Long maxStaleness, final TimeUnit timeUnit, @Nullable final ReadPreferenceHedgeOptions hedgeOptions) { notNull("tagSetList", tagSetList); Expand All @@ -80,6 +82,7 @@ public abstract class TaggableReadPreference extends ReadPreference { @Override public abstract TaggableReadPreference withMaxStalenessMS(Long maxStalenessMS, TimeUnit timeUnit);
@Deprecated @Override public abstract TaggableReadPreference withHedgeOptions(ReadPreferenceHedgeOptions hedgeOptions);
Expand Down Expand Up @@ -146,7 +149,9 @@ public Long getMaxStaleness(final TimeUnit timeUnit) { * @return the hedge options * @mongodb.server.release 4.4 * @since 4.1 * @deprecated As of MongoDB 8.1, the server ignores the option and periodically logs a warning */ @Deprecated @Nullable public ReadPreferenceHedgeOptions getHedgeOptions() { return hedgeOptions; Expand Down Expand Up @@ -327,6 +332,7 @@ static class SecondaryReadPreference extends TaggableReadPreference { this(tagSetList, maxStaleness, timeUnit, null); }
@SuppressWarnings("deprecation") SecondaryReadPreference(final List<TagSet> tagSetList, @Nullable final Long maxStaleness, final TimeUnit timeUnit, @Nullable final ReadPreferenceHedgeOptions hedgeOptions) { super(tagSetList, maxStaleness, timeUnit, hedgeOptions); Expand All @@ -349,6 +355,7 @@ public TaggableReadPreference withMaxStalenessMS(@Nullable final Long maxStalene return new SecondaryReadPreference(getTagSetList(), maxStaleness, timeUnit, getHedgeOptions()); }
@Deprecated @Override public TaggableReadPreference withHedgeOptions(final ReadPreferenceHedgeOptions hedgeOptions) { return new SecondaryReadPreference(getTagSetList(), getMaxStaleness(MILLISECONDS), MILLISECONDS, hedgeOptions); Expand Down Expand Up @@ -388,6 +395,7 @@ static class SecondaryPreferredReadPreference extends SecondaryReadPreference { this(tagSetList, maxStaleness, timeUnit, null); }
@SuppressWarnings("deprecation") SecondaryPreferredReadPreference(final List<TagSet> tagSetList, @Nullable final Long maxStaleness, final TimeUnit timeUnit, @Nullable final ReadPreferenceHedgeOptions hedgeOptions) { super(tagSetList, maxStaleness, timeUnit, hedgeOptions); Expand All @@ -410,6 +418,7 @@ public TaggableReadPreference withMaxStalenessMS(@Nullable final Long maxStalene return new SecondaryPreferredReadPreference(getTagSetList(), maxStaleness, timeUnit, getHedgeOptions()); }
@Deprecated @Override public TaggableReadPreference withHedgeOptions(final ReadPreferenceHedgeOptions hedgeOptions) { return new SecondaryPreferredReadPreference(getTagSetList(), getMaxStaleness(MILLISECONDS), MILLISECONDS, hedgeOptions); Expand Down Expand Up @@ -441,6 +450,7 @@ static class NearestReadPreference extends TaggableReadPreference { this(tagSetList, maxStaleness, timeUnit, null); }
@SuppressWarnings("deprecation") NearestReadPreference(final List<TagSet> tagSetList, @Nullable final Long maxStaleness, final TimeUnit timeUnit, @Nullable final ReadPreferenceHedgeOptions hedgeOptions) { super(tagSetList, maxStaleness, timeUnit, hedgeOptions); Expand All @@ -463,6 +473,7 @@ public TaggableReadPreference withMaxStalenessMS(@Nullable final Long maxStalene return new NearestReadPreference(getTagSetList(), maxStaleness, timeUnit, getHedgeOptions()); }
@Deprecated @Override public TaggableReadPreference withHedgeOptions(final ReadPreferenceHedgeOptions hedgeOptions) { return new NearestReadPreference(getTagSetList(), getMaxStaleness(MILLISECONDS), MILLISECONDS, hedgeOptions); Expand Down Expand Up @@ -503,6 +514,7 @@ static class PrimaryPreferredReadPreference extends SecondaryReadPreference { this(tagSetList, maxStaleness, timeUnit, null); }
@SuppressWarnings("deprecation") PrimaryPreferredReadPreference(final List<TagSet> tagSetList, @Nullable final Long maxStaleness, final TimeUnit timeUnit, @Nullable final ReadPreferenceHedgeOptions hedgeOptions) { super(tagSetList, maxStaleness, timeUnit, hedgeOptions); Expand All @@ -525,6 +537,7 @@ public TaggableReadPreference withMaxStalenessMS(@Nullable final Long maxStalene return new PrimaryPreferredReadPreference(getTagSetList(), maxStaleness, timeUnit, getHedgeOptions()); }
@Deprecated @Override public TaggableReadPreference withHedgeOptions(final ReadPreferenceHedgeOptions hedgeOptions) { return new PrimaryPreferredReadPreference(getTagSetList(), getMaxStaleness(MILLISECONDS), MILLISECONDS, hedgeOptions); Expand Down
private final List<TagSet> tagSetList = new ArrayList<>(); private final Long maxStalenessMS; @SuppressWarnings("deprecation") private final ReadPreferenceHedgeOptions hedgeOptions;
TaggableReadPreference() { this.maxStalenessMS = null; this.hedgeOptions = null; }
@SuppressWarnings("deprecation") TaggableReadPreference(final List<TagSet> tagSetList, @Nullable final Long maxStaleness, final TimeUnit timeUnit, @Nullable final ReadPreferenceHedgeOptions hedgeOptions) { notNull("tagSetList", tagSetList); Expand All @@ -80,6 +82,7 @@ public abstract class TaggableReadPreference extends ReadPreference { @Override public abstract TaggableReadPreference withMaxStalenessMS(Long maxStalenessMS, TimeUnit timeUnit);
@Deprecated @Override public abstract TaggableReadPreference withHedgeOptions(ReadPreferenceHedgeOptions hedgeOptions);
Expand Down Expand Up @@ -146,7 +149,9 @@ public Long getMaxStaleness(final TimeUnit timeUnit) { * @return the hedge options * @mongodb.server.release 4.4 * @since 4.1 * @deprecated As of MongoDB 8.1, the server ignores the option and periodically logs a warning */ @Deprecated @Nullable public ReadPreferenceHedgeOptions getHedgeOptions() { return hedgeOptions; Expand Down Expand Up @@ -327,6 +332,7 @@ static class SecondaryReadPreference extends TaggableReadPreference { this(tagSetList, maxStaleness, timeUnit, null); }
@SuppressWarnings("deprecation") SecondaryReadPreference(final List<TagSet> tagSetList, @Nullable final Long maxStaleness, final TimeUnit timeUnit, @Nullable final ReadPreferenceHedgeOptions hedgeOptions) { super(tagSetList, maxStaleness, timeUnit, hedgeOptions); Expand All @@ -349,6 +355,7 @@ public TaggableReadPreference withMaxStalenessMS(@Nullable final Long maxStalene return new SecondaryReadPreference(getTagSetList(), maxStaleness, timeUnit, getHedgeOptions()); }
@Deprecated @Override public TaggableReadPreference withHedgeOptions(final ReadPreferenceHedgeOptions hedgeOptions) { return new SecondaryReadPreference(getTagSetList(), getMaxStaleness(MILLISECONDS), MILLISECONDS, hedgeOptions); Expand Down Expand Up @@ -388,6 +395,7 @@ static class SecondaryPreferredReadPreference extends SecondaryReadPreference { this(tagSetList, maxStaleness, timeUnit, null); }
@SuppressWarnings("deprecation") SecondaryPreferredReadPreference(final List<TagSet> tagSetList, @Nullable final Long maxStaleness, final TimeUnit timeUnit, @Nullable final ReadPreferenceHedgeOptions hedgeOptions) { super(tagSetList, maxStaleness, timeUnit, hedgeOptions); Expand All @@ -410,6 +418,7 @@ public TaggableReadPreference withMaxStalenessMS(@Nullable final Long maxStalene return new SecondaryPreferredReadPreference(getTagSetList(), maxStaleness, timeUnit, getHedgeOptions()); }
@Deprecated @Override public TaggableReadPreference withHedgeOptions(final ReadPreferenceHedgeOptions hedgeOptions) { return new SecondaryPreferredReadPreference(getTagSetList(), getMaxStaleness(MILLISECONDS), MILLISECONDS, hedgeOptions); Expand Down Expand Up @@ -441,6 +450,7 @@ static class NearestReadPreference extends TaggableReadPreference { this(tagSetList, maxStaleness, timeUnit, null); }
@SuppressWarnings("deprecation") NearestReadPreference(final List<TagSet> tagSetList, @Nullable final Long maxStaleness, final TimeUnit timeUnit, @Nullable final ReadPreferenceHedgeOptions hedgeOptions) { super(tagSetList, maxStaleness, timeUnit, hedgeOptions); Expand All @@ -463,6 +473,7 @@ public TaggableReadPreference withMaxStalenessMS(@Nullable final Long maxStalene return new NearestReadPreference(getTagSetList(), maxStaleness, timeUnit, getHedgeOptions()); }
@Deprecated @Override public TaggableReadPreference withHedgeOptions(final ReadPreferenceHedgeOptions hedgeOptions) { return new NearestReadPreference(getTagSetList(), getMaxStaleness(MILLISECONDS), MILLISECONDS, hedgeOptions); Expand Down Expand Up @@ -503,6 +514,7 @@ static class PrimaryPreferredReadPreference extends SecondaryReadPreference { this(tagSetList, maxStaleness, timeUnit, null); }
@SuppressWarnings("deprecation") PrimaryPreferredReadPreference(final List<TagSet> tagSetList, @Nullable final Long maxStaleness, final TimeUnit timeUnit, @Nullable final ReadPreferenceHedgeOptions hedgeOptions) { super(tagSetList, maxStaleness, timeUnit, hedgeOptions); Expand All @@ -525,6 +537,7 @@ public TaggableReadPreference withMaxStalenessMS(@Nullable final Long maxStalene return new PrimaryPreferredReadPreference(getTagSetList(), maxStaleness, timeUnit, getHedgeOptions()); }
@Deprecated @Override public TaggableReadPreference withHedgeOptions(final ReadPreferenceHedgeOptions hedgeOptions) { return new PrimaryPreferredReadPreference(getTagSetList(), getMaxStaleness(MILLISECONDS), MILLISECONDS, hedgeOptions); Expand Down