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
d23d61b2
Commit
d23d61b2
authored
Jul 21, 2017
by
ashutoshm
Committed by
Madhan Neethiraj
Jul 21, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-1960: fixed handling of import/export APIs in HA configuration
Signed-off-by:
Madhan Neethiraj
<
madhan@apache.org
>
parent
e0d2cdc2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
8 deletions
+42
-8
ActiveServerFilter.java
...java/org/apache/atlas/web/filters/ActiveServerFilter.java
+14
-1
ActiveServerFilterTest.java
.../org/apache/atlas/web/filters/ActiveServerFilterTest.java
+28
-7
No files found.
webapp/src/main/java/org/apache/atlas/web/filters/ActiveServerFilter.java
View file @
d23d61b2
...
...
@@ -100,10 +100,23 @@ public class ActiveServerFilter implements Filter {
}
}
final
String
adminUriNotFiltered
[]
=
{
"/admin/export"
,
"/admin/import"
,
"/admin/importfile"
};
private
boolean
isFilteredURI
(
ServletRequest
servletRequest
)
{
HttpServletRequest
httpServletRequest
=
(
HttpServletRequest
)
servletRequest
;
String
requestURI
=
httpServletRequest
.
getRequestURI
();
return
requestURI
.
contains
(
"/admin/"
);
if
(
requestURI
.
contains
(
"/admin/"
))
{
for
(
String
s
:
adminUriNotFiltered
)
{
if
(
requestURI
.
contains
(
s
))
{
LOG
.
error
(
"URL not supported in HA mode: {}"
,
requestURI
);
return
false
;
}
}
return
true
;
}
else
{
return
false
;
}
}
boolean
isInstanceActive
()
{
...
...
webapp/src/test/java/org/apache/atlas/web/filters/ActiveServerFilterTest.java
View file @
d23d61b2
...
...
@@ -6,9 +6,9 @@
* 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
*
*
<p>
* http://www.apache.org/licenses/LICENSE-2.0
*
<p>
* 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.
...
...
@@ -99,7 +99,28 @@ public class ActiveServerFilterTest {
activeServerFilter
.
doFilter
(
servletRequest
,
servletResponse
,
filterChain
);
verify
(
servletResponse
).
sendRedirect
(
ACTIVE_SERVER_ADDRESS
+
"types"
);
verify
(
servletResponse
).
sendRedirect
(
ACTIVE_SERVER_ADDRESS
+
"types"
);
}
@Test
public
void
adminImportRequestsToPassiveServerShouldToActiveServerAddress
()
throws
IOException
,
ServletException
{
String
importExportUrls
[]
=
{
"api/admin/export"
,
"api/admin/import"
,
"api/admin/importfile"
};
for
(
String
partialUrl
:
importExportUrls
)
{
when
(
serviceState
.
getState
()).
thenReturn
(
ServiceState
.
ServiceStateValue
.
PASSIVE
);
when
(
servletRequest
.
getRequestURI
()).
thenReturn
(
partialUrl
);
ActiveServerFilter
activeServerFilter
=
new
ActiveServerFilter
(
activeInstanceState
,
serviceState
);
when
(
activeInstanceState
.
getActiveServerAddress
()).
thenReturn
(
ACTIVE_SERVER_ADDRESS
);
when
(
servletRequest
.
getRequestURI
()).
thenReturn
(
partialUrl
);
when
(
servletRequest
.
getMethod
()).
thenReturn
(
HttpMethod
.
GET
);
activeServerFilter
.
doFilter
(
servletRequest
,
servletResponse
,
filterChain
);
verify
(
servletResponse
).
sendRedirect
(
ACTIVE_SERVER_ADDRESS
+
partialUrl
);
}
}
@Test
...
...
@@ -116,7 +137,7 @@ public class ActiveServerFilterTest {
activeServerFilter
.
doFilter
(
servletRequest
,
servletResponse
,
filterChain
);
verify
(
servletResponse
).
sendRedirect
(
ACTIVE_SERVER_ADDRESS
+
"types?query=TRAIT"
);
verify
(
servletResponse
).
sendRedirect
(
ACTIVE_SERVER_ADDRESS
+
"types?query=TRAIT"
);
}
...
...
@@ -133,7 +154,7 @@ public class ActiveServerFilterTest {
activeServerFilter
.
doFilter
(
servletRequest
,
servletResponse
,
filterChain
);
verify
(
servletResponse
).
setHeader
(
"Location"
,
ACTIVE_SERVER_ADDRESS
+
"types"
);
verify
(
servletResponse
).
setHeader
(
"Location"
,
ACTIVE_SERVER_ADDRESS
+
"types"
);
verify
(
servletResponse
).
setStatus
(
HttpServletResponse
.
SC_TEMPORARY_REDIRECT
);
}
...
...
@@ -150,7 +171,7 @@ public class ActiveServerFilterTest {
activeServerFilter
.
doFilter
(
servletRequest
,
servletResponse
,
filterChain
);
verify
(
servletResponse
).
setHeader
(
"Location"
,
ACTIVE_SERVER_ADDRESS
+
"types"
);
verify
(
servletResponse
).
setHeader
(
"Location"
,
ACTIVE_SERVER_ADDRESS
+
"types"
);
verify
(
servletResponse
).
setStatus
(
HttpServletResponse
.
SC_TEMPORARY_REDIRECT
);
}
...
...
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