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
b178df2e
Commit
b178df2e
authored
Jul 14, 2015
by
Jon Maron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-36 listener port properties
parent
864cc5bc
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
78 additions
and
4 deletions
+78
-4
application.properties
src/conf/application.properties
+3
-0
Main.java
webapp/src/main/java/org/apache/atlas/Main.java
+20
-4
MainIT.java
webapp/src/test/java/org/apache/atlas/MainIT.java
+55
-0
No files found.
src/conf/application.properties
View file @
b178df2e
...
@@ -39,6 +39,9 @@ atlas.graph.index.search.elasticsearch.create.sleep=2000
...
@@ -39,6 +39,9 @@ atlas.graph.index.search.elasticsearch.create.sleep=2000
atlas.lineage.hive.table.schema.query.hive_table
=
hive_table where name='%s'
\,
columns
atlas.lineage.hive.table.schema.query.hive_table
=
hive_table where name='%s'
\,
columns
atlas.lineage.hive.table.schema.query.Table
=
Table where name='%s'
\,
columns
atlas.lineage.hive.table.schema.query.Table
=
Table where name='%s'
\,
columns
## Server port configuration
#atlas.server.http.port=21000
#atlas.server.https.port=21443
######### Security Properties #########
######### Security Properties #########
...
...
webapp/src/main/java/org/apache/atlas/Main.java
View file @
b178df2e
...
@@ -40,6 +40,10 @@ public final class Main {
...
@@ -40,6 +40,10 @@ public final class Main {
private
static
final
String
APP_PORT
=
"port"
;
private
static
final
String
APP_PORT
=
"port"
;
private
static
final
String
ATLAS_HOME
=
"atlas.home"
;
private
static
final
String
ATLAS_HOME
=
"atlas.home"
;
private
static
final
String
ATLAS_LOG_DIR
=
"atlas.log.dir"
;
private
static
final
String
ATLAS_LOG_DIR
=
"atlas.log.dir"
;
public
static
final
String
ATLAS_SERVER_HTTPS_PORT
=
"atlas.server.https.port"
;
public
static
final
String
ATLAS_SERVER_HTTP_PORT
=
"atlas.server.http.port"
;
/**
/**
* Prevent users from constructing this.
* Prevent users from constructing this.
...
@@ -47,7 +51,7 @@ public final class Main {
...
@@ -47,7 +51,7 @@ public final class Main {
private
Main
()
{
private
Main
()
{
}
}
pr
ivate
static
CommandLine
parseArgs
(
String
[]
args
)
throws
ParseException
{
pr
otected
static
CommandLine
parseArgs
(
String
[]
args
)
throws
ParseException
{
Options
options
=
new
Options
();
Options
options
=
new
Options
();
Option
opt
;
Option
opt
;
...
@@ -74,7 +78,7 @@ public final class Main {
...
@@ -74,7 +78,7 @@ public final class Main {
setApplicationHome
();
setApplicationHome
();
PropertiesConfiguration
configuration
=
PropertiesUtil
.
getApplicationProperties
();
PropertiesConfiguration
configuration
=
PropertiesUtil
.
getApplicationProperties
();
final
String
enableTLSFlag
=
configuration
.
getString
(
"atlas.enableTLS"
);
final
String
enableTLSFlag
=
configuration
.
getString
(
"atlas.enableTLS"
);
final
int
appPort
=
getApplicationPort
(
cmd
,
enableTLSFlag
);
final
int
appPort
=
getApplicationPort
(
cmd
,
enableTLSFlag
,
configuration
);
final
boolean
enableTLS
=
isTLSEnabled
(
enableTLSFlag
,
appPort
);
final
boolean
enableTLS
=
isTLSEnabled
(
enableTLSFlag
,
appPort
);
configuration
.
setProperty
(
"atlas.enableTLS"
,
String
.
valueOf
(
enableTLS
));
configuration
.
setProperty
(
"atlas.enableTLS"
,
String
.
valueOf
(
enableTLS
));
...
@@ -96,18 +100,30 @@ public final class Main {
...
@@ -96,18 +100,30 @@ public final class Main {
return
buildConfiguration
.
getString
(
"project.version"
);
return
buildConfiguration
.
getString
(
"project.version"
);
}
}
private
static
int
getApplicationPort
(
CommandLine
cmd
,
String
enableTLSFlag
)
{
static
int
getApplicationPort
(
CommandLine
cmd
,
String
enableTLSFlag
,
PropertiesConfiguration
configuration
)
{
final
int
appPort
;
final
int
appPort
;
if
(
cmd
.
hasOption
(
APP_PORT
))
{
if
(
cmd
.
hasOption
(
APP_PORT
))
{
appPort
=
Integer
.
valueOf
(
cmd
.
getOptionValue
(
APP_PORT
));
appPort
=
Integer
.
valueOf
(
cmd
.
getOptionValue
(
APP_PORT
));
}
else
{
}
else
{
// default : atlas.enableTLS is true
// default : atlas.enableTLS is true
appPort
=
StringUtils
.
isEmpty
(
enableTLSFlag
)
||
enableTLSFlag
.
equals
(
"true"
)
?
21443
:
21000
;
appPort
=
getPortValue
(
configuration
,
enableTLSFlag
)
;
}
}
return
appPort
;
return
appPort
;
}
}
private
static
int
getPortValue
(
PropertiesConfiguration
configuration
,
String
enableTLSFlag
)
{
int
appPort
;
assert
configuration
!=
null
;
appPort
=
StringUtils
.
isEmpty
(
enableTLSFlag
)
||
enableTLSFlag
.
equals
(
"true"
)
?
configuration
.
getInt
(
ATLAS_SERVER_HTTPS_PORT
,
21443
)
:
configuration
.
getInt
(
ATLAS_SERVER_HTTP_PORT
,
21000
);
return
appPort
;
}
private
static
boolean
isTLSEnabled
(
String
enableTLSFlag
,
int
appPort
)
{
private
static
boolean
isTLSEnabled
(
String
enableTLSFlag
,
int
appPort
)
{
return
Boolean
.
valueOf
(
StringUtils
.
isEmpty
(
enableTLSFlag
)
?
return
Boolean
.
valueOf
(
StringUtils
.
isEmpty
(
enableTLSFlag
)
?
System
.
getProperty
(
"atlas.enableTLS"
,
(
appPort
%
1000
)
==
443
?
"true"
:
"false"
)
:
enableTLSFlag
);
System
.
getProperty
(
"atlas.enableTLS"
,
(
appPort
%
1000
)
==
443
?
"true"
:
"false"
)
:
enableTLSFlag
);
...
...
webapp/src/test/java/org/apache/atlas/MainIT.java
0 → 100644
View file @
b178df2e
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
apache
.
atlas
;
import
org.apache.commons.cli.CommandLine
;
import
org.apache.commons.configuration.PropertiesConfiguration
;
import
org.testng.Assert
;
import
org.testng.annotations.Test
;
/**
*
*/
public
class
MainIT
{
@Test
public
void
testPortSelection
()
throws
Exception
{
PropertiesConfiguration
config
=
new
PropertiesConfiguration
();
// test ports via config
config
.
setProperty
(
Main
.
ATLAS_SERVER_HTTP_PORT
,
21001
);
config
.
setProperty
(
Main
.
ATLAS_SERVER_HTTPS_PORT
,
22443
);
int
port
=
Main
.
getApplicationPort
(
Main
.
parseArgs
(
new
String
[]
{}),
"false"
,
config
);
Assert
.
assertEquals
(
21001
,
port
,
"wrong http port"
);
port
=
Main
.
getApplicationPort
(
Main
.
parseArgs
(
new
String
[]
{}),
"true"
,
config
);
Assert
.
assertEquals
(
22443
,
port
,
"wrong https port"
);
// test defaults
port
=
Main
.
getApplicationPort
(
Main
.
parseArgs
(
new
String
[]
{}),
"false"
,
new
PropertiesConfiguration
()
);
Assert
.
assertEquals
(
21000
,
port
,
"wrong http port"
);
port
=
Main
.
getApplicationPort
(
Main
.
parseArgs
(
new
String
[]
{}),
"true"
,
new
PropertiesConfiguration
()
);
Assert
.
assertEquals
(
21443
,
port
,
"wrong https port"
);
// test command line override
CommandLine
commandLine
=
Main
.
parseArgs
(
new
String
[]
{
"--port"
,
"22000"
});
port
=
Main
.
getApplicationPort
(
commandLine
,
"true"
,
config
);
Assert
.
assertEquals
(
22000
,
port
,
"wrong https port"
);
port
=
Main
.
getApplicationPort
(
commandLine
,
"false"
,
config
);
Assert
.
assertEquals
(
22000
,
port
,
"wrong https port"
);
}
}
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