public static ResourceCalculatorPlugin getResourceCalculatorPlugin ( Class < ? extends ResourceCalculatorPlugin > clazz , Configuration conf ) { if ( clazz != null ) { return ReflectionUtils . newInstance ( clazz , conf ) ; } // No class given, try a os specific class try { String osName = System . getProperty ( "os.name" ) ; if ( osName . startsWith ( "Linux" ) ) { return new LinuxResourceCalculatorPlugin ( ) ; } } catch ( SecurityException se ) { // Failed to get Operating System name. return new NullResourceCalculatorPlugin ( ) ; } // Not supported on this system. return new NullResourceCalculatorPlugin ( ) ; }
Get the ResourceCalculatorPlugin from the class name and configure it . If class name is null this method will try and return a memory calculator plugin available for this system .