Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
atlas
Project
Overview
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
dataplatform
atlas
Commits
0a81c250
Commit
0a81c250
authored
Apr 22, 2019
by
nixonrodrigues
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-3129 Fix SSL Truststore reloader leak from AtlasBaseClient
Change-Id: I5af8c26a41a7010de645ddaa6869c3ce15723f43
parent
4d6169f5
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
76 additions
and
18 deletions
+76
-18
HBaseBridge.java
.../main/java/org/apache/atlas/hbase/bridge/HBaseBridge.java
+5
-2
HiveMetaStoreBridge.java
...ava/org/apache/atlas/hive/bridge/HiveMetaStoreBridge.java
+5
-1
KafkaBridge.java
.../main/java/org/apache/atlas/kafka/bridge/KafkaBridge.java
+5
-1
AtlasBaseClient.java
...ommon/src/main/java/org/apache/atlas/AtlasBaseClient.java
+11
-2
SecureClientUtils.java
...ain/java/org/apache/atlas/security/SecureClientUtils.java
+23
-9
QuickStart.java
...p/src/main/java/org/apache/atlas/examples/QuickStart.java
+13
-1
QuickStartV2.java
...src/main/java/org/apache/atlas/examples/QuickStartV2.java
+14
-2
No files found.
addons/hbase-bridge/src/main/java/org/apache/atlas/hbase/bridge/HBaseBridge.java
View file @
0a81c250
...
...
@@ -42,7 +42,6 @@ import org.apache.hadoop.hbase.HBaseConfiguration;
import
org.apache.hadoop.hbase.NamespaceDescriptor
;
import
org.apache.hadoop.hbase.client.Admin
;
import
org.apache.hadoop.hbase.client.ColumnFamilyDescriptor
;
import
org.apache.hadoop.hbase.client.ColumnFamilyDescriptor
;
import
org.apache.hadoop.hbase.client.Connection
;
import
org.apache.hadoop.hbase.client.ConnectionFactory
;
import
org.apache.hadoop.hbase.client.HBaseAdmin
;
...
...
@@ -123,6 +122,7 @@ public class HBaseBridge {
public
static
void
main
(
String
[]
args
)
{
int
exitCode
=
EXIT_CODE_FAILED
;
AtlasClientV2
atlasClientV2
=
null
;
try
{
Options
options
=
new
Options
();
...
...
@@ -142,7 +142,6 @@ public class HBaseBridge {
urls
=
new
String
[]
{
DEFAULT_ATLAS_URL
};
}
final
AtlasClientV2
atlasClientV2
;
if
(!
AuthenticationUtil
.
isKerberosAuthenticationEnabled
())
{
String
[]
basicAuthUsernamePassword
=
AuthenticationUtil
.
getBasicAuthenticationInput
();
...
...
@@ -195,6 +194,10 @@ public class HBaseBridge {
System
.
out
.
println
(
"ImportHBaseEntities failed. Please check the log file for the detailed error message"
);
LOG
.
error
(
"ImportHBaseEntities failed"
,
e
);
}
finally
{
if
(
atlasClientV2
!=
null
)
{
atlasClientV2
.
close
();
}
}
System
.
exit
(
exitCode
);
...
...
addons/hive-bridge/src/main/java/org/apache/atlas/hive/bridge/HiveMetaStoreBridge.java
View file @
0a81c250
...
...
@@ -103,6 +103,7 @@ public class HiveMetaStoreBridge {
public
static
void
main
(
String
[]
args
)
{
int
exitCode
=
EXIT_CODE_FAILED
;
AtlasClientV2
atlasClientV2
=
null
;
try
{
Options
options
=
new
Options
();
...
...
@@ -123,7 +124,6 @@ public class HiveMetaStoreBridge {
atlasEndpoint
=
new
String
[]
{
DEFAULT_ATLAS_URL
};
}
final
AtlasClientV2
atlasClientV2
;
if
(!
AuthenticationUtil
.
isKerberosAuthenticationEnabled
())
{
String
[]
basicAuthUsernamePassword
=
AuthenticationUtil
.
getBasicAuthenticationInput
();
...
...
@@ -174,6 +174,10 @@ public class HiveMetaStoreBridge {
printUsage
();
}
catch
(
Exception
e
)
{
LOG
.
error
(
"Import failed"
,
e
);
}
finally
{
if
(
atlasClientV2
!=
null
)
{
atlasClientV2
.
close
();
}
}
System
.
exit
(
exitCode
);
...
...
addons/kafka-bridge/src/main/java/org/apache/atlas/kafka/bridge/KafkaBridge.java
View file @
0a81c250
...
...
@@ -88,6 +88,7 @@ public class KafkaBridge {
public
static
void
main
(
String
[]
args
)
{
int
exitCode
=
EXIT_CODE_FAILED
;
AtlasClientV2
atlasClientV2
=
null
;
try
{
Options
options
=
new
Options
();
...
...
@@ -105,7 +106,6 @@ public class KafkaBridge {
urls
=
new
String
[]
{
DEFAULT_ATLAS_URL
};
}
final
AtlasClientV2
atlasClientV2
;
if
(!
AuthenticationUtil
.
isKerberosAuthenticationEnabled
())
{
String
[]
basicAuthUsernamePassword
=
AuthenticationUtil
.
getBasicAuthenticationInput
();
...
...
@@ -148,6 +148,10 @@ public class KafkaBridge {
System
.
out
.
println
(
"ImportKafkaEntities failed. Please check the log file for the detailed error message"
);
e
.
printStackTrace
();
LOG
.
error
(
"ImportKafkaEntities failed"
,
e
);
}
finally
{
if
(
atlasClientV2
!=
null
)
{
atlasClientV2
.
close
();
}
}
System
.
exit
(
exitCode
);
...
...
client/common/src/main/java/org/apache/atlas/AtlasBaseClient.java
View file @
0a81c250
...
...
@@ -114,6 +114,8 @@ public abstract class AtlasBaseClient {
private
boolean
retryEnabled
=
false
;
private
Cookie
cookie
=
null
;
private
SecureClientUtils
clientUtils
;
protected
AtlasBaseClient
()
{
}
...
...
@@ -282,14 +284,15 @@ public abstract class AtlasBaseClient {
}
final
URLConnectionClientHandler
handler
;
clientUtils
=
new
SecureClientUtils
();
boolean
isKerberosEnabled
=
AuthenticationUtil
.
isKerberosAuthenticationEnabled
(
ugi
);
if
(
isKerberosEnabled
)
{
handler
=
SecureC
lientUtils
.
getClientConnectionHandler
(
config
,
configuration
,
doAsUser
,
ugi
);
handler
=
c
lientUtils
.
getClientConnectionHandler
(
config
,
configuration
,
doAsUser
,
ugi
);
}
else
{
if
(
configuration
.
getBoolean
(
TLS_ENABLED
,
false
))
{
handler
=
SecureC
lientUtils
.
getUrlConnectionClientHandler
();
handler
=
c
lientUtils
.
getUrlConnectionClientHandler
();
}
else
{
handler
=
new
URLConnectionClientHandler
();
}
...
...
@@ -300,6 +303,12 @@ public abstract class AtlasBaseClient {
return
client
;
}
public
void
close
()
{
if
(
clientUtils
!=
null
)
{
clientUtils
.
destroyFactory
();
}
}
@VisibleForTesting
protected
String
determineActiveServiceURL
(
String
[]
baseUrls
,
Client
client
)
{
if
(
baseUrls
.
length
==
0
)
{
...
...
client/common/src/main/java/org/apache/atlas/security/SecureClientUtils.java
View file @
0a81c250
...
...
@@ -57,9 +57,10 @@ public class SecureClientUtils {
public
final
static
int
DEFAULT_SOCKET_TIMEOUT_IN_MSECS
=
1
*
60
*
1000
;
// 1 minute
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
SecureClientUtils
.
class
);
private
SSLFactory
factory
=
null
;
public
static
URLConnectionClientHandler
getClientConnectionHandler
(
DefaultClientConfig
config
,
public
URLConnectionClientHandler
getClientConnectionHandler
(
DefaultClientConfig
config
,
org
.
apache
.
commons
.
configuration
.
Configuration
clientConfig
,
String
doAsUser
,
final
UserGroupInformation
ugi
)
{
config
.
getProperties
().
put
(
URLConnectionClientHandler
.
PROPERTY_HTTP_URL_CONNECTION_SET_METHOD_WORKAROUND
,
true
);
...
...
@@ -125,7 +126,7 @@ public class SecureClientUtils {
}
};
private
static
ConnectionConfigurator
newConnConfigurator
(
Configuration
conf
)
{
private
ConnectionConfigurator
newConnConfigurator
(
Configuration
conf
)
{
try
{
return
newSslConnConfigurator
(
DEFAULT_SOCKET_TIMEOUT_IN_MSECS
,
conf
);
}
catch
(
Exception
e
)
{
...
...
@@ -134,14 +135,12 @@ public class SecureClientUtils {
}
}
private
static
ConnectionConfigurator
newSslConnConfigurator
(
final
int
timeout
,
Configuration
conf
)
private
ConnectionConfigurator
newSslConnConfigurator
(
final
int
timeout
,
Configuration
conf
)
throws
IOException
,
GeneralSecurityException
{
final
SSLFactory
factory
;
final
SSLSocketFactory
sf
;
final
HostnameVerifier
hv
;
factory
=
new
SSLFactory
(
SSLFactory
.
Mode
.
CLIENT
,
conf
);
factory
.
init
();
factory
=
getSSLFactory
(
conf
);
sf
=
factory
.
createSSLSocketFactory
();
hv
=
factory
.
getHostnameVerifier
();
...
...
@@ -159,6 +158,22 @@ public class SecureClientUtils {
};
}
public
SSLFactory
getSSLFactory
(
Configuration
conf
)
throws
IOException
,
GeneralSecurityException
{
if
(
factory
==
null
)
{
factory
=
new
SSLFactory
(
SSLFactory
.
Mode
.
CLIENT
,
conf
);
factory
.
init
();
}
return
factory
;
}
public
void
destroyFactory
()
{
if
(
factory
!=
null
)
{
factory
.
destroy
();
factory
=
null
;
}
}
private
static
void
setTimeouts
(
URLConnection
connection
,
int
socketTimeout
)
{
connection
.
setConnectTimeout
(
socketTimeout
);
connection
.
setReadTimeout
(
socketTimeout
);
...
...
@@ -210,7 +225,7 @@ public class SecureClientUtils {
}
}
public
static
URLConnectionClientHandler
getUrlConnectionClientHandler
()
{
public
URLConnectionClientHandler
getUrlConnectionClientHandler
()
{
return
new
URLConnectionClientHandler
(
new
HttpURLConnectionFactory
()
{
@Override
public
HttpURLConnection
getHttpURLConnection
(
URL
url
)
...
...
@@ -230,8 +245,7 @@ public class SecureClientUtils {
UserGroupInformation
.
setConfiguration
(
conf
);
HttpsURLConnection
c
=
(
HttpsURLConnection
)
connection
;
factory
=
new
SSLFactory
(
SSLFactory
.
Mode
.
CLIENT
,
conf
);
factory
.
init
();
factory
=
getSSLFactory
(
conf
);
sf
=
factory
.
createSSLSocketFactory
();
hv
=
factory
.
getHostnameVerifier
();
c
.
setSSLSocketFactory
(
sf
);
...
...
webapp/src/main/java/org/apache/atlas/examples/QuickStart.java
View file @
0a81c250
...
...
@@ -77,8 +77,9 @@ public class QuickStart {
@VisibleForTesting
static
void
runQuickstart
(
String
[]
args
,
String
[]
basicAuthUsernamePassword
)
throws
Exception
{
String
[]
urls
=
getServerUrl
(
args
);
QuickStart
quickStart
;
QuickStart
quickStart
=
null
;
try
{
if
(!
AuthenticationUtil
.
isKerberosAuthenticationEnabled
())
{
quickStart
=
new
QuickStart
(
urls
,
basicAuthUsernamePassword
);
}
else
{
...
...
@@ -93,6 +94,11 @@ public class QuickStart {
// Shows some search queries using DSL based on types
quickStart
.
search
();
}
finally
{
if
(
quickStart
!=
null
)
{
quickStart
.
closeConnection
();
}
}
}
static
String
[]
getServerUrl
(
String
[]
args
)
throws
AtlasException
{
...
...
@@ -492,4 +498,10 @@ public class QuickStart {
throw
new
AtlasBaseException
(
AtlasErrorCode
.
QUICK_START
,
e
,
"one or more dsl queries failed"
);
}
}
private
void
closeConnection
()
{
if
(
metadataServiceClient
!=
null
)
{
metadataServiceClient
.
close
();
}
}
}
webapp/src/main/java/org/apache/atlas/examples/QuickStartV2.java
View file @
0a81c250
...
...
@@ -151,8 +151,8 @@ public class QuickStartV2 {
static
void
runQuickstart
(
String
[]
args
,
String
[]
basicAuthUsernamePassword
)
throws
Exception
{
String
[]
urls
=
getServerUrl
(
args
);
QuickStartV2
quickStartV2
;
QuickStartV2
quickStartV2
=
null
;
try
{
if
(!
AuthenticationUtil
.
isKerberosAuthenticationEnabled
())
{
quickStartV2
=
new
QuickStartV2
(
urls
,
basicAuthUsernamePassword
);
}
else
{
...
...
@@ -170,6 +170,11 @@ public class QuickStartV2 {
// Shows some lineage information on entity
quickStartV2
.
lineage
();
}
finally
{
if
(
quickStartV2
!=
null
)
{
quickStartV2
.
closeConnection
();
}
}
}
...
...
@@ -647,4 +652,10 @@ public class QuickStartV2 {
return
tableEntity
.
getGuid
();
}
private
void
closeConnection
()
{
if
(
atlasClientV2
!=
null
)
{
atlasClientV2
.
close
();
}
}
}
\ No newline at end of file
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