damondouglas commented on code in PR #28952:
URL: https://github.com/apache/beam/pull/28952#discussion_r1361242160


##########
sdks/java/io/rrio/src/main/java/org/apache/beam/io/requestresponseio/CallShouldBackoffBasedOnRejectionProbability.java:
##########
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.io.requestresponseio;
+
+import org.checkerframework.checker.nullness.qual.Nullable;
+
+/** Reports whether to apply backoff based on 
https://sre.google/sre-book/handling-overload/. */
+class CallShouldBackoffBasedOnRejectionProbability<ResponseT>
+    implements CallShouldBackoff<ResponseT> {
+
+  // Default multiplier value recommended by 
https://sre.google/sre-book/handling-overload/
+  private static final double DEFAULT_MULTIPLIER = 2.0;
+
+  // The threshold is the value that pReject() must exceed in order to report 
a value() of true. If
+  // null, then the computation relies on a random value.
+  private @Nullable Double threshold;
+
+  // The multiplier drives the impact of accepts on the rejection probability. 
See <a
+  // https://sre.google/sre-book/handling-overload/ for details.
+  private final double multiplier;
+
+  // The number of total requests called to a remote API.
+  private double requests = 0;
+
+  // The number of total accepts called to a remote API.
+  private double accepts = 0;
+
+  /** Instantiate class with the {@link #DEFAULT_MULTIPLIER}. */
+  CallShouldBackoffBasedOnRejectionProbability() {

Review Comment:
   The class and everything in it is at most package private.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to