[ 
https://issues.apache.org/jira/browse/HDDS-1782?focusedWorklogId=281511&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-281511
 ]

ASF GitHub Bot logged work on HDDS-1782:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 24/Jul/19 04:28
            Start Date: 24/Jul/19 04:28
    Worklog Time Spent: 10m 
      Work Description: arp7 commented on pull request #1076: HDDS-1782. Add an 
option to MiniOzoneChaosCluster to read files multiple times. Contributed by 
Mukul Kumar Singh.
URL: https://github.com/apache/hadoop/pull/1076#discussion_r306617142
 
 

 ##########
 File path: 
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/chaos/TestProbability.java
 ##########
 @@ -0,0 +1,43 @@
+/**
+ * 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.hadoop.ozone.chaos;
+
+import com.google.common.base.Preconditions;
+import org.apache.commons.lang3.RandomUtils;
+
+/**
+ * This class is used to find out if a certain event is true.
+ * Every event is assigned a propbability and the isTrue function returns true
+ * when the probability has been met.
+ */
+final public class TestProbability {
+  private int pct;
+
+  private TestProbability(int pct) {
+    Preconditions.checkArgument(pct <= 100 && pct > 0);
+    this.pct = pct;
+  }
+
+  public boolean isTrue() {
+    return (RandomUtils.nextInt() % (100 / pct)) == 0;
 
 Review comment:
   Lets replace this with `return RandomUtils.nextInt(100) < pct`
 
----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 281511)
    Time Spent: 2h 10m  (was: 2h)

> Add an option to MiniOzoneChaosCluster to read files multiple times.
> --------------------------------------------------------------------
>
>                 Key: HDDS-1782
>                 URL: https://issues.apache.org/jira/browse/HDDS-1782
>             Project: Hadoop Distributed Data Store
>          Issue Type: Bug
>          Components: test
>    Affects Versions: 0.4.0
>            Reporter: Mukul Kumar Singh
>            Assignee: Mukul Kumar Singh
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 2h 10m
>  Remaining Estimate: 0h
>
> Right now MiniOzoneChaosCluster writes a file/ reads it and deletes it 
> immediately. This jira proposes to add an option to read the file multiple 
> time in MiniOzoneChaosCluster.



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)

---------------------------------------------------------------------
To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org

Reply via email to