YARN-10460. Upgrading to JUnit 4.13 causes tests in TestNodeStatusUpdater to fail. Contributed by Peter Bacsko
(cherry picked from commit 31477a224f
)
This commit is contained in:
parent
49f6326a9f
commit
f7e382c62e
@ -29,6 +29,8 @@
|
|||||||
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 org.apache.hadoop.thirdparty.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 void stopClient(Client client) {
|
|||||||
client.stop();
|
client.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
public void clearCache() {
|
||||||
|
clients.values().forEach(c -> c.stop());
|
||||||
|
clients.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -352,6 +352,11 @@ public RPC.Server getServer(Class<?> protocol, Object protocolImpl,
|
|||||||
portRangeConfig, alignmentContext);
|
portRangeConfig, alignmentContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
public static void clearClientCache() {
|
||||||
|
CLIENTS.clearCache();
|
||||||
|
}
|
||||||
|
|
||||||
public static class Server extends RPC.Server {
|
public static class Server extends RPC.Server {
|
||||||
|
|
||||||
static final ThreadLocal<ProtobufRpcEngineCallback2> CURRENT_CALLBACK =
|
static final ThreadLocal<ProtobufRpcEngineCallback2> CURRENT_CALLBACK =
|
||||||
|
@ -54,6 +54,7 @@
|
|||||||
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.ProtobufRpcEngine2;
|
||||||
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;
|
||||||
@ -137,6 +138,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+
|
||||||
|
ProtobufRpcEngine2.clearClientCache();
|
||||||
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void tearDown() {
|
public void tearDown() {
|
||||||
this.registeredNodes.clear();
|
this.registeredNodes.clear();
|
||||||
|
Loading…
Reference in New Issue
Block a user