Skip to content

Commit d2a4893

Browse files
committed
HBASE-24072 Nightlies reporting OutOfMemoryError: unable to create new native thread DEBUG. NOT FOR COMMIT.
1 parent 4a85f06 commit d2a4893

File tree

1 file changed

+165
-0
lines changed

1 file changed

+165
-0
lines changed
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package org.apache.hadoop.hbase;
19+
20+
import com.sun.management.UnixOperatingSystemMXBean;
21+
import java.io.BufferedReader;
22+
import java.io.IOException;
23+
import java.io.InputStreamReader;
24+
import java.lang.management.ManagementFactory;
25+
import org.apache.hadoop.hbase.testclassification.SmallTests;
26+
import org.junit.ClassRule;
27+
import org.junit.Test;
28+
import org.junit.experimental.categories.Category;
29+
30+
@Category(SmallTests.class)
31+
public class TestPrintEnv {
32+
@ClassRule
33+
public static final HBaseClassTestRule CLASS_RULE =
34+
HBaseClassTestRule.forClass(TestPrintEnv.class);
35+
private static Object S = new Object();
36+
private static int COUNT = 0;
37+
38+
@Test
39+
public void testupu() throws Exception {
40+
Process p = Runtime.getRuntime().exec(new String [] {"/bin/bash", "-c", "ulimit -u"});
41+
int errCode = p.waitFor();
42+
System.out.println("errCode=" + errCode);
43+
BufferedReader is = new BufferedReader(new InputStreamReader(p.getInputStream()));
44+
String line;
45+
while ((line = is.readLine()) != null) {
46+
System.out.println(line);
47+
}
48+
is.close();
49+
is = new BufferedReader(new InputStreamReader(p.getErrorStream()));
50+
while ((line = is.readLine()) != null) {
51+
System.out.println(line);
52+
}
53+
p = Runtime.getRuntime().exec(new String [] {"/bin/bash", "-c", "ulimit -u 10001"});
54+
errCode = p.waitFor();
55+
System.out.println("errCode=" + errCode);
56+
is = new BufferedReader(new InputStreamReader(p.getInputStream()));
57+
while ((line = is.readLine()) != null) {
58+
System.out.println(line);
59+
}
60+
is.close();
61+
is = new BufferedReader(new InputStreamReader(p.getErrorStream()));
62+
while ((line = is.readLine()) != null) {
63+
System.out.println(line);
64+
}
65+
p = Runtime.getRuntime().exec(new String [] {"/bin/bash", "-c", "ulimit -u"});
66+
errCode = p.waitFor();
67+
System.out.println("errCode=" + errCode);
68+
is = new BufferedReader(new InputStreamReader(p.getInputStream()));
69+
while ((line = is.readLine()) != null) {
70+
System.out.println(line);
71+
}
72+
is.close();
73+
is = new BufferedReader(new InputStreamReader(p.getErrorStream()));
74+
while ((line = is.readLine()) != null) {
75+
System.out.println(line);
76+
}
77+
}
78+
79+
@Test
80+
public void testmvnversion() throws Exception {
81+
Process p = Runtime.getRuntime().exec(new String [] {"/bin/bash", "-c", "mvn --version"});
82+
int errCode = p.waitFor();
83+
System.out.println("errCode=" + errCode);
84+
BufferedReader is = new BufferedReader(new InputStreamReader(p.getInputStream()));
85+
String line;
86+
while ((line = is.readLine()) != null) {
87+
System.out.println(line);
88+
}
89+
is.close();
90+
is = new BufferedReader(new InputStreamReader(p.getErrorStream()));
91+
while ((line = is.readLine()) != null) {
92+
System.out.println(line);
93+
}
94+
}
95+
96+
@Test
97+
public void testn() throws Exception {
98+
Process p = Runtime.getRuntime().exec(new String [] {"/bin/bash", "-c", "ulimit -n"});
99+
int errCode = p.waitFor();
100+
System.out.println("errCode=" + errCode);
101+
BufferedReader is = new BufferedReader(new InputStreamReader(p.getInputStream()));
102+
String line;
103+
while ((line = is.readLine()) != null) {
104+
System.out.println(line);
105+
}
106+
is.close();
107+
is = new BufferedReader(new InputStreamReader(p.getErrorStream()));
108+
while ((line = is.readLine()) != null) {
109+
System.out.println(line);
110+
}
111+
}
112+
113+
@Test
114+
public void testa() throws Exception {
115+
Process p = Runtime.getRuntime().exec(new String [] {"/bin/bash", "-c", "ulimit -a"});
116+
int errCode = p.waitFor();
117+
System.out.println("errCode=" + errCode);
118+
BufferedReader is = new BufferedReader(new InputStreamReader(p.getInputStream()));
119+
String line;
120+
while ((line = is.readLine()) != null) {
121+
System.out.println(line);
122+
}
123+
is.close();
124+
is = new BufferedReader(new InputStreamReader(p.getErrorStream()));
125+
while ((line = is.readLine()) != null) {
126+
System.out.println(line);
127+
}
128+
}
129+
130+
@Test
131+
public void testfds() throws InterruptedException, IOException {
132+
final UnixOperatingSystemMXBean osMBean =
133+
(UnixOperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
134+
System.out.println("opendfs: " + osMBean.getOpenFileDescriptorCount());
135+
System.out.println("maxfds: " + osMBean.getMaxFileDescriptorCount());
136+
}
137+
138+
/*
139+
@org.junit.Ignore @Test
140+
public void testthreds() throws InterruptedException, IOException {
141+
try {
142+
Runtime rt = Runtime.getRuntime();
143+
while (true) {
144+
new Thread(new Runnable() {
145+
public void run() {
146+
synchronized (S) {
147+
COUNT += 1;
148+
System.err.println("New thread #" + COUNT);
149+
}
150+
for (; ; ) {
151+
try {
152+
Thread.sleep(10);
153+
} catch (Exception e) {
154+
System.err.println(e);
155+
}
156+
}
157+
}
158+
}).start();
159+
Thread.sleep(10);
160+
}
161+
} catch (Throwable t) {
162+
}
163+
}
164+
*/
165+
}

0 commit comments

Comments
 (0)