phet commented on code in PR #3765:
URL: https://github.com/apache/gobblin/pull/3765#discussion_r1322264497


##########
gobblin-runtime/src/main/java/org/apache/gobblin/runtime/api/MysqlMultiActiveLeaseArbiterTestingDecorator.java:
##########
@@ -0,0 +1,206 @@
+package org.apache.gobblin.runtime.api;
+
+import com.google.common.base.Optional;
+import com.typesafe.config.Config;
+import java.io.IOException;
+import java.net.Inet6Address;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.HashMap;
+import javax.inject.Inject;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.gobblin.configuration.ConfigurationKeys;
+import org.apache.gobblin.util.ConfigUtils;
+import org.apache.gobblin.util.HostUtils;
+
+
+/**
+ * This class is a decorator for {@link MysqlMultiActiveLeaseArbiter} used to 
model scenarios where a lease owner fails
+ * to complete a lease intermittently (representing a variety of slowness or 
failure cases that can result on the
+ * participant side, network connectivity, or database).
+ *
+ * It will fail on calls to {@link 
MysqlMultiActiveLeaseArbiter.recordLeaseSuccess()} where a function of the lease
+ * obtained timestamp matches a bitmask of the host. Ideally, each participant 
should fail on different calls (with
+ * limited overlap if we want to test that). We use a deterministic method of 
failing some calls to complete a lease
+ * success with the following methodology. We take the binary representation 
of the lease obtained timestamp, scatter
+ * its bits through bit interleaving of the first and second halves of the 
binary representation to differentiate
+ * behavior of consecutive timestamps, and compare the last N digits 
(determined through config) to the bit mask of the
+ * host. If the bitwise AND comparison to the host bit mask equals the bitmask 
we fail the call.
+ */
+@Slf4j
+public class MysqlMultiActiveLeaseArbiterTestingDecorator extends 
MysqlMultiActiveLeaseArbiter {
+  private final int bitMaskLength;

Review Comment:
   thinking about it, I don't actually believe we need separately to store the 
length of the bitmask.  we can just take whatever value is passed in and use 
that; e.g.
   ```
   int bitmaskBits = config.readInt(...)
   ```



-- 
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