private static PlatformInfo getPlatformInfoInternal()
{
URL url = JobConf.class.getResource( JobConf.class.getSimpleName() + ".class" );
if( url == null || !url.toString().startsWith( "jar" ) )
return new PlatformInfo( "Hadoop", null, null );
String path = url.toString();
String manifestPath = path.substring( 0, path.lastIndexOf( "!" ) + 1 ) + "/META-INF/MANIFEST.MF";
Manifest manifest;
try
{
manifest = new Manifest( new URL( manifestPath ).openStream() );
}
catch( IOException exception )
{
LOG.warn( "unable to get manifest from {}", manifestPath, exception );
return new PlatformInfo( "Hadoop", null, null );
}
Attributes attributes = manifest.getAttributes( "org/apache/hadoop" );
if( attributes == null )
{
LOG.debug( "unable to get Hadoop manifest attributes" );
return new PlatformInfo( "Hadoop", null, null );
}
String vendor = attributes.getValue( "Implementation-Vendor" );
String version = attributes.getValue( "Implementation-Version" );
return new PlatformInfo( "Hadoop", vendor, version );
}