HBASE-6945 Compilation errors when using non-Sun JDKs to build HBase-0.94
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1409115 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
839a0944b3
commit
98bdd5df13
|
@ -34,17 +34,20 @@ import java.lang.reflect.Method;
|
||||||
import org.apache.hadoop.classification.InterfaceAudience;
|
import org.apache.hadoop.classification.InterfaceAudience;
|
||||||
import org.apache.hadoop.classification.InterfaceStability;
|
import org.apache.hadoop.classification.InterfaceStability;
|
||||||
|
|
||||||
|
import org.apache.hadoop.util.Shell;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is a wrapper for the implementation of
|
* This class is a wrapper for the implementation of
|
||||||
* com.sun.management.UnixOperatingSystemMXBean
|
* com.sun.management.UnixOperatingSystemMXBean
|
||||||
* It will decide to use Oracle Java api or its own implementation
|
* It will decide to use the sun api or its own implementation
|
||||||
* depending on the runtime (vendor) used.
|
* depending on the runtime (vendor) used.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@InterfaceAudience.Public
|
@InterfaceAudience.Public
|
||||||
@InterfaceStability.Evolving
|
@InterfaceStability.Evolving
|
||||||
public class OSMXBean {
|
public class JVM
|
||||||
static final Logger LOG = LoggerFactory.getLogger(OSMXBean.class);
|
{
|
||||||
|
static final Logger LOG = LoggerFactory.getLogger(JVM.class);
|
||||||
|
|
||||||
private OperatingSystemMXBean osMbean;
|
private OperatingSystemMXBean osMbean;
|
||||||
|
|
||||||
|
@ -58,7 +61,7 @@ public class OSMXBean {
|
||||||
/**
|
/**
|
||||||
* Constructor. Get the running Operating System instance
|
* Constructor. Get the running Operating System instance
|
||||||
*/
|
*/
|
||||||
public OSMXBean () {
|
public JVM () {
|
||||||
this.osMbean = ManagementFactory.getOperatingSystemMXBean();
|
this.osMbean = ManagementFactory.getOperatingSystemMXBean();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,8 +83,8 @@ public class OSMXBean {
|
||||||
* @param mBeanMethodName : method to run from the interface UnixOperatingSystemMXBean
|
* @param mBeanMethodName : method to run from the interface UnixOperatingSystemMXBean
|
||||||
* @return the method result
|
* @return the method result
|
||||||
*/
|
*/
|
||||||
private Long runUnixMXBeanMethod (String mBeanMethodName)
|
private Long runUnixMXBeanMethod (String mBeanMethodName) {
|
||||||
{
|
|
||||||
Object unixos;
|
Object unixos;
|
||||||
Class<?> classRef;
|
Class<?> classRef;
|
||||||
Method mBeanMethod;
|
Method mBeanMethod;
|
||||||
|
@ -107,8 +110,8 @@ public class OSMXBean {
|
||||||
* Otherwise, this methods implements it (linux only).
|
* Otherwise, this methods implements it (linux only).
|
||||||
* @return number of open file descriptors for the jvm
|
* @return number of open file descriptors for the jvm
|
||||||
*/
|
*/
|
||||||
public long getOpenFileDescriptorCount()
|
public long getOpenFileDescriptorCount() {
|
||||||
{
|
|
||||||
Long ofdc;
|
Long ofdc;
|
||||||
|
|
||||||
if (!ibmvendor) {
|
if (!ibmvendor) {
|
||||||
|
@ -130,9 +133,8 @@ public class OSMXBean {
|
||||||
new InputStreamReader(in));
|
new InputStreamReader(in));
|
||||||
|
|
||||||
String openFileDesCount;
|
String openFileDesCount;
|
||||||
if ((openFileDesCount = output.readLine()) != null) {
|
if ((openFileDesCount = output.readLine()) != null)
|
||||||
return Long.parseLong(openFileDesCount);
|
return Long.parseLong(openFileDesCount);
|
||||||
}
|
|
||||||
} catch (IOException ie) {
|
} catch (IOException ie) {
|
||||||
LOG.warn("Not able to get the number of open file descriptors", ie);
|
LOG.warn("Not able to get the number of open file descriptors", ie);
|
||||||
}
|
}
|
||||||
|
@ -145,8 +147,8 @@ public class OSMXBean {
|
||||||
* Otherwise, this methods implements it (linux only).
|
* Otherwise, this methods implements it (linux only).
|
||||||
* @return max number of file descriptors the operating system can use.
|
* @return max number of file descriptors the operating system can use.
|
||||||
*/
|
*/
|
||||||
public long getMaxFileDescriptorCount()
|
public long getMaxFileDescriptorCount() {
|
||||||
{
|
|
||||||
Long mfdc;
|
Long mfdc;
|
||||||
|
|
||||||
if (!ibmvendor) {
|
if (!ibmvendor) {
|
||||||
|
@ -164,9 +166,8 @@ public class OSMXBean {
|
||||||
new InputStreamReader(in));
|
new InputStreamReader(in));
|
||||||
|
|
||||||
String maxFileDesCount;
|
String maxFileDesCount;
|
||||||
if ((maxFileDesCount = output.readLine()) != null) {
|
if ((maxFileDesCount = output.readLine()) != null)
|
||||||
return Long.parseLong(maxFileDesCount);
|
return Long.parseLong(maxFileDesCount);
|
||||||
}
|
|
||||||
} catch (IOException ie) {
|
} catch (IOException ie) {
|
||||||
LOG.warn("Not able to get the max number of file descriptors", ie);
|
LOG.warn("Not able to get the max number of file descriptors", ie);
|
||||||
}
|
}
|
|
@ -32,7 +32,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||||
import org.apache.hadoop.hbase.ResourceChecker.Phase;
|
import org.apache.hadoop.hbase.ResourceChecker.Phase;
|
||||||
import org.junit.runner.notification.RunListener;
|
import org.junit.runner.notification.RunListener;
|
||||||
|
|
||||||
import com.sun.management.UnixOperatingSystemMXBean;
|
import org.apache.hadoop.hbase.util.JVM;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Listen to the test progress and check the usage of:
|
* Listen to the test progress and check the usage of:
|
||||||
|
@ -85,32 +85,15 @@ public class ResourceCheckerJUnitListener extends RunListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* On unix, we know how to get the number of open file descriptor. This class allow to share
|
|
||||||
* the MXBeans code.
|
|
||||||
*/
|
|
||||||
abstract static class OSResourceAnalyzer extends ResourceChecker.ResourceAnalyzer {
|
|
||||||
protected static final OperatingSystemMXBean osStats;
|
|
||||||
protected static final UnixOperatingSystemMXBean unixOsStats;
|
|
||||||
|
|
||||||
static {
|
static class OpenFileDescriptorResourceAnalyzer extends ResourceChecker.ResourceAnalyzer {
|
||||||
osStats = ManagementFactory.getOperatingSystemMXBean();
|
|
||||||
if (osStats instanceof UnixOperatingSystemMXBean) {
|
|
||||||
unixOsStats = (UnixOperatingSystemMXBean) osStats;
|
|
||||||
} else {
|
|
||||||
unixOsStats = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static class OpenFileDescriptorResourceAnalyzer extends OSResourceAnalyzer {
|
|
||||||
@Override
|
@Override
|
||||||
public int getVal(Phase phase) {
|
public int getVal(Phase phase) {
|
||||||
if (unixOsStats == null) {
|
JVM jvm = new JVM();
|
||||||
|
if (jvm != null && jvm.isUnix() == true)
|
||||||
|
return (int)jvm.getOpenFileDescriptorCount();
|
||||||
|
else
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
|
||||||
return (int) unixOsStats.getOpenFileDescriptorCount();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -119,14 +102,14 @@ public class ResourceCheckerJUnitListener extends RunListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class MaxFileDescriptorResourceAnalyzer extends OSResourceAnalyzer {
|
static class MaxFileDescriptorResourceAnalyzer extends ResourceChecker.ResourceAnalyzer {
|
||||||
@Override
|
@Override
|
||||||
public int getVal(Phase phase) {
|
public int getVal(Phase phase) {
|
||||||
if (unixOsStats == null) {
|
JVM jvm = new JVM();
|
||||||
|
if (jvm != null && jvm.isUnix() == true)
|
||||||
|
return (int)jvm.getMaxFileDescriptorCount();
|
||||||
|
else
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
|
||||||
return (int) unixOsStats.getMaxFileDescriptorCount();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue