[SPARK-15053][BUILD] Fix Java Lint errors on Hive-Thriftserver module
## What changes were proposed in this pull request? This issue fixes or hides 181 Java linter errors introduced by SPARK-14987 which copied hive service code from Hive. We had better clean up these errors before releasing Spark 2.0. - Fix UnusedImports (15 lines), RedundantModifier (14 lines), SeparatorWrap (9 lines), MethodParamPad (6 lines), FileTabCharacter (5 lines), ArrayTypeStyle (3 lines), ModifierOrder (3 lines), RedundantImport (1 line), CommentsIndentation (1 line), UpperEll (1 line), FallThrough (1 line), OneStatementPerLine (1 line), NewlineAtEndOfFile (1 line) errors. - Ignore `LineLength` errors under `hive/service/*` (118 lines). - Ignore `MethodName` error in `PasswdAuthenticationProvider.java` (1 line). - Ignore `NoFinalizer` error in `ThreadWithGarbageCleanup.java` (1 line). ## How was this patch tested? After passing Jenkins building, run `dev/lint-java` manually. ```bash $ dev/lint-java Checkstyle checks passed. ``` Author: Dongjoon Hyun <dongjoon@apache.org> Closes #12831 from dongjoon-hyun/SPARK-15053.
This commit is contained in:
parent
dfd9723dd3
commit
a744457076
|
@ -36,4 +36,10 @@
|
|||
files="src/test/java/org/apache/spark/sql/hive/test/Complex.java"/>
|
||||
<suppress checks="LineLength"
|
||||
files="src/main/java/org/apache/spark/examples/JavaLogQuery.java"/>
|
||||
<suppress checks="LineLength"
|
||||
files="src/main/java/org/apache/hive/service/*"/>
|
||||
<suppress checks="MethodName"
|
||||
files="src/main/java/org/apache/hive/service/auth/PasswdAuthenticationProvider.java"/>
|
||||
<suppress checks="NoFinalizer"
|
||||
files="src/main/java/org/apache/hive/service/server/ThreadWithGarbageCleanup.java"/>
|
||||
</suppressions>
|
||||
|
|
|
@ -29,7 +29,7 @@ public interface Service {
|
|||
/**
|
||||
* Service states
|
||||
*/
|
||||
public enum STATE {
|
||||
enum STATE {
|
||||
/** Constructed but not initialized */
|
||||
NOTINITED,
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ public final class HttpAuthUtils {
|
|||
private static final String COOKIE_CLIENT_USER_NAME = "cu";
|
||||
private static final String COOKIE_CLIENT_RAND_NUMBER = "rn";
|
||||
private static final String COOKIE_KEY_VALUE_SEPARATOR = "=";
|
||||
private final static Set<String> COOKIE_ATTRIBUTES =
|
||||
private static final Set<String> COOKIE_ATTRIBUTES =
|
||||
new HashSet<String>(Arrays.asList(COOKIE_CLIENT_USER_NAME, COOKIE_CLIENT_RAND_NUMBER));
|
||||
|
||||
/**
|
||||
|
@ -93,10 +93,10 @@ public final class HttpAuthUtils {
|
|||
*/
|
||||
public static String createCookieToken(String clientUserName) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append(COOKIE_CLIENT_USER_NAME).append(COOKIE_KEY_VALUE_SEPARATOR).append(clientUserName).
|
||||
append(COOKIE_ATTR_SEPARATOR);
|
||||
sb.append(COOKIE_CLIENT_RAND_NUMBER).append(COOKIE_KEY_VALUE_SEPARATOR).
|
||||
append((new Random(System.currentTimeMillis())).nextLong());
|
||||
sb.append(COOKIE_CLIENT_USER_NAME).append(COOKIE_KEY_VALUE_SEPARATOR).append(clientUserName)
|
||||
.append(COOKIE_ATTR_SEPARATOR);
|
||||
sb.append(COOKIE_CLIENT_RAND_NUMBER).append(COOKIE_KEY_VALUE_SEPARATOR)
|
||||
.append((new Random(System.currentTimeMillis())).nextLong());
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ public final class KerberosSaslHelper {
|
|||
private final ThriftCLIService service;
|
||||
private final Server saslServer;
|
||||
|
||||
public CLIServiceProcessorFactory(Server saslServer, ThriftCLIService service) {
|
||||
CLIServiceProcessorFactory(Server saslServer, ThriftCLIService service) {
|
||||
super(null);
|
||||
this.service = service;
|
||||
this.saslServer = saslServer;
|
||||
|
|
|
@ -25,10 +25,12 @@ import java.util.Map;
|
|||
* Possible values of SASL quality-of-protection value.
|
||||
*/
|
||||
public enum SaslQOP {
|
||||
AUTH("auth"), // Authentication only.
|
||||
AUTH_INT("auth-int"), // Authentication and integrity checking by using signatures.
|
||||
AUTH_CONF("auth-conf"); // Authentication, integrity and confidentiality checking
|
||||
// by using signatures and encryption.
|
||||
// Authentication only.
|
||||
AUTH("auth"),
|
||||
// Authentication and integrity checking by using signatures.
|
||||
AUTH_INT("auth-int"),
|
||||
// Authentication, integrity and confidentiality checking by using signatures and encryption.
|
||||
AUTH_CONF("auth-conf");
|
||||
|
||||
public final String saslQop;
|
||||
|
||||
|
|
|
@ -481,8 +481,8 @@ public class CLIService extends CompositeService implements ICLIService {
|
|||
@Override
|
||||
public String getDelegationToken(SessionHandle sessionHandle, HiveAuthFactory authFactory,
|
||||
String owner, String renewer) throws HiveSQLException {
|
||||
String delegationToken = sessionManager.getSession(sessionHandle).
|
||||
getDelegationToken(authFactory, owner, renewer);
|
||||
String delegationToken = sessionManager.getSession(sessionHandle)
|
||||
.getDelegationToken(authFactory, owner, renewer);
|
||||
LOG.info(sessionHandle + ": getDelegationToken()");
|
||||
return delegationToken;
|
||||
}
|
||||
|
@ -490,8 +490,7 @@ public class CLIService extends CompositeService implements ICLIService {
|
|||
@Override
|
||||
public void cancelDelegationToken(SessionHandle sessionHandle, HiveAuthFactory authFactory,
|
||||
String tokenStr) throws HiveSQLException {
|
||||
sessionManager.getSession(sessionHandle).
|
||||
cancelDelegationToken(authFactory, tokenStr);
|
||||
sessionManager.getSession(sessionHandle).cancelDelegationToken(authFactory, tokenStr);
|
||||
LOG.info(sessionHandle + ": cancelDelegationToken()");
|
||||
}
|
||||
|
||||
|
|
|
@ -155,7 +155,8 @@ public class HiveSQLException extends SQLException {
|
|||
if (parent != null) {
|
||||
int n = parent.length - 1;
|
||||
while (m >= 0 && n >= 0 && trace[m].equals(parent[n])) {
|
||||
m--; n--;
|
||||
m--;
|
||||
n--;
|
||||
}
|
||||
}
|
||||
List<String> detail = enroll(cause, trace, m);
|
||||
|
|
|
@ -85,6 +85,7 @@ public enum OperationState {
|
|||
if (OperationState.CLOSED.equals(newState)) {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// fall-through
|
||||
}
|
||||
|
|
|
@ -130,8 +130,8 @@ public class RowBasedSet implements RowSet {
|
|||
}
|
||||
|
||||
private static class RemovableList<E> extends ArrayList<E> {
|
||||
public RemovableList() { super(); }
|
||||
public RemovableList(List<E> rows) { super(rows); }
|
||||
RemovableList() { super(); }
|
||||
RemovableList(List<E> rows) { super(rows); }
|
||||
@Override
|
||||
public void removeRange(int fromIndex, int toIndex) {
|
||||
super.removeRange(fromIndex, toIndex);
|
||||
|
|
|
@ -27,10 +27,8 @@ import java.util.Map;
|
|||
import java.util.Map.Entry;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.hadoop.hive.conf.HiveConf.ConfVars;
|
||||
import org.apache.hadoop.hive.metastore.IMetaStoreClient;
|
||||
import org.apache.hadoop.hive.metastore.api.Table;
|
||||
import org.apache.hadoop.hive.ql.plan.HiveOperation;
|
||||
import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveOperationType;
|
||||
import org.apache.hadoop.hive.ql.security.authorization.plugin.HivePrivilegeObject;
|
||||
import org.apache.hadoop.hive.ql.security.authorization.plugin.HivePrivilegeObject.HivePrivilegeObjectType;
|
||||
|
|
|
@ -23,7 +23,6 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
|
||||
import org.apache.hadoop.hive.metastore.IMetaStoreClient;
|
||||
import org.apache.hadoop.hive.metastore.api.MetaException;
|
||||
import org.apache.hadoop.hive.ql.exec.FunctionInfo;
|
||||
import org.apache.hadoop.hive.ql.exec.FunctionRegistry;
|
||||
import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveOperationType;
|
||||
|
@ -103,7 +102,7 @@ public class GetFunctionsOperation extends MetadataOperation {
|
|||
.getFunctionNames(CLIServiceUtils.patternToRegex(functionName));
|
||||
for (String functionName : functionNames) {
|
||||
FunctionInfo functionInfo = FunctionRegistry.getFunctionInfo(functionName);
|
||||
Object rowData[] = new Object[] {
|
||||
Object[] rowData = new Object[] {
|
||||
null, // FUNCTION_CAT
|
||||
null, // FUNCTION_SCHEM
|
||||
functionInfo.getDisplayName(), // FUNCTION_NAME
|
||||
|
|
|
@ -18,16 +18,8 @@
|
|||
|
||||
package org.apache.hive.service.cli.operation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.hadoop.hive.metastore.IMetaStoreClient;
|
||||
import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAccessControlException;
|
||||
import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAuthzContext;
|
||||
import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAuthzPluginException;
|
||||
import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveOperationType;
|
||||
import org.apache.hadoop.hive.ql.security.authorization.plugin.HivePrivilegeObject;
|
||||
import org.apache.hadoop.hive.ql.session.SessionState;
|
||||
import org.apache.hive.service.cli.FetchOrientation;
|
||||
import org.apache.hive.service.cli.HiveSQLException;
|
||||
import org.apache.hive.service.cli.OperationState;
|
||||
|
|
|
@ -44,8 +44,8 @@ public class GetTableTypesOperation extends MetadataOperation {
|
|||
|
||||
protected GetTableTypesOperation(HiveSession parentSession) {
|
||||
super(parentSession, OperationType.GET_TABLE_TYPES);
|
||||
String tableMappingStr = getParentSession().getHiveConf().
|
||||
getVar(HiveConf.ConfVars.HIVE_SERVER2_TABLE_TYPE_MAPPING);
|
||||
String tableMappingStr = getParentSession().getHiveConf()
|
||||
.getVar(HiveConf.ConfVars.HIVE_SERVER2_TABLE_TYPE_MAPPING);
|
||||
tableTypeMapping =
|
||||
TableTypeMappingFactory.getTableTypeMapping(tableMappingStr);
|
||||
rowSet = RowSetFactory.create(RESULT_SET_SCHEMA, getProtocolVersion());
|
||||
|
|
|
@ -64,8 +64,8 @@ public class GetTablesOperation extends MetadataOperation {
|
|||
this.catalogName = catalogName;
|
||||
this.schemaName = schemaName;
|
||||
this.tableName = tableName;
|
||||
String tableMappingStr = getParentSession().getHiveConf().
|
||||
getVar(HiveConf.ConfVars.HIVE_SERVER2_TABLE_TYPE_MAPPING);
|
||||
String tableMappingStr = getParentSession().getHiveConf()
|
||||
.getVar(HiveConf.ConfVars.HIVE_SERVER2_TABLE_TYPE_MAPPING);
|
||||
tableTypeMapping =
|
||||
TableTypeMappingFactory.getTableTypeMapping(tableMappingStr);
|
||||
if (tableTypes != null) {
|
||||
|
|
|
@ -35,7 +35,7 @@ import org.apache.hive.service.cli.session.HiveSession;
|
|||
*/
|
||||
public class GetTypeInfoOperation extends MetadataOperation {
|
||||
|
||||
private final static TableSchema RESULT_SET_SCHEMA = new TableSchema()
|
||||
private static final TableSchema RESULT_SET_SCHEMA = new TableSchema()
|
||||
.addPrimitiveColumn("TYPE_NAME", Type.STRING_TYPE,
|
||||
"Type name")
|
||||
.addPrimitiveColumn("DATA_TYPE", Type.INT_TYPE,
|
||||
|
|
|
@ -60,15 +60,15 @@ public class LogDivertAppender extends WriterAppender {
|
|||
/* Patterns that are excluded in verbose logging level.
|
||||
* Filter out messages coming from log processing classes, or we'll run an infinite loop.
|
||||
*/
|
||||
private static final Pattern verboseExcludeNamePattern = Pattern.compile(Joiner.on("|").
|
||||
join(new String[] {LOG.getName(), OperationLog.class.getName(),
|
||||
private static final Pattern verboseExcludeNamePattern = Pattern.compile(Joiner.on("|")
|
||||
.join(new String[] {LOG.getName(), OperationLog.class.getName(),
|
||||
OperationManager.class.getName()}));
|
||||
|
||||
/* Patterns that are included in execution logging level.
|
||||
* In execution mode, show only select logger messages.
|
||||
*/
|
||||
private static final Pattern executionIncludeNamePattern = Pattern.compile(Joiner.on("|").
|
||||
join(new String[] {"org.apache.hadoop.mapreduce.JobSubmitter",
|
||||
private static final Pattern executionIncludeNamePattern = Pattern.compile(Joiner.on("|")
|
||||
.join(new String[] {"org.apache.hadoop.mapreduce.JobSubmitter",
|
||||
"org.apache.hadoop.mapreduce.Job", "SessionState", Task.class.getName(),
|
||||
"org.apache.hadoop.hive.ql.exec.spark.status.SparkJobMonitor"}));
|
||||
|
||||
|
@ -88,7 +88,7 @@ public class LogDivertAppender extends WriterAppender {
|
|||
}
|
||||
}
|
||||
|
||||
public NameFilter(
|
||||
NameFilter(
|
||||
OperationLog.LoggingLevel loggingMode, OperationManager op) {
|
||||
this.operationManager = op;
|
||||
this.loggingMode = loggingMode;
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
package org.apache.hive.service.cli.operation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.hadoop.hive.conf.HiveConf;
|
||||
|
|
|
@ -326,7 +326,7 @@ public class SQLOperation extends ExecuteStatementOperation {
|
|||
return resultSchema;
|
||||
}
|
||||
|
||||
private transient final List<Object> convey = new ArrayList<Object>();
|
||||
private final transient List<Object> convey = new ArrayList<Object>();
|
||||
|
||||
@Override
|
||||
public RowSet getNextRowSet(FetchOrientation orientation, long maxRows) throws HiveSQLException {
|
||||
|
|
|
@ -27,18 +27,18 @@ public interface TableTypeMapping {
|
|||
* @param clientTypeName
|
||||
* @return
|
||||
*/
|
||||
public String mapToHiveType (String clientTypeName);
|
||||
String mapToHiveType(String clientTypeName);
|
||||
|
||||
/**
|
||||
* Map hive's table type name to client's table type
|
||||
* @param clientTypeName
|
||||
* @return
|
||||
*/
|
||||
public String mapToClientType (String hiveTypeName);
|
||||
String mapToClientType(String hiveTypeName);
|
||||
|
||||
/**
|
||||
* Get all the table types of this mapping
|
||||
* @return
|
||||
*/
|
||||
public Set<String> getTableTypeNames();
|
||||
Set<String> getTableTypeNames();
|
||||
}
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
|
||||
package org.apache.hive.service.cli.session;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.hadoop.hive.conf.HiveConf;
|
||||
import org.apache.hadoop.hive.ql.session.SessionState;
|
||||
import org.apache.hive.service.cli.SessionHandle;
|
||||
|
@ -27,7 +25,6 @@ import org.apache.hive.service.cli.operation.OperationManager;
|
|||
import org.apache.hive.service.cli.thrift.TProtocolVersion;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Methods that don't need to be executed under a doAs
|
||||
|
|
|
@ -33,5 +33,5 @@ public interface HiveSessionHook extends Hook {
|
|||
* @param sessionHookContext context
|
||||
* @throws HiveSQLException
|
||||
*/
|
||||
public void run(HiveSessionHookContext sessionHookContext) throws HiveSQLException;
|
||||
void run(HiveSessionHookContext sessionHookContext) throws HiveSQLException;
|
||||
}
|
||||
|
|
|
@ -30,17 +30,17 @@ public interface HiveSessionHookContext {
|
|||
* Retrieve session conf
|
||||
* @return
|
||||
*/
|
||||
public HiveConf getSessionConf();
|
||||
HiveConf getSessionConf();
|
||||
|
||||
/**
|
||||
* The get the username starting the session
|
||||
* @return
|
||||
*/
|
||||
public String getSessionUser();
|
||||
String getSessionUser();
|
||||
|
||||
/**
|
||||
* Retrieve handle for the session
|
||||
* @return
|
||||
*/
|
||||
public String getSessionHandle();
|
||||
String getSessionHandle();
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ import org.apache.hadoop.fs.FileSystem;
|
|||
import org.apache.hadoop.hive.conf.HiveConf;
|
||||
import org.apache.hadoop.hive.ql.metadata.Hive;
|
||||
import org.apache.hadoop.hive.ql.metadata.HiveException;
|
||||
import org.apache.hadoop.hive.shims.ShimLoader;
|
||||
import org.apache.hadoop.hive.shims.Utils;
|
||||
import org.apache.hadoop.security.UserGroupInformation;
|
||||
import org.apache.hive.service.auth.HiveAuthFactory;
|
||||
|
|
|
@ -151,7 +151,7 @@ public class SessionManager extends CompositeService {
|
|||
}
|
||||
|
||||
private void startTimeoutChecker() {
|
||||
final long interval = Math.max(checkInterval, 3000l); // minimum 3 seconds
|
||||
final long interval = Math.max(checkInterval, 3000L); // minimum 3 seconds
|
||||
Runnable timeoutChecker = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
|
|
@ -722,8 +722,8 @@ public abstract class ThriftCLIService extends AbstractService implements TCLISe
|
|||
}
|
||||
|
||||
// If there's no authentication, then directly substitute the user
|
||||
if (HiveAuthFactory.AuthTypes.NONE.toString().
|
||||
equalsIgnoreCase(hiveConf.getVar(ConfVars.HIVE_SERVER2_AUTHENTICATION))) {
|
||||
if (HiveAuthFactory.AuthTypes.NONE.toString()
|
||||
.equalsIgnoreCase(hiveConf.getVar(ConfVars.HIVE_SERVER2_AUTHENTICATION))) {
|
||||
return proxyUser;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.apache.hive.service.cli.thrift;
|
|||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
@ -458,7 +457,7 @@ public class ThriftHttpServlet extends TServlet {
|
|||
|
||||
private String getUsername(HttpServletRequest request, String authType)
|
||||
throws HttpAuthenticationException {
|
||||
String creds[] = getAuthHeaderTokens(request, authType);
|
||||
String[] creds = getAuthHeaderTokens(request, authType);
|
||||
// Username must be present
|
||||
if (creds[0] == null || creds[0].isEmpty()) {
|
||||
throw new HttpAuthenticationException("Authorization header received " +
|
||||
|
@ -469,7 +468,7 @@ public class ThriftHttpServlet extends TServlet {
|
|||
|
||||
private String getPassword(HttpServletRequest request, String authType)
|
||||
throws HttpAuthenticationException {
|
||||
String creds[] = getAuthHeaderTokens(request, authType);
|
||||
String[] creds = getAuthHeaderTokens(request, authType);
|
||||
// Password must be present
|
||||
if (creds[1] == null || creds[1].isEmpty()) {
|
||||
throw new HttpAuthenticationException("Authorization header received " +
|
||||
|
|
|
@ -236,8 +236,8 @@ public class HiveServer2 extends CompositeService {
|
|||
/**
|
||||
* The executor interface for running the appropriate HiveServer2 command based on parsed options
|
||||
*/
|
||||
static interface ServerOptionsExecutor {
|
||||
public void execute();
|
||||
interface ServerOptionsExecutor {
|
||||
void execute();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue