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
42ccc44a
Commit
42ccc44a
authored
Aug 29, 2017
by
Richard Ding
Committed by
Madhan Neethiraj
Aug 29, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-2087: Allow Atlas server to bind on a specific address
Signed-off-by:
Madhan Neethiraj
<
madhan@apache.org
>
parent
f59284ad
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
54 additions
and
17 deletions
+54
-17
Atlas.java
webapp/src/main/java/org/apache/atlas/Atlas.java
+31
-1
EmbeddedServer.java
...ain/java/org/apache/atlas/web/service/EmbeddedServer.java
+10
-7
SecureEmbeddedServer.java
...va/org/apache/atlas/web/service/SecureEmbeddedServer.java
+2
-2
AtlasAuthenticationKerberosFilterTest.java
...as/web/filters/AtlasAuthenticationKerberosFilterTest.java
+1
-1
BaseSSLAndKerberosTest.java
...org/apache/atlas/web/security/BaseSSLAndKerberosTest.java
+1
-1
SSLTest.java
.../src/test/java/org/apache/atlas/web/security/SSLTest.java
+1
-1
SecureEmbeddedServerTest.java
...rg/apache/atlas/web/service/SecureEmbeddedServerTest.java
+2
-1
SecureEmbeddedServerTestBase.java
...pache/atlas/web/service/SecureEmbeddedServerTestBase.java
+6
-3
No files found.
webapp/src/main/java/org/apache/atlas/Atlas.java
View file @
42ccc44a
...
@@ -33,6 +33,10 @@ import org.slf4j.Logger;
...
@@ -33,6 +33,10 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.bridge.SLF4JBridgeHandler
;
import
org.slf4j.bridge.SLF4JBridgeHandler
;
import
java.io.IOException
;
import
java.net.InetAddress
;
import
java.net.NetworkInterface
;
import
java.net.SocketException
;
import
java.util.Iterator
;
import
java.util.Iterator
;
/**
/**
...
@@ -105,6 +109,17 @@ public final class Atlas {
...
@@ -105,6 +109,17 @@ public final class Atlas {
setApplicationHome
();
setApplicationHome
();
Configuration
configuration
=
ApplicationProperties
.
get
();
Configuration
configuration
=
ApplicationProperties
.
get
();
final
String
enableTLSFlag
=
configuration
.
getString
(
SecurityProperties
.
TLS_ENABLED
);
final
String
enableTLSFlag
=
configuration
.
getString
(
SecurityProperties
.
TLS_ENABLED
);
final
String
appHost
=
configuration
.
getString
(
SecurityProperties
.
BIND_ADDRESS
,
EmbeddedServer
.
ATLAS_DEFAULT_BIND_ADDRESS
);
if
(!
isLocalAddress
(
InetAddress
.
getByName
(
appHost
)))
{
String
msg
=
"Failed to start Atlas server. Address "
+
appHost
+
" does not belong to this host. Correct configuration parameter: "
+
SecurityProperties
.
BIND_ADDRESS
;
LOG
.
error
(
msg
);
throw
new
IOException
(
msg
);
}
final
int
appPort
=
getApplicationPort
(
cmd
,
enableTLSFlag
,
configuration
);
final
int
appPort
=
getApplicationPort
(
cmd
,
enableTLSFlag
,
configuration
);
System
.
setProperty
(
AtlasConstants
.
SYSTEM_PROPERTY_APP_PORT
,
String
.
valueOf
(
appPort
));
System
.
setProperty
(
AtlasConstants
.
SYSTEM_PROPERTY_APP_PORT
,
String
.
valueOf
(
appPort
));
final
boolean
enableTLS
=
isTLSEnabled
(
enableTLSFlag
,
appPort
);
final
boolean
enableTLS
=
isTLSEnabled
(
enableTLSFlag
,
appPort
);
...
@@ -112,7 +127,7 @@ public final class Atlas {
...
@@ -112,7 +127,7 @@ public final class Atlas {
showStartupInfo
(
buildConfiguration
,
enableTLS
,
appPort
);
showStartupInfo
(
buildConfiguration
,
enableTLS
,
appPort
);
server
=
EmbeddedServer
.
newServer
(
appPort
,
appPath
,
enableTLS
);
server
=
EmbeddedServer
.
newServer
(
app
Host
,
app
Port
,
appPath
,
enableTLS
);
installLogBridge
();
installLogBridge
();
server
.
start
();
server
.
start
();
...
@@ -164,6 +179,21 @@ public final class Atlas {
...
@@ -164,6 +179,21 @@ public final class Atlas {
System
.
getProperty
(
SecurityProperties
.
TLS_ENABLED
,
(
appPort
%
1000
)
==
443
?
"true"
:
"false"
)
:
enableTLSFlag
);
System
.
getProperty
(
SecurityProperties
.
TLS_ENABLED
,
(
appPort
%
1000
)
==
443
?
"true"
:
"false"
)
:
enableTLSFlag
);
}
}
private
static
boolean
isLocalAddress
(
InetAddress
addr
)
{
// Check if the address is any local or loop back
boolean
local
=
addr
.
isAnyLocalAddress
()
||
addr
.
isLoopbackAddress
();
// Check if the address is defined on any interface
if
(!
local
)
{
try
{
local
=
NetworkInterface
.
getByInetAddress
(
addr
)
!=
null
;
}
catch
(
SocketException
e
)
{
local
=
false
;
}
}
return
local
;
}
private
static
void
showStartupInfo
(
PropertiesConfiguration
buildConfiguration
,
boolean
enableTLS
,
int
appPort
)
{
private
static
void
showStartupInfo
(
PropertiesConfiguration
buildConfiguration
,
boolean
enableTLS
,
int
appPort
)
{
StringBuilder
buffer
=
new
StringBuilder
();
StringBuilder
buffer
=
new
StringBuilder
();
buffer
.
append
(
"\n############################################"
);
buffer
.
append
(
"\n############################################"
);
...
...
webapp/src/main/java/org/apache/atlas/web/service/EmbeddedServer.java
View file @
42ccc44a
...
@@ -41,9 +41,11 @@ import java.util.concurrent.TimeUnit;
...
@@ -41,9 +41,11 @@ import java.util.concurrent.TimeUnit;
public
class
EmbeddedServer
{
public
class
EmbeddedServer
{
public
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
EmbeddedServer
.
class
);
public
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
EmbeddedServer
.
class
);
public
static
final
String
ATLAS_DEFAULT_BIND_ADDRESS
=
"0.0.0.0"
;
protected
final
Server
server
;
protected
final
Server
server
;
public
EmbeddedServer
(
int
port
,
String
path
)
throws
IOException
{
public
EmbeddedServer
(
String
host
,
int
port
,
String
path
)
throws
IOException
{
int
queueSize
=
AtlasConfiguration
.
WEBSERVER_QUEUE_SIZE
.
getInt
();
int
queueSize
=
AtlasConfiguration
.
WEBSERVER_QUEUE_SIZE
.
getInt
();
LinkedBlockingQueue
<
Runnable
>
queue
=
new
LinkedBlockingQueue
<>(
queueSize
);
LinkedBlockingQueue
<
Runnable
>
queue
=
new
LinkedBlockingQueue
<>(
queueSize
);
...
@@ -54,7 +56,7 @@ public class EmbeddedServer {
...
@@ -54,7 +56,7 @@ public class EmbeddedServer {
new
ExecutorThreadPool
(
minThreads
,
maxThreads
,
keepAliveTime
,
TimeUnit
.
SECONDS
,
queue
);
new
ExecutorThreadPool
(
minThreads
,
maxThreads
,
keepAliveTime
,
TimeUnit
.
SECONDS
,
queue
);
server
=
new
Server
(
pool
);
server
=
new
Server
(
pool
);
Connector
connector
=
getConnector
(
port
);
Connector
connector
=
getConnector
(
host
,
port
);
server
.
addConnector
(
connector
);
server
.
addConnector
(
connector
);
WebAppContext
application
=
getWebAppContext
(
path
);
WebAppContext
application
=
getWebAppContext
(
path
);
...
@@ -69,15 +71,16 @@ public class EmbeddedServer {
...
@@ -69,15 +71,16 @@ public class EmbeddedServer {
return
application
;
return
application
;
}
}
public
static
EmbeddedServer
newServer
(
int
port
,
String
path
,
boolean
secure
)
throws
IOException
{
public
static
EmbeddedServer
newServer
(
String
host
,
int
port
,
String
path
,
boolean
secure
)
throws
IOException
{
if
(
secure
)
{
if
(
secure
)
{
return
new
SecureEmbeddedServer
(
port
,
path
);
return
new
SecureEmbeddedServer
(
host
,
port
,
path
);
}
else
{
}
else
{
return
new
EmbeddedServer
(
port
,
path
);
return
new
EmbeddedServer
(
host
,
port
,
path
);
}
}
}
}
protected
Connector
getConnector
(
int
port
)
throws
IOException
{
protected
Connector
getConnector
(
String
host
,
int
port
)
throws
IOException
{
HttpConfiguration
http_config
=
new
HttpConfiguration
();
HttpConfiguration
http_config
=
new
HttpConfiguration
();
// this is to enable large header sizes when Kerberos is enabled with AD
// this is to enable large header sizes when Kerberos is enabled with AD
final
int
bufferSize
=
AtlasConfiguration
.
WEBSERVER_REQUEST_BUFFER_SIZE
.
getInt
();;
final
int
bufferSize
=
AtlasConfiguration
.
WEBSERVER_REQUEST_BUFFER_SIZE
.
getInt
();;
...
@@ -86,7 +89,7 @@ public class EmbeddedServer {
...
@@ -86,7 +89,7 @@ public class EmbeddedServer {
ServerConnector
connector
=
new
ServerConnector
(
server
,
new
HttpConnectionFactory
(
http_config
));
ServerConnector
connector
=
new
ServerConnector
(
server
,
new
HttpConnectionFactory
(
http_config
));
connector
.
setPort
(
port
);
connector
.
setPort
(
port
);
connector
.
setHost
(
"0.0.0.0"
);
connector
.
setHost
(
host
);
return
connector
;
return
connector
;
}
}
...
...
webapp/src/main/java/org/apache/atlas/web/service/SecureEmbeddedServer.java
View file @
42ccc44a
...
@@ -60,8 +60,8 @@ public class SecureEmbeddedServer extends EmbeddedServer {
...
@@ -60,8 +60,8 @@ public class SecureEmbeddedServer extends EmbeddedServer {
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
SecureEmbeddedServer
.
class
);
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
SecureEmbeddedServer
.
class
);
public
SecureEmbeddedServer
(
int
port
,
String
path
)
throws
IOException
{
public
SecureEmbeddedServer
(
String
host
,
int
port
,
String
path
)
throws
IOException
{
super
(
port
,
path
);
super
(
host
,
port
,
path
);
}
}
protected
Connector
getConnector
(
int
port
)
throws
IOException
{
protected
Connector
getConnector
(
int
port
)
throws
IOException
{
...
...
webapp/src/test/java/org/apache/atlas/web/filters/AtlasAuthenticationKerberosFilterTest.java
View file @
42ccc44a
...
@@ -55,7 +55,7 @@ public class AtlasAuthenticationKerberosFilterTest extends BaseSecurityTest {
...
@@ -55,7 +55,7 @@ public class AtlasAuthenticationKerberosFilterTest extends BaseSecurityTest {
class
TestEmbeddedServer
extends
EmbeddedServer
{
class
TestEmbeddedServer
extends
EmbeddedServer
{
public
TestEmbeddedServer
(
int
port
,
String
path
)
throws
IOException
{
public
TestEmbeddedServer
(
int
port
,
String
path
)
throws
IOException
{
super
(
port
,
path
);
super
(
ATLAS_DEFAULT_BIND_ADDRESS
,
port
,
path
);
}
}
Server
getServer
()
{
Server
getServer
()
{
...
...
webapp/src/test/java/org/apache/atlas/web/security/BaseSSLAndKerberosTest.java
View file @
42ccc44a
...
@@ -49,7 +49,7 @@ public class BaseSSLAndKerberosTest extends BaseSecurityTest {
...
@@ -49,7 +49,7 @@ public class BaseSSLAndKerberosTest extends BaseSecurityTest {
class
TestSecureEmbeddedServer
extends
SecureEmbeddedServer
{
class
TestSecureEmbeddedServer
extends
SecureEmbeddedServer
{
public
TestSecureEmbeddedServer
(
int
port
,
String
path
)
throws
IOException
{
public
TestSecureEmbeddedServer
(
int
port
,
String
path
)
throws
IOException
{
super
(
port
,
path
);
super
(
ATLAS_DEFAULT_BIND_ADDRESS
,
port
,
path
);
}
}
public
Server
getServer
()
{
public
Server
getServer
()
{
...
...
webapp/src/test/java/org/apache/atlas/web/security/SSLTest.java
View file @
42ccc44a
...
@@ -52,7 +52,7 @@ public class SSLTest extends BaseSSLAndKerberosTest {
...
@@ -52,7 +52,7 @@ public class SSLTest extends BaseSSLAndKerberosTest {
class
TestSecureEmbeddedServer
extends
SecureEmbeddedServer
{
class
TestSecureEmbeddedServer
extends
SecureEmbeddedServer
{
public
TestSecureEmbeddedServer
(
int
port
,
String
path
)
throws
IOException
{
public
TestSecureEmbeddedServer
(
int
port
,
String
path
)
throws
IOException
{
super
(
port
,
path
);
super
(
ATLAS_DEFAULT_BIND_ADDRESS
,
port
,
path
);
}
}
public
Server
getServer
()
{
public
Server
getServer
()
{
...
...
webapp/src/test/java/org/apache/atlas/web/service/SecureEmbeddedServerTest.java
View file @
42ccc44a
...
@@ -49,7 +49,8 @@ public class SecureEmbeddedServerTest extends SecureEmbeddedServerTestBase {
...
@@ -49,7 +49,8 @@ public class SecureEmbeddedServerTest extends SecureEmbeddedServerTestBase {
ApplicationProperties
.
forceReload
();
ApplicationProperties
.
forceReload
();
SecureEmbeddedServer
secureEmbeddedServer
=
null
;
SecureEmbeddedServer
secureEmbeddedServer
=
null
;
try
{
try
{
secureEmbeddedServer
=
new
SecureEmbeddedServer
(
21443
,
TestUtils
.
getWarPath
())
{
secureEmbeddedServer
=
new
SecureEmbeddedServer
(
ATLAS_DEFAULT_HOST_ADDRESS
,
21443
,
TestUtils
.
getWarPath
())
{
@Override
@Override
protected
PropertiesConfiguration
getConfiguration
()
{
protected
PropertiesConfiguration
getConfiguration
()
{
return
configuration
;
return
configuration
;
...
...
webapp/src/test/java/org/apache/atlas/web/service/SecureEmbeddedServerTestBase.java
View file @
42ccc44a
...
@@ -105,7 +105,8 @@ public class SecureEmbeddedServerTestBase {
...
@@ -105,7 +105,8 @@ public class SecureEmbeddedServerTestBase {
originalConf
=
System
.
getProperty
(
"atlas.conf"
);
originalConf
=
System
.
getProperty
(
"atlas.conf"
);
System
.
clearProperty
(
"atlas.conf"
);
System
.
clearProperty
(
"atlas.conf"
);
ApplicationProperties
.
forceReload
();
ApplicationProperties
.
forceReload
();
secureEmbeddedServer
=
new
SecureEmbeddedServer
(
securePort
,
TestUtils
.
getWarPath
());
secureEmbeddedServer
=
new
SecureEmbeddedServer
(
EmbeddedServer
.
ATLAS_DEFAULT_BIND_ADDRESS
,
securePort
,
TestUtils
.
getWarPath
());
secureEmbeddedServer
.
server
.
start
();
secureEmbeddedServer
.
server
.
start
();
Assert
.
fail
(
"Should have thrown an exception"
);
Assert
.
fail
(
"Should have thrown an exception"
);
...
@@ -132,7 +133,8 @@ public class SecureEmbeddedServerTestBase {
...
@@ -132,7 +133,8 @@ public class SecureEmbeddedServerTestBase {
configuration
.
setProperty
(
CERT_STORES_CREDENTIAL_PROVIDER_PATH
,
providerUrl
);
configuration
.
setProperty
(
CERT_STORES_CREDENTIAL_PROVIDER_PATH
,
providerUrl
);
try
{
try
{
secureEmbeddedServer
=
new
SecureEmbeddedServer
(
securePort
,
TestUtils
.
getWarPath
())
{
secureEmbeddedServer
=
new
SecureEmbeddedServer
(
EmbeddedServer
.
ATLAS_DEFAULT_BIND_ADDRESS
,
securePort
,
TestUtils
.
getWarPath
())
{
@Override
@Override
protected
PropertiesConfiguration
getConfiguration
()
{
protected
PropertiesConfiguration
getConfiguration
()
{
return
configuration
;
return
configuration
;
...
@@ -159,7 +161,8 @@ public class SecureEmbeddedServerTestBase {
...
@@ -159,7 +161,8 @@ public class SecureEmbeddedServerTestBase {
setupCredentials
();
setupCredentials
();
try
{
try
{
secureEmbeddedServer
=
new
SecureEmbeddedServer
(
securePort
,
TestUtils
.
getWarPath
())
{
secureEmbeddedServer
=
new
SecureEmbeddedServer
(
EmbeddedServer
.
ATLAS_DEFAULT_BIND_ADDRESS
,
securePort
,
TestUtils
.
getWarPath
())
{
@Override
@Override
protected
PropertiesConfiguration
getConfiguration
()
{
protected
PropertiesConfiguration
getConfiguration
()
{
return
configuration
;
return
configuration
;
...
...
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