dcapwell commented on code in PR #2299:
URL: https://github.com/apache/cassandra/pull/2299#discussion_r1179739164


##########
test/simulator/main/org/apache/cassandra/simulator/ClusterSimulation.java:
##########
@@ -618,9 +615,17 @@ public ClusterSimulation(RandomSource random, long seed, 
int uniqueNum,
                              SimulationFactory<S> factory) throws IOException
     {
         this.random = random;
-        this.jimfs  = Jimfs.newFileSystem(Long.toHexString(seed) + 'x' + 
uniqueNum, Configuration.unix().toBuilder()
-                                                                               
.setMaxSize(4L << 30).setBlockSize(512)
-                                                                               
.build());
+        this.jimfs  = new 
ListenableFileSystem(Jimfs.newFileSystem(Long.toHexString(seed) + 'x' + 
uniqueNum, Configuration.unix().toBuilder()
+                                                                               
                                           .setMaxSize(4L << 
30).setBlockSize(512)
+                                                                               
                                           .build()));
+        jimfs.listen((ListenableFileSystem.OnRead) (path, channel, position, 
dst, read) -> {
+            if (read > 0 && path.getFileName().toString().endsWith("Index.db") 
&& random.decide(.05f))
+            {
+                int offset = random.uniform(0, read);
+                int index = dst.position() - offset;
+                dst.put(index, (byte) (dst.get(index) + 1));
+            }
+        });

Review Comment:
   this will go away, I was using it to test this specific case... in reviewing 
Index.db code I saw we didn't validate it, so figured it would be easy to test 
corruption real quick... this listener does what I wanted and corrupts 5% of 
`FileChannel.read` on `Index.db`... (map is backed by `.read`, so will also 
trigger)



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to