bharatviswa504 edited a comment on pull request #897:
URL: https://github.com/apache/hadoop-ozone/pull/897#issuecomment-624762288


   > > Hi @Simon0806
   > > Thanks for the contribution and welcome to Ozone.
   > > OzoneConfiguration() calls loadDefaults() and in loadDefaults() we add 
ozone-site.xml.
   > > I see this has been already taken care of by the below code.
   > > ```
   > >    public OzoneConfiguration() {
   > >      OzoneConfiguration.activate();
   > >      loadDefaults();
   > >    }
   > > ```
   > > 
   > > 
   > > ```
   > >   private void loadDefaults() {
   > >     try {
   > >       //there could be multiple ozone-default-generated.xml files on the
   > >       // classpath, which are generated by the annotation processor.
   > >       // Here we add all of them to the list of the available 
configuration.
   > >       Enumeration<URL> generatedDefaults =
   > >           OzoneConfiguration.class.getClassLoader().getResources(
   > >               "ozone-default-generated.xml");
   > >       while (generatedDefaults.hasMoreElements()) {
   > >         addResource(generatedDefaults.nextElement());
   > >       }
   > >     } catch (IOException e) {
   > >       e.printStackTrace();
   > >     }
   > >     addResource("ozone-site.xml");
   > >   }
   > > ```
   > 
   > Hi Bharat
   > Actually it's true but they are different behaviors. the line you 
mentioned was add ozone-site.xml into resources belong to OzoneConfiguration 
but will not add ozone-site.xml into defaultResources belong to Configuration. 
The initialize process of S3Gateway will use 
UserGroupInformation.isSecurityEnable to check if security has been configured.
   > Here is the key point code:
   > 
   > ```
   > 
   >  private static void ensureInitialized() {
   >     if (!isInitialized()) {
   >       synchronized(UserGroupInformation.class) {
   >         if (!isInitialized()) { // someone might have beat us
   >           initialize(new Configuration(), false);
   >         }
   >       }
   >     }
   >   }
   > ```
   > 
   > Here it called new Configuration() which will load defaultResources, which 
only contains
   > core-site.xml, hdfs-site.xml, core-default.xml, hdfs-default.xml and 
ozone-default.xml.
   > While when initializing OM and SCM it will pass the OzoneConfiguration to 
do initialize but S3Gateway it use Configuration by default.
   > 
   > Or I can call a UserGroupInformation.setConfiguration(conf) when startup a 
S3Gateway service to pass the OzoneConfiguration to UserGroupInformation.
   
   Thank You @Simon0806 for the clear explanation. I see in OzoneManager, we 
set 
   UserGroupInformation.setConfiguration(conf), and we want to do a similar 
thing in S3Gateway. Can we do the set conf, without any checks? (Not sure if 
something might require in future for non-secure, just to be on the safer side)
   
   
   ```
     private static void loginOMUser(OzoneConfiguration conf)
         throws IOException, AuthenticationException {
   
       if (SecurityUtil.getAuthenticationMethod(conf).equals(
           AuthenticationMethod.KERBEROS)) {
         if (LOG.isDebugEnabled()) {
           LOG.debug("Ozone security is enabled. Attempting login for OM user. "
                   + "Principal: {}, keytab: {}", conf.get(
               OZONE_OM_KERBEROS_PRINCIPAL_KEY),
               conf.get(OZONE_OM_KERBEROS_KEYTAB_FILE_KEY));
         }
   
   ```
         UserGroupInformation.setConfiguration(conf);


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to