Skip to content

Commit

Permalink
TEZ-4289: Remove Dependency on commons-math (apache#110)
Browse files Browse the repository at this point in the history
* TEZ-4289: Remove Dependency on commons-math

* Remove stray reference to commons-math

* Fix checkstyle and missing parenthesis
  • Loading branch information
belugabehr committed Feb 17, 2021
1 parent 3089d47 commit 70623f0
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 18 deletions.
5 changes: 0 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -668,11 +668,6 @@
<artifactId>commons-collections4</artifactId>
<version>4.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
<version>3.1.1</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import com.google.common.base.Strings;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.math3.util.Precision;
import org.apache.tez.common.JavaOptsChecker;
import org.apache.tez.dag.api.records.DAGProtos.AMPluginDescriptorProto;
import org.apache.tez.serviceplugins.api.ServicePluginsDescriptor;
Expand Down Expand Up @@ -1007,11 +1006,11 @@ public static String maybeAddDefaultMemoryJavaOpts(String javaOpts, Resource res
return javaOpts;
}

if ((maxHeapFactor <= 0 && !Precision.equals(maxHeapFactor, -1, 0.01)) || maxHeapFactor >= 1) {
if ((maxHeapFactor <= 0 && Double.valueOf("-1") != maxHeapFactor) || maxHeapFactor >= 1) {
return javaOpts;
}

if (Precision.equals(maxHeapFactor, -1, 0.01)) {
if (Double.valueOf("-1") == maxHeapFactor) {
maxHeapFactor = resource.getMemory() < TezConstants.TEZ_CONTAINER_SMALL_SLAB_BOUND_MB
? TezConstants.TEZ_CONTAINER_MAX_JAVA_HEAP_FRACTION_SMALL_SLAB
: TezConstants.TEZ_CONTAINER_MAX_JAVA_HEAP_FRACTION_LARGE_SLAB;
Expand Down
4 changes: 0 additions & 4 deletions tez-dag/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-yarn-server-web-proxy</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.apache.tez.common.Preconditions;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.apache.commons.lang.mutable.MutableInt;
import org.apache.commons.math3.random.RandomDataGenerator;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.util.StringUtils;
import org.apache.hadoop.util.Time;
Expand Down Expand Up @@ -80,6 +79,7 @@
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit;

/**
Expand All @@ -95,7 +95,6 @@ public class DagAwareYarnTaskScheduler extends TaskScheduler
private static final Logger LOG = LoggerFactory.getLogger(DagAwareYarnTaskScheduler.class);
private static final Comparator<HeldContainer> PREEMPT_ORDER_COMPARATOR = new PreemptOrderComparator();

private final RandomDataGenerator random = new RandomDataGenerator();
private AMRMClientAsyncWrapper client;
private ScheduledExecutorService reuseExecutor;
private ResourceCalculator resourceCalculator;
Expand Down Expand Up @@ -1544,7 +1543,7 @@ long getIdleExpirationTimestamp(long now) {
if (idleExpirationTimestamp == 0) {
if (idleContainerTimeoutMin > 0) {
idleExpirationTimestamp = now + (idleContainerTimeoutMin == idleContainerTimeoutMax ? idleContainerTimeoutMin
: random.nextLong(idleContainerTimeoutMin, idleContainerTimeoutMax));
: ThreadLocalRandom.current().nextLong(idleContainerTimeoutMin, idleContainerTimeoutMax));
} else {
idleExpirationTimestamp = Long.MAX_VALUE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.PriorityBlockingQueue;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

Expand All @@ -44,7 +45,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.commons.math3.random.RandomDataGenerator;
import org.apache.hadoop.classification.InterfaceAudience.Private;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.util.ExitUtil;
Expand Down Expand Up @@ -153,7 +153,6 @@ public class YarnTaskSchedulerService extends TaskScheduler

Set<ContainerId> sessionMinHeldContainers = Sets.newHashSet();

RandomDataGenerator random = new RandomDataGenerator();
private final Configuration conf;

@VisibleForTesting
Expand Down Expand Up @@ -593,7 +592,7 @@ long getHeldContainerExpireTime(long startTime) {
long expireTime = (startTime + idleContainerTimeoutMin);
if (idleContainerTimeoutMin != -1 && idleContainerTimeoutMin < idleContainerTimeoutMax) {
long expireTimeMax = startTime + idleContainerTimeoutMax;
expireTime = random.nextLong(expireTime, expireTimeMax);
expireTime = ThreadLocalRandom.current().nextLong(expireTime, expireTimeMax);
}

return expireTime;
Expand Down

0 comments on commit 70623f0

Please sign in to comment.