YARN-10460. Upgrading to JUnit 4.13 causes tests in TestNodeStatusUpdater to fail. Contributed by Peter Bacsko.
(cherry picked from commit bf0d058b69
)
This commit is contained in:
parent
bef21ceb14
commit
9c3acb3018
|
@ -29,6 +29,8 @@ import org.apache.hadoop.conf.Configuration;
|
||||||
import org.apache.hadoop.io.ObjectWritable;
|
import org.apache.hadoop.io.ObjectWritable;
|
||||||
import org.apache.hadoop.io.Writable;
|
import org.apache.hadoop.io.Writable;
|
||||||
|
|
||||||
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
|
|
||||||
/* Cache a client using its socket factory as the hash key */
|
/* Cache a client using its socket factory as the hash key */
|
||||||
@InterfaceAudience.LimitedPrivate({"HDFS", "MapReduce"})
|
@InterfaceAudience.LimitedPrivate({"HDFS", "MapReduce"})
|
||||||
@InterfaceStability.Evolving
|
@InterfaceStability.Evolving
|
||||||
|
@ -114,4 +116,10 @@ public class ClientCache {
|
||||||
client.stop();
|
client.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
public void clearCache() {
|
||||||
|
clients.values().forEach(c -> c.stop());
|
||||||
|
clients.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -335,7 +335,10 @@ public class ProtobufRpcEngine implements RpcEngine {
|
||||||
RpcWritable.Buffer.class);
|
RpcWritable.Buffer.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
public static void clearClientCache() {
|
||||||
|
CLIENTS.clearCache();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RPC.Server getServer(Class<?> protocol, Object protocolImpl,
|
public RPC.Server getServer(Class<?> protocol, Object protocolImpl,
|
||||||
|
|
|
@ -52,6 +52,7 @@ import org.apache.hadoop.io.DataOutputBuffer;
|
||||||
import org.apache.hadoop.io.Text;
|
import org.apache.hadoop.io.Text;
|
||||||
import org.apache.hadoop.io.retry.RetryPolicy;
|
import org.apache.hadoop.io.retry.RetryPolicy;
|
||||||
import org.apache.hadoop.io.retry.RetryProxy;
|
import org.apache.hadoop.io.retry.RetryProxy;
|
||||||
|
import org.apache.hadoop.ipc.ProtobufRpcEngine;
|
||||||
import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
|
import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
|
||||||
import org.apache.hadoop.net.NetUtils;
|
import org.apache.hadoop.net.NetUtils;
|
||||||
import org.apache.hadoop.net.ServerSocketUtil;
|
import org.apache.hadoop.net.ServerSocketUtil;
|
||||||
|
@ -122,6 +123,12 @@ public class TestNodeStatusUpdater extends NodeManagerTestBase {
|
||||||
private NodeManager nm;
|
private NodeManager nm;
|
||||||
private AtomicBoolean assertionFailedInThread = new AtomicBoolean(false);
|
private AtomicBoolean assertionFailedInThread = new AtomicBoolean(false);
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void before() {
|
||||||
|
// to avoid threading issues with JUnit 4.13+
|
||||||
|
ProtobufRpcEngine.clearClientCache();
|
||||||
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void tearDown() {
|
public void tearDown() {
|
||||||
this.registeredNodes.clear();
|
this.registeredNodes.clear();
|
||||||
|
|
Loading…
Reference in New Issue