Review Board 1.7.22


FLUME-1890. Flume should set the hbase keytab and principal in HBase conf object

Review Request #9212 - Created Feb. 1, 2013 and submitted

Hari Shreedharan
FLUME-1890
Reviewers
Flume
flume-git
Set the keytab and principal in the conf object.
Ran on secure cluster and verified.
flume-ng-sinks/flume-ng-hbase-sink/src/main/java/org/apache/flume/sink/hbase/HBaseSinkSecurityManager.java
Revision 8bf0509 New Change
[20] 38 lines
[+20] [+] public class HBaseSinkSecurityManager {
39
   * volatile for safe publication. Since this is updated only by
39
   * volatile for safe publication. Since this is updated only by
40
   * a single thread (configuration) and read later by the sink threads,
40
   * a single thread (configuration) and read later by the sink threads,
41
   * this can just be volatile, no need of Atomic reference.
41
   * this can just be volatile, no need of Atomic reference.
42
   */
42
   */
43
  private volatile static KerberosUser loggedInUser;
43
  private volatile static KerberosUser loggedInUser;

    
   
44
  private static final String FLUME_KEYTAB_KEY = "flume.keytab.key";

    
   
45
  private static final String FLUME_PRINCIPAL_KEY = "flume.principal.key";
44
  private static final Logger LOG =
46
  private static final Logger LOG =
45
          LoggerFactory.getLogger(HBaseSinkSecurityManager.class);
47
          LoggerFactory.getLogger(HBaseSinkSecurityManager.class);
46

    
   
48

   
47
  /**
49
  /**
48
   * Checks if security is enabled for the HBase cluster.
50
   * Checks if security is enabled for the HBase cluster.
[+20] [20] 68 lines
[+20] [+] public static synchronized User login(Configuration conf, String hostname,
117
    }
119
    }
118
    if (!loggedIn) {
120
    if (!loggedIn) {
119
      if (hostname == null || hostname.isEmpty()) {
121
      if (hostname == null || hostname.isEmpty()) {
120
        hostname = InetAddress.getLocalHost().getCanonicalHostName();
122
        hostname = InetAddress.getLocalHost().getCanonicalHostName();
121
      }
123
      }
122
      User.login(conf, kerberosKeytab, principal, hostname);
124
      conf.set(FLUME_KEYTAB_KEY, kerberosKeytab);

    
   
125
      conf.set(FLUME_PRINCIPAL_KEY, principal);

    
   
126
      User.login(conf, FLUME_KEYTAB_KEY, FLUME_PRINCIPAL_KEY, hostname);
123
      hbaseUser = User.create(UserGroupInformation.getLoginUser());
127
      hbaseUser = User.create(UserGroupInformation.getLoginUser());
124
      loggedInUser = newUser;
128
      loggedInUser = newUser;
125
      //TODO: Set the loggedInUser to the current user.
129
      //TODO: Set the loggedInUser to the current user.
126
      LOG.info("Logged into HBase as user: " + hbaseUser.getName());
130
      LOG.info("Logged into HBase as user: " + hbaseUser.getName());
127
    }
131
    }
128
    return hbaseUser;
132
    return hbaseUser;
129
  }
133
  }
130
}
134
}
  1. flume-ng-sinks/flume-ng-hbase-sink/src/main/java/org/apache/flume/sink/hbase/HBaseSinkSecurityManager.java: Loading...