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
4152bc6d
Commit
4152bc6d
authored
Feb 14, 2018
by
Ashutosh Mestry
Committed by
Madhan Neethiraj
Feb 14, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-2448: added default values for JanusGraph cache configurations to improve performance
Signed-off-by:
Madhan Neethiraj
<
madhan@apache.org
>
parent
340f8637
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
3 deletions
+77
-3
ApplicationProperties.java
...src/main/java/org/apache/atlas/ApplicationProperties.java
+56
-3
ApplicationPropertiesTest.java
...test/java/org/apache/atlas/ApplicationPropertiesTest.java
+21
-0
No files found.
intg/src/main/java/org/apache/atlas/ApplicationProperties.java
View file @
4152bc6d
...
...
@@ -21,6 +21,7 @@ import org.apache.atlas.security.InMemoryJAASConfiguration;
import
org.apache.commons.configuration.Configuration
;
import
org.apache.commons.configuration.ConfigurationException
;
import
org.apache.commons.configuration.PropertiesConfiguration
;
import
org.apache.commons.lang.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -29,6 +30,7 @@ import java.io.FileInputStream;
import
java.io.FileNotFoundException
;
import
java.io.InputStream
;
import
java.net.URL
;
import
java.util.AbstractMap.SimpleEntry
;
import
java.util.Iterator
;
/**
...
...
@@ -36,10 +38,15 @@ import java.util.Iterator;
*/
public
final
class
ApplicationProperties
extends
PropertiesConfiguration
{
public
static
final
String
ATLAS_CONFIGURATION_DIRECTORY_PROPERTY
=
"atlas.conf"
;
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
ApplicationProperties
.
class
);
public
static
final
String
APPLICATION_PROPERTIES
=
"atlas-application.properties"
;
public
static
final
String
APPLICATION_PROPERTIES
=
"atlas-application.properties"
;
public
static
final
SimpleEntry
<
String
,
String
>
DB_CACHE_CONF
=
new
SimpleEntry
<>(
"atlas.graph.cache.db-cache"
,
"true"
);
public
static
final
SimpleEntry
<
String
,
String
>
DB_CACHE_CLEAN_WAIT_CONF
=
new
SimpleEntry
<>(
"atlas.graph.cache.db-cache-clean-wait"
,
"20"
);
public
static
final
SimpleEntry
<
String
,
String
>
DB_CACHE_SIZE_CONF
=
new
SimpleEntry
<>(
"atlas.graph.cache.db-cache-size"
,
"0.5"
);
public
static
final
SimpleEntry
<
String
,
String
>
DB_TX_CACHE_SIZE_CONF
=
new
SimpleEntry
<>(
"atlas.graph.cache.tx-cache.size"
,
"15000"
);
public
static
final
SimpleEntry
<
String
,
String
>
DB_CACHE_TX_DIRTY_SIZE_CONF
=
new
SimpleEntry
<>(
"atlas.graph.cache.tx-dirty-size"
,
"120"
);
private
static
volatile
Configuration
instance
=
null
;
...
...
@@ -90,7 +97,12 @@ public final class ApplicationProperties extends PropertiesConfiguration {
LOG
.
info
(
"Loading {} from {}"
,
fileName
,
url
);
Configuration
configuration
=
new
ApplicationProperties
(
url
).
interpolatedConfiguration
();
ApplicationProperties
appProperties
=
new
ApplicationProperties
(
url
);
appProperties
.
setDefaults
();
Configuration
configuration
=
appProperties
.
interpolatedConfiguration
();
logConfiguration
(
configuration
);
return
configuration
;
}
catch
(
Exception
e
)
{
...
...
@@ -131,6 +143,21 @@ public final class ApplicationProperties extends PropertiesConfiguration {
}
}
public
static
Class
getClass
(
String
fullyQualifiedClassName
,
Class
assignableClass
)
throws
AtlasException
{
try
{
Class
<?>
clazz
=
Class
.
forName
(
fullyQualifiedClassName
);
if
(
assignableClass
==
null
||
assignableClass
.
isAssignableFrom
(
clazz
))
{
return
clazz
;
}
else
{
String
message
=
"Class "
+
clazz
.
getName
()
+
" is not assignable to class "
+
assignableClass
.
getName
();
LOG
.
error
(
message
);
throw
new
AtlasException
(
message
);
}
}
catch
(
Exception
e
)
{
throw
new
AtlasException
(
e
);
}
}
/**
* Get the specified property as an {@link InputStream}.
* If the property is not set, then the specified default filename
...
...
@@ -200,4 +227,30 @@ public final class ApplicationProperties extends PropertiesConfiguration {
}
return
inStr
;
}
private
void
setDefaults
()
{
setDbCacheConfDefaults
();
}
void
setDefault
(
SimpleEntry
<
String
,
String
>
keyValueDefault
,
String
currentValue
)
{
if
(
StringUtils
.
isNotEmpty
(
currentValue
))
{
return
;
}
clearPropertyDirect
(
keyValueDefault
.
getKey
());
addPropertyDirect
(
keyValueDefault
.
getKey
(),
keyValueDefault
.
getValue
());
LOG
.
info
(
"Property (set to default) {} = {}"
,
keyValueDefault
.
getKey
(),
keyValueDefault
.
getValue
());
}
private
void
setDbCacheConfDefaults
()
{
SimpleEntry
<
String
,
String
>
keyValues
[]
=
new
SimpleEntry
[]{
DB_CACHE_CONF
,
DB_CACHE_CLEAN_WAIT_CONF
,
DB_CACHE_SIZE_CONF
,
DB_TX_CACHE_SIZE_CONF
,
DB_CACHE_TX_DIRTY_SIZE_CONF
};
for
(
SimpleEntry
<
String
,
String
>
kv
:
keyValues
)
{
String
currentValue
=
getString
(
kv
.
getKey
());
setDefault
(
kv
,
currentValue
);
}
}
}
intg/src/test/java/org/apache/atlas/ApplicationPropertiesTest.java
View file @
4152bc6d
...
...
@@ -18,8 +18,14 @@
package
org
.
apache
.
atlas
;
import
java.io.InputStream
;
import
java.net.MalformedURLException
;
import
java.net.URL
;
import
java.util.AbstractMap
;
import
com.sun.jersey.json.impl.provider.entity.JSONArrayProvider
;
import
org.apache.commons.configuration.Configuration
;
import
org.apache.commons.configuration.ConfigurationException
;
import
org.springframework.cache.interceptor.SimpleKey
;
import
org.testng.annotations.Test
;
import
static
org
.
testng
.
Assert
.*;
...
...
@@ -126,4 +132,19 @@ public class ApplicationPropertiesTest {
}
}
}
@Test
public
void
verifySetDefault
()
throws
AtlasException
{
Configuration
props
=
ApplicationProperties
.
get
(
"test.properties"
);
ApplicationProperties
aProps
=
(
ApplicationProperties
)
props
;
String
defaultValue
=
"someValue"
;
String
someKey
=
"someKey"
;
AbstractMap
.
SimpleEntry
<
String
,
String
>
defaultKV
=
new
AbstractMap
.
SimpleEntry
<>(
someKey
,
defaultValue
);
aProps
.
setDefault
(
defaultKV
,
"newValue"
);
assertNotEquals
(
props
.
getString
(
someKey
),
defaultValue
);
aProps
.
setDefault
(
defaultKV
,
""
);
assertEquals
(
props
.
getString
(
someKey
),
defaultValue
);
}
}
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