Why UserGroupInformation class is designed this way? Why setConfiguration(Configuration conf) method of UserGroupInformation class is static ?
My understanding is that this will restrict client to be able to connect to only 1 cluster per JVM.
How can we connect to multiple clusters at the same time from single JVM? I think this is a very basic scenario currently not being supported by Hadoop API.
Any help would be appreciated.
In general, main motivation for making a method static is convenience. You can call a static method without creating any object, just by using it's class name.So if you need a method, which you want to call directly by class name, make that method static. Utility classes e.g. java.lang.Math
or StringUtils
, are good examples of classes, which uses static methods.
setConfiguration(Configuration conf)
-
Set the static configuration for UGI. In particular, set the security authentication mechanism and the group look up service.
How can we connect to multiple clusters at the same time from single JVM? I think this is a very basic scenario currently not being supported by Hadoop API.
Ans: Hadoop API is using like singleton design pattern here. You cannot do that because if you can imagine ever requiring to use object inheritance or needing to use polymorphism for your method, you should definitely skip the static and make it an instance method.
A good scenerio is described here: Static methods are a code smell
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With