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
c413975a
Commit
c413975a
authored
Dec 05, 2016
by
Apoorv Naik
Committed by
Vimal Sharma
Dec 05, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reduce excessive exception logging
parent
74a8de1a
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
119 additions
and
49 deletions
+119
-49
AtlasAuthorizationUtils.java
...pache/atlas/authorize/simple/AtlasAuthorizationUtils.java
+15
-7
release-log.txt
release-log.txt
+1
-0
GraphTransactionInterceptor.java
...in/java/org/apache/atlas/GraphTransactionInterceptor.java
+6
-6
EntityNotFoundException.java
...e/atlas/typesystem/exception/EntityNotFoundException.java
+1
-3
NotFoundException.java
.../apache/atlas/typesystem/exception/NotFoundException.java
+46
-0
SchemaNotFoundException.java
...e/atlas/typesystem/exception/SchemaNotFoundException.java
+1
-3
TraitNotFoundException.java
...he/atlas/typesystem/exception/TraitNotFoundException.java
+1
-2
AtlasBaseExceptionMapper.java
...org/apache/atlas/web/errors/AtlasBaseExceptionMapper.java
+9
-27
ExceptionMapperUtil.java
...java/org/apache/atlas/web/errors/ExceptionMapperUtil.java
+0
-1
NotFoundExceptionMapper.java
.../org/apache/atlas/web/errors/NotFoundExceptionMapper.java
+39
-0
No files found.
authorization/src/main/java/org/apache/atlas/authorize/simple/AtlasAuthorizationUtils.java
View file @
c413975a
...
...
@@ -18,15 +18,16 @@
package
org
.
apache
.
atlas
.
authorize
.
simple
;
import
java.util.HashSet
;
import
java.util.Set
;
import
org.apache.atlas.AtlasClient
;
import
org.apache.atlas.authorize.AtlasActionTypes
;
import
org.apache.atlas.authorize.AtlasResourceTypes
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.util.HashSet
;
import
java.util.Objects
;
import
java.util.Set
;
public
class
AtlasAuthorizationUtils
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
AtlasAuthorizationUtils
.
class
);
private
static
boolean
isDebugEnabled
=
LOG
.
isDebugEnabled
();
...
...
@@ -47,7 +48,13 @@ public class AtlasAuthorizationUtils {
String
[]
split
=
contextPath
.
split
(
"/"
,
3
);
String
api
=
split
[
0
];
if
(
split
.
length
>
1
)
{
return
(!
api
.
equals
(
"v1"
))
?
api
:
String
.
format
(
"v1/%s"
,
split
[
1
]);
if
(
Objects
.
equals
(
api
,
"v1"
))
{
return
String
.
format
(
"v1/%s"
,
split
[
1
]);
}
else
if
(
Objects
.
equals
(
api
,
"v2"
))
{
return
String
.
format
(
"v2/%s"
,
split
[
1
]);
}
else
{
return
api
;
}
}
else
{
return
api
;
}
...
...
@@ -101,14 +108,15 @@ public class AtlasAuthorizationUtils {
LOG
.
debug
(
"==> getAtlasResourceType for "
+
contextPath
);
}
String
api
=
getApi
(
contextPath
);
if
(
api
.
startsWith
(
"types"
))
{
if
(
api
.
startsWith
(
"types"
)
||
api
.
startsWith
(
"v2/types"
)
)
{
resourceTypes
.
add
(
AtlasResourceTypes
.
TYPE
);
}
else
if
(
api
.
startsWith
(
"admin"
)
&&
(
contextPath
.
contains
(
"/session"
)
||
contextPath
.
contains
(
"/version"
)))
{
resourceTypes
.
add
(
AtlasResourceTypes
.
UNKNOWN
);
}
else
if
((
api
.
startsWith
(
"discovery"
)
&&
contextPath
.
contains
(
"/gremlin"
))
||
api
.
startsWith
(
"admin"
)
||
api
.
startsWith
(
"graph"
))
{
resourceTypes
.
add
(
AtlasResourceTypes
.
OPERATION
);
}
else
if
(
api
.
startsWith
(
"entities"
)
||
api
.
startsWith
(
"lineage"
)
||
api
.
startsWith
(
"discovery"
))
{
}
else
if
(
api
.
startsWith
(
"entities"
)
||
api
.
startsWith
(
"lineage"
)
||
api
.
startsWith
(
"discovery"
)
||
api
.
startsWith
(
"v2/entity"
))
{
resourceTypes
.
add
(
AtlasResourceTypes
.
ENTITY
);
}
else
if
(
api
.
startsWith
(
"v1/taxonomies"
))
{
resourceTypes
.
add
(
AtlasResourceTypes
.
TAXONOMY
);
...
...
@@ -117,7 +125,7 @@ public class AtlasAuthorizationUtils {
if
(
contextPath
.
contains
(
"/terms"
))
{
resourceTypes
.
add
(
AtlasResourceTypes
.
TERM
);
}
}
else
if
(
api
.
startsWith
(
"v1/entities"
))
{
}
else
if
(
api
.
startsWith
(
"v1/entities"
)
||
api
.
startsWith
(
"v2/entities"
)
)
{
resourceTypes
.
add
(
AtlasResourceTypes
.
ENTITY
);
}
else
{
LOG
.
error
(
"Unable to find Atlas Resource corresponding to : "
+
api
+
"\nSetting "
...
...
release-log.txt
View file @
c413975a
...
...
@@ -9,6 +9,7 @@ ATLAS-1060 Add composite indexes for exact match performance improvements for al
ATLAS-1127 Modify creation and modification timestamps to Date instead of Long(sumasai)
ALL CHANGES:
ATLAS-1349 Reduce excessive exception logging (apoorvnaik via svimal2106)
ATLAS-1343 CTAS query is not captured by Atlas with Hive2 (svimal2106)
ATLAS-1337 fixed FalconHookIT (ayubpathan via mneethiraj)
ATLAS-1338 fix SqoopHookIT (ayubpathan via mneethiraj)
...
...
repository/src/main/java/org/apache/atlas/GraphTransactionInterceptor.java
View file @
c413975a
...
...
@@ -19,13 +19,14 @@ package org.apache.atlas;
import
org.aopalliance.intercept.MethodInterceptor
;
import
org.aopalliance.intercept.MethodInvocation
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.repository.graph.AtlasGraphProvider
;
import
org.apache.atlas.repository.graphdb.AtlasGraph
;
import
org.apache.atlas.typesystem.exception.EntityNotFoundException
;
import
org.apache.atlas.typesystem.exception.SchemaNotFoundException
;
import
org.apache.atlas.typesystem.exception.NotFoundException
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
javax.ws.rs.core.Response
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -79,10 +80,9 @@ public class GraphTransactionInterceptor implements MethodInterceptor {
}
boolean
logException
(
Throwable
t
)
{
if
((
t
instanceof
SchemaNotFoundException
)
||
(
t
instanceof
EntityNotFoundException
))
{
return
false
;
}
return
true
;
return
!(
t
instanceof
NotFoundException
)
&&
((
t
instanceof
AtlasBaseException
)
&&
((
AtlasBaseException
)
t
).
getAtlasErrorCode
().
getHttpCode
()
!=
Response
.
Status
.
NOT_FOUND
);
}
public
static
abstract
class
PostTransactionHook
{
...
...
server-api/src/main/java/org/apache/atlas/typesystem/exception/EntityNotFoundException.java
View file @
c413975a
...
...
@@ -18,12 +18,10 @@
package
org
.
apache
.
atlas
.
typesystem
.
exception
;
import
org.apache.atlas.AtlasException
;
/**
* A simple wrapper for 404.
*/
public
class
EntityNotFoundException
extends
Atlas
Exception
{
public
class
EntityNotFoundException
extends
NotFound
Exception
{
public
EntityNotFoundException
()
{
}
...
...
server-api/src/main/java/org/apache/atlas/typesystem/exception/NotFoundException.java
0 → 100644
View file @
c413975a
/**
* 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
.
typesystem
.
exception
;
import
org.apache.atlas.AtlasException
;
/**
* A simple wrapper for 404.
*/
public
class
NotFoundException
extends
AtlasException
{
public
NotFoundException
()
{
}
public
NotFoundException
(
String
message
)
{
super
(
message
);
}
public
NotFoundException
(
String
message
,
Throwable
cause
)
{
super
(
message
,
cause
);
}
public
NotFoundException
(
Throwable
cause
)
{
super
(
cause
);
}
public
NotFoundException
(
String
message
,
Throwable
cause
,
boolean
enableSuppression
,
boolean
writableStackTrace
)
{
super
(
message
,
cause
,
enableSuppression
,
writableStackTrace
);
}
}
server-api/src/main/java/org/apache/atlas/typesystem/exception/SchemaNotFoundException.java
View file @
c413975a
...
...
@@ -17,9 +17,7 @@
*/
package
org
.
apache
.
atlas
.
typesystem
.
exception
;
import
org.apache.atlas.AtlasException
;
public
class
SchemaNotFoundException
extends
AtlasException
{
public
class
SchemaNotFoundException
extends
NotFoundException
{
public
SchemaNotFoundException
()
{
}
...
...
server-api/src/main/java/org/apache/atlas/typesystem/exception/TraitNotFoundException.java
View file @
c413975a
...
...
@@ -17,13 +17,12 @@
*/
package
org
.
apache
.
atlas
.
typesystem
.
exception
;
import
org.apache.atlas.AtlasException
;
/**
* A simple wrapper for 404.
* Thrown when a requested trait can not be found.
*/
public
class
TraitNotFoundException
extends
AtlasException
{
public
class
TraitNotFoundException
extends
NotFoundException
{
public
TraitNotFoundException
()
{
}
...
...
webapp/src/main/java/org/apache/atlas/web/errors/AtlasBaseExceptionMapper.java
View file @
c413975a
...
...
@@ -21,34 +21,31 @@ package org.apache.atlas.web.errors;
import
org.apache.atlas.AtlasErrorCode
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.type.AtlasType
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
java.util.concurrent.ThreadLocalRandom
;
import
javax.inject.Singleton
;
import
javax.ws.rs.core.Response
;
import
javax.ws.rs.ext.ExceptionMapper
;
import
javax.ws.rs.ext.Provider
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
java.util.concurrent.ThreadLocalRandom
;
/**
* Exception mapper for Jersey.
* @param <E>
* AtlasBaseException mapper for Jersey.
*/
@Provider
@Singleton
public
class
AtlasBaseExceptionMapper
implements
ExceptionMapper
<
AtlasBaseException
>
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
AtlasBaseExceptionMapper
.
class
);
@Override
public
Response
toResponse
(
AtlasBaseException
exception
)
{
final
long
id
=
ThreadLocalRandom
.
current
().
nextLong
();
// Log the response and use the error codes from the Exception
logException
(
id
,
exception
);
return
buildAtlasBaseExceptionResponse
((
AtlasBaseException
)
exception
);
// Only log the exception is there's an internal error
if
(
exception
.
getAtlasErrorCode
().
getHttpCode
()
==
Response
.
Status
.
INTERNAL_SERVER_ERROR
)
{
ExceptionMapperUtil
.
logException
(
id
,
exception
);
}
return
buildAtlasBaseExceptionResponse
(
exception
);
}
protected
Response
buildAtlasBaseExceptionResponse
(
AtlasBaseException
baseException
)
{
...
...
@@ -64,19 +61,4 @@ public class AtlasBaseExceptionMapper implements ExceptionMapper<AtlasBaseExcept
}
return
responseBuilder
.
build
();
}
@SuppressWarnings
(
"UnusedParameters"
)
protected
String
formatErrorMessage
(
long
id
,
AtlasBaseException
exception
)
{
return
String
.
format
(
"There was an error processing your request. It has been logged (ID %016x)."
,
id
);
}
protected
void
logException
(
long
id
,
AtlasBaseException
exception
)
{
LOGGER
.
error
(
formatLogMessage
(
id
,
exception
),
exception
);
}
@SuppressWarnings
(
"UnusedParameters"
)
protected
String
formatLogMessage
(
long
id
,
Throwable
exception
)
{
return
String
.
format
(
"Error handling a request: %016x"
,
id
);
}
}
webapp/src/main/java/org/apache/atlas/web/errors/ExceptionMapperUtil.java
View file @
c413975a
...
...
@@ -17,7 +17,6 @@
*/
package
org
.
apache
.
atlas
.
web
.
errors
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
webapp/src/main/java/org/apache/atlas/web/errors/NotFoundExceptionMapper.java
0 → 100644
View file @
c413975a
/**
* 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
* <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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
apache
.
atlas
.
web
.
errors
;
import
org.apache.atlas.typesystem.exception.NotFoundException
;
import
javax.inject.Singleton
;
import
javax.ws.rs.core.Response
;
import
javax.ws.rs.ext.ExceptionMapper
;
import
javax.ws.rs.ext.Provider
;
import
java.util.concurrent.ThreadLocalRandom
;
@Provider
@Singleton
public
class
NotFoundExceptionMapper
implements
ExceptionMapper
<
NotFoundException
>
{
@Override
public
Response
toResponse
(
NotFoundException
e
)
{
final
long
id
=
ThreadLocalRandom
.
current
().
nextLong
();
return
Response
.
status
(
Response
.
Status
.
NOT_FOUND
)
.
entity
(
ExceptionMapperUtil
.
formatErrorMessage
(
id
,
e
))
.
build
();
}
}
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