1 /** 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 package org.apache.hadoop.mapred.gridmix; 19 20 import java.io.IOException; 21 import java.net.URI; 22 import org.apache.hadoop.conf.Configuration; 23 import org.apache.hadoop.security.UserGroupInformation; 24 import org.apache.commons.logging.Log; 25 import org.apache.commons.logging.LogFactory; 26 27 /** 28 * Resolves all UGIs to the submitting user. 29 */ 30 public class SubmitterUserResolver implements UserResolver { 31 public static final Log LOG = LogFactory.getLog(SubmitterUserResolver.class); 32 33 private UserGroupInformation ugi = null; 34 SubmitterUserResolver()35 public SubmitterUserResolver() throws IOException { 36 LOG.info(" Current user resolver is SubmitterUserResolver "); 37 ugi = UserGroupInformation.getLoginUser(); 38 } 39 setTargetUsers(URI userdesc, Configuration conf)40 public synchronized boolean setTargetUsers(URI userdesc, Configuration conf) 41 throws IOException { 42 return false; 43 } 44 getTargetUgi( UserGroupInformation ugi)45 public synchronized UserGroupInformation getTargetUgi( 46 UserGroupInformation ugi) { 47 return this.ugi; 48 } 49 50 /** 51 * {@inheritDoc} 52 * <p> 53 * Since {@link SubmitterUserResolver} returns the user name who is running 54 * gridmix, it doesn't need a target list of users. 55 */ needsTargetUsersList()56 public boolean needsTargetUsersList() { 57 return false; 58 } 59 } 60