Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dinky
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangpeng
dinky
Commits
355bfd02
Unverified
Commit
355bfd02
authored
Nov 28, 2022
by
Forus
Committed by
GitHub
Nov 28, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Feature-1337]新增Yarn-Session模式,Kerberos环境票据认证 (#1339)
parent
16b18f10
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
80 additions
and
1 deletion
+80
-1
pom.xml
dlink-executor/pom.xml
+17
-0
Executor.java
...k-executor/src/main/java/com/dlink/executor/Executor.java
+63
-1
No files found.
dlink-executor/pom.xml
View file @
355bfd02
...
@@ -30,6 +30,7 @@
...
@@ -30,6 +30,7 @@
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<maven.compiler.source>
${target.java.version}
</maven.compiler.source>
<maven.compiler.source>
${target.java.version}
</maven.compiler.source>
<maven.compiler.target>
${target.java.version}
</maven.compiler.target>
<maven.compiler.target>
${target.java.version}
</maven.compiler.target>
<hadoop.version>
3.1.0
</hadoop.version>
</properties>
</properties>
<dependencies>
<dependencies>
...
@@ -57,6 +58,22 @@
...
@@ -57,6 +58,22 @@
<artifactId>
dlink-metadata-mysql
</artifactId>
<artifactId>
dlink-metadata-mysql
</artifactId>
<scope>
test
</scope>
<scope>
test
</scope>
</dependency>
</dependency>
<dependency>
<groupId>
org.apache.hadoop
</groupId>
<artifactId>
hadoop-common
</artifactId>
<version>
${hadoop.version}
</version>
<scope>
provided
</scope>
<exclusions>
<exclusion>
<groupId>
com.google.guava
</groupId>
<artifactId>
guava
</artifactId>
</exclusion>
<exclusion>
<groupId>
javax.servlet
</groupId>
<artifactId>
servlet-api
</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</dependencies>
<profiles>
<profiles>
...
...
dlink-executor/src/main/java/com/dlink/executor/Executor.java
View file @
355bfd02
...
@@ -43,7 +43,10 @@ import org.apache.flink.table.api.TableConfig;
...
@@ -43,7 +43,10 @@ import org.apache.flink.table.api.TableConfig;
import
org.apache.flink.table.api.TableResult
;
import
org.apache.flink.table.api.TableResult
;
import
org.apache.flink.table.catalog.CatalogManager
;
import
org.apache.flink.table.catalog.CatalogManager
;
import
org.apache.flink.util.JarUtils
;
import
org.apache.flink.util.JarUtils
;
import
org.apache.hadoop.security.UserGroupInformation
;
import
java.io.IOException
;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Method
;
import
java.net.URL
;
import
java.net.URL
;
import
java.net.URLClassLoader
;
import
java.net.URLClassLoader
;
...
@@ -58,12 +61,15 @@ import com.fasterxml.jackson.core.JsonProcessingException;
...
@@ -58,12 +61,15 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.node.ObjectNode
;
import
com.fasterxml.jackson.databind.node.ObjectNode
;
import
lombok.extern.slf4j.Slf4j
;
/**
/**
* Executor
* Executor
*
*
* @author wenmo
* @author wenmo
* @since 2021/11/17
* @since 2021/11/17
**/
**/
@Slf4j
public
abstract
class
Executor
{
public
abstract
class
Executor
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
Executor
.
class
);
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
Executor
.
class
);
...
@@ -239,12 +245,68 @@ public abstract class Executor {
...
@@ -239,12 +245,68 @@ public abstract class Executor {
return
flinkInterceptorResult
.
getTableResult
();
return
flinkInterceptorResult
.
getTableResult
();
}
}
if
(!
flinkInterceptorResult
.
isNoExecute
())
{
if
(!
flinkInterceptorResult
.
isNoExecute
())
{
this
.
loginFromKeytabIfNeed
();
return
stEnvironment
.
executeSql
(
statement
);
return
stEnvironment
.
executeSql
(
statement
);
}
else
{
}
else
{
return
CustomTableResultImpl
.
TABLE_RESULT_OK
;
return
CustomTableResultImpl
.
TABLE_RESULT_OK
;
}
}
}
}
private
void
reset
()
{
try
{
if
(
UserGroupInformation
.
isLoginKeytabBased
())
{
Method
reset
=
UserGroupInformation
.
class
.
getDeclaredMethod
(
"reset"
);
reset
.
invoke
(
UserGroupInformation
.
class
);
log
.
info
(
"Reset kerberos authentication..."
);
}
}
catch
(
NoSuchMethodException
|
IllegalAccessException
|
InvocationTargetException
e
)
{
throw
new
RuntimeException
(
e
);
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
private
void
loginFromKeytabIfNeed
()
{
this
.
reset
();
setConfig
.
forEach
((
k
,
v
)
->
log
.
debug
(
"setConfig key: [{}], value: [{}]"
,
k
,
v
));
String
krb5ConfPath
=
(
String
)
setConfig
.
getOrDefault
(
"java.security.krb5.conf"
,
""
);
String
keytabPath
=
(
String
)
setConfig
.
getOrDefault
(
"security.kerberos.login.keytab"
,
""
);
String
principal
=
(
String
)
setConfig
.
getOrDefault
(
"security.kerberos.login.principal"
,
""
);
if
(
krb5ConfPath
.
isEmpty
()
&&
keytabPath
.
isEmpty
()
&&
principal
.
isEmpty
())
{
log
.
info
(
"Simple authentication mode"
);
return
;
}
log
.
info
(
"Kerberos authentication mode"
);
if
(
krb5ConfPath
.
isEmpty
())
{
log
.
error
(
"Parameter [java.security.krb5.conf] is null or empty."
);
return
;
}
if
(
keytabPath
.
isEmpty
())
{
log
.
error
(
"Parameter [security.kerberos.login.keytab] is null or empty."
);
return
;
}
if
(
principal
.
isEmpty
())
{
log
.
error
(
"Parameter [security.kerberos.login.principal] is null or empty."
);
return
;
}
System
.
setProperty
(
"java.security.krb5.conf"
,
krb5ConfPath
);
org
.
apache
.
hadoop
.
conf
.
Configuration
config
=
new
org
.
apache
.
hadoop
.
conf
.
Configuration
();
config
.
set
(
"hadoop.security.authentication"
,
"Kerberos"
);
config
.
setBoolean
(
"hadoop.security.authorization"
,
true
);
UserGroupInformation
.
setConfiguration
(
config
);
try
{
UserGroupInformation
.
loginUserFromKeytab
(
principal
,
keytabPath
);
log
.
error
(
"Kerberos [{}] authentication success."
,
UserGroupInformation
.
getLoginUser
().
getUserName
());
}
catch
(
IOException
e
)
{
log
.
error
(
"Kerberos authentication failed."
);
e
.
printStackTrace
();
}
}
/**
/**
* init udf
* init udf
*
*
...
@@ -254,7 +316,7 @@ public abstract class Executor {
...
@@ -254,7 +316,7 @@ public abstract class Executor {
JarUtils
.
getJarFiles
(
udfFilePath
).
forEach
(
Executor:
:
loadJar
);
JarUtils
.
getJarFiles
(
udfFilePath
).
forEach
(
Executor:
:
loadJar
);
}
}
public
void
initPyUDF
(
String
executable
,
String
...
udfPyFilePath
)
{
public
void
initPyUDF
(
String
executable
,
String
...
udfPyFilePath
)
{
if
(
udfPyFilePath
==
null
||
udfPyFilePath
.
length
==
0
)
{
if
(
udfPyFilePath
==
null
||
udfPyFilePath
.
length
==
0
)
{
return
;
return
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment