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
8d8b0b71
Commit
8d8b0b71
authored
Jun 09, 2015
by
Suma Shivaprasad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed api response codes and audit filter logging
parent
2cbd25cc
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
79 additions
and
16 deletions
+79
-16
GraphBackedMetadataRepository.java
...adata/repository/graph/GraphBackedMetadataRepository.java
+7
-1
DefaultMetadataService.java
...ache/hadoop/metadata/services/DefaultMetadataService.java
+16
-5
TypeNotFoundException.java
...ava/org/apache/hadoop/metadata/TypeNotFoundException.java
+44
-0
TypeSystem.java
...g/apache/hadoop/metadata/typesystem/types/TypeSystem.java
+2
-1
AuditFilter.java
...a/org/apache/hadoop/metadata/web/filters/AuditFilter.java
+3
-2
EntityResource.java
.../apache/hadoop/metadata/web/resources/EntityResource.java
+4
-4
EntityJerseyResourceIT.java
...hadoop/metadata/web/resources/EntityJerseyResourceIT.java
+3
-3
No files found.
repository/src/main/java/org/apache/hadoop/metadata/repository/graph/GraphBackedMetadataRepository.java
View file @
8d8b0b71
...
...
@@ -257,6 +257,8 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
((
TitanVertex
)
instanceVertex
)
.
addProperty
(
Constants
.
TRAIT_NAMES_PROPERTY_KEY
,
traitName
);
}
catch
(
RepositoryException
e
)
{
throw
e
;
}
catch
(
Exception
e
)
{
throw
new
RepositoryException
(
e
);
}
...
...
@@ -279,7 +281,7 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
List
<
String
>
traitNames
=
getTraitNames
(
instanceVertex
);
if
(!
traitNames
.
contains
(
traitNameToBeDeleted
))
{
throw
new
Repository
Exception
(
"Could not find trait="
+
traitNameToBeDeleted
throw
new
EntityNotFound
Exception
(
"Could not find trait="
+
traitNameToBeDeleted
+
" in the repository for entity: "
+
guid
);
}
...
...
@@ -302,6 +304,8 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
updateTraits
(
instanceVertex
,
traitNames
);
}
}
}
catch
(
RepositoryException
e
)
{
throw
e
;
}
catch
(
Exception
e
)
{
throw
new
RepositoryException
(
e
);
}
...
...
@@ -350,6 +354,8 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
instanceToGraphMapper
.
mapAttributesToVertex
(
getIdFromVertex
(
typeName
,
instanceVertex
),
instance
,
instanceVertex
,
new
HashMap
<
Id
,
Vertex
>(),
attributeInfo
,
attributeInfo
.
dataType
());
}
catch
(
RepositoryException
e
)
{
throw
e
;
}
catch
(
Exception
e
)
{
throw
new
RepositoryException
(
e
);
}
...
...
repository/src/main/java/org/apache/hadoop/metadata/services/DefaultMetadataService.java
View file @
8d8b0b71
...
...
@@ -21,9 +21,11 @@ package org.apache.hadoop.metadata.services;
import
com.google.common.base.Preconditions
;
import
com.google.common.collect.ImmutableList
;
import
com.google.inject.Provider
;
import
com.sun.jersey.api.NotFoundException
;
import
org.apache.hadoop.metadata.MetadataException
;
import
org.apache.hadoop.metadata.MetadataServiceClient
;
import
org.apache.hadoop.metadata.ParamChecker
;
import
org.apache.hadoop.metadata.TypeNotFoundException
;
import
org.apache.hadoop.metadata.classification.InterfaceAudience
;
import
org.apache.hadoop.metadata.discovery.SearchIndexer
;
import
org.apache.hadoop.metadata.listener.EntityChangeListener
;
...
...
@@ -293,7 +295,7 @@ public class DefaultMetadataService implements MetadataService {
// verify if the type exists
if
(!
typeSystem
.
isRegistered
(
entityType
))
{
throw
new
Metadata
Exception
(
"type is not defined for : "
+
entityType
);
throw
new
TypeNotFound
Exception
(
"type is not defined for : "
+
entityType
);
}
}
...
...
@@ -327,8 +329,12 @@ public class DefaultMetadataService implements MetadataService {
final
String
traitName
=
traitInstance
.
getTypeName
();
// ensure trait type is already registered with the TS
Preconditions
.
checkArgument
(
typeSystem
.
isRegistered
(
traitName
),
"trait=%s should be defined in type system before it can be added"
,
traitName
);
if
(
!
typeSystem
.
isRegistered
(
traitName
)
)
{
String
msg
=
String
.
format
(
"trait=%s should be defined in type system before it can be added"
,
traitName
);
LOG
.
error
(
msg
);
throw
new
TypeNotFoundException
(
msg
);
}
// ensure trait is not already defined
Preconditions
.
checkArgument
(!
getTraitNames
(
guid
).
contains
(
traitName
),
"trait=%s is already defined for entity=%s"
,
traitName
,
guid
);
...
...
@@ -350,6 +356,8 @@ public class DefaultMetadataService implements MetadataService {
TraitType
traitType
=
typeSystem
.
getDataType
(
TraitType
.
class
,
entityTypeName
);
return
traitType
.
convert
(
traitInstance
,
Multiplicity
.
REQUIRED
);
}
catch
(
TypeNotFoundException
e
)
{
throw
e
;
}
catch
(
Exception
e
)
{
throw
new
MetadataException
(
"Error deserializing trait instance"
,
e
);
}
...
...
@@ -369,9 +377,12 @@ public class DefaultMetadataService implements MetadataService {
ParamChecker
.
notEmpty
(
traitNameToBeDeleted
,
"Trait name cannot be null"
);
// ensure trait type is already registered with the TS
Preconditions
.
checkArgument
(
typeSystem
.
isRegistered
(
traitNameToBeDeleted
),
"trait=%s should be defined in type system before it can be deleted"
,
if
(
!
typeSystem
.
isRegistered
(
traitNameToBeDeleted
))
{
final
String
msg
=
String
.
format
(
"trait=%s should be defined in type system before it can be deleted"
,
traitNameToBeDeleted
);
LOG
.
error
(
msg
);
throw
new
TypeNotFoundException
(
msg
);
}
repository
.
deleteTrait
(
guid
,
traitNameToBeDeleted
);
...
...
typesystem/src/main/java/org/apache/hadoop/metadata/TypeNotFoundException.java
0 → 100644
View file @
8d8b0b71
/**
* 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
.
hadoop
.
metadata
;
/**
* A simple wrapper for 404.
*/
public
class
TypeNotFoundException
extends
MetadataException
{
public
TypeNotFoundException
()
{
}
public
TypeNotFoundException
(
String
message
)
{
super
(
message
);
}
public
TypeNotFoundException
(
String
message
,
Throwable
cause
)
{
super
(
message
,
cause
);
}
public
TypeNotFoundException
(
Throwable
cause
)
{
super
(
cause
);
}
public
TypeNotFoundException
(
String
message
,
Throwable
cause
,
boolean
enableSuppression
,
boolean
writableStackTrace
)
{
super
(
message
,
cause
,
enableSuppression
,
writableStackTrace
);
}
}
typesystem/src/main/java/org/apache/hadoop/metadata/typesystem/types/TypeSystem.java
View file @
8d8b0b71
...
...
@@ -22,6 +22,7 @@ import com.google.common.collect.ArrayListMultimap;
import
com.google.common.collect.ImmutableList
;
import
com.google.common.collect.Multimap
;
import
org.apache.hadoop.metadata.MetadataException
;
import
org.apache.hadoop.metadata.TypeNotFoundException
;
import
org.apache.hadoop.metadata.classification.InterfaceAudience
;
import
org.apache.hadoop.metadata.typesystem.TypesDef
;
...
...
@@ -160,7 +161,7 @@ public class TypeSystem {
return
cls
.
cast
(
dT
);
}
throw
new
Metadata
Exception
(
String
.
format
(
"Unknown datatype: %s"
,
name
));
throw
new
TypeNotFound
Exception
(
String
.
format
(
"Unknown datatype: %s"
,
name
));
}
public
StructType
defineStructType
(
String
name
,
...
...
webapp/src/main/java/org/apache/hadoop/metadata/web/filters/AuditFilter.java
View file @
8d8b0b71
...
...
@@ -81,11 +81,12 @@ public class AuditFilter implements Filter {
final
String
who
=
getUserFromRequest
(
httpRequest
);
final
String
fromHost
=
httpRequest
.
getRemoteHost
();
final
String
fromAddress
=
httpRequest
.
getRemoteAddr
();
final
String
whatRequest
=
httpRequest
.
getMethod
();
final
String
whatURL
=
Servlets
.
getRequestURL
(
httpRequest
);
final
String
whatAddrs
=
httpRequest
.
getLocalAddr
();
LOG
.
debug
(
"Audit: {}/{} performed request {} ({}) at time {}"
,
who
,
fromAddress
,
whatURL
,
whatAddrs
,
whenISO9601
);
LOG
.
debug
(
"Audit: {}/{} performed request {}
{}
({}) at time {}"
,
who
,
fromAddress
,
what
Request
,
what
URL
,
whatAddrs
,
whenISO9601
);
audit
(
who
,
fromAddress
,
fromHost
,
whatURL
,
whatAddrs
,
whenISO9601
);
}
...
...
webapp/src/main/java/org/apache/hadoop/metadata/web/resources/EntityResource.java
View file @
8d8b0b71
...
...
@@ -22,6 +22,7 @@ import com.google.common.base.Preconditions;
import
org.apache.hadoop.metadata.MetadataException
;
import
org.apache.hadoop.metadata.MetadataServiceClient
;
import
org.apache.hadoop.metadata.ParamChecker
;
import
org.apache.hadoop.metadata.TypeNotFoundException
;
import
org.apache.hadoop.metadata.repository.EntityNotFoundException
;
import
org.apache.hadoop.metadata.services.MetadataService
;
import
org.apache.hadoop.metadata.typesystem.types.ValueConversionException
;
...
...
@@ -48,7 +49,6 @@ import javax.ws.rs.core.Context;
import
javax.ws.rs.core.Response
;
import
javax.ws.rs.core.UriBuilder
;
import
javax.ws.rs.core.UriInfo
;
import
java.io.IOException
;
import
java.net.URI
;
import
java.util.List
;
...
...
@@ -300,11 +300,11 @@ public class EntityResource {
response
.
put
(
MetadataServiceClient
.
GUID
,
guid
);
return
Response
.
created
(
locationURI
).
entity
(
response
).
build
();
}
catch
(
EntityNotFoundException
e
)
{
}
catch
(
EntityNotFoundException
|
TypeNotFoundException
e
)
{
LOG
.
error
(
"An entity with GUID={} does not exist"
,
guid
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
NOT_FOUND
));
}
catch
(
MetadataException
|
I
OException
|
I
llegalArgumentException
e
)
{
}
catch
(
MetadataException
|
IllegalArgumentException
e
)
{
LOG
.
error
(
"Unable to add trait for entity={}"
,
guid
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
BAD_REQUEST
));
...
...
@@ -338,7 +338,7 @@ public class EntityResource {
response
.
put
(
TRAIT_NAME
,
traitName
);
return
Response
.
ok
(
response
).
build
();
}
catch
(
EntityNotFoundException
e
)
{
}
catch
(
EntityNotFoundException
|
TypeNotFoundException
e
)
{
LOG
.
error
(
"An entity with GUID={} does not exist"
,
guid
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
NOT_FOUND
));
...
...
webapp/src/test/java/org/apache/hadoop/metadata/web/resources/EntityJerseyResourceIT.java
View file @
8d8b0b71
...
...
@@ -424,7 +424,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
.
accept
(
Servlets
.
JSON_MEDIA_TYPE
)
.
type
(
Servlets
.
JSON_MEDIA_TYPE
)
.
method
(
HttpMethod
.
POST
,
ClientResponse
.
class
,
traitInstanceAsJSON
);
Assert
.
assertEquals
(
clientResponse
.
getStatus
(),
Response
.
Status
.
BAD_REQUEST
.
getStatusCode
());
Assert
.
assertEquals
(
clientResponse
.
getStatus
(),
Response
.
Status
.
NOT_FOUND
.
getStatusCode
());
}
@Test
(
dependsOnMethods
=
"testGetTraitNames"
)
...
...
@@ -494,7 +494,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
.
accept
(
Servlets
.
JSON_MEDIA_TYPE
)
.
type
(
Servlets
.
JSON_MEDIA_TYPE
)
.
method
(
HttpMethod
.
POST
,
ClientResponse
.
class
,
traitInstanceAsJSON
);
Assert
.
assertEquals
(
clientResponse
.
getStatus
(),
Response
.
Status
.
BAD_REQUEST
.
getStatusCode
());
Assert
.
assertEquals
(
clientResponse
.
getStatus
(),
Response
.
Status
.
NOT_FOUND
.
getStatusCode
());
}
@Test
(
dependsOnMethods
=
"testAddTrait"
)
...
...
@@ -532,7 +532,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
.
accept
(
Servlets
.
JSON_MEDIA_TYPE
)
.
type
(
Servlets
.
JSON_MEDIA_TYPE
)
.
method
(
HttpMethod
.
DELETE
,
ClientResponse
.
class
);
Assert
.
assertEquals
(
clientResponse
.
getStatus
(),
Response
.
Status
.
BAD_REQUEST
.
getStatusCode
());
Assert
.
assertEquals
(
clientResponse
.
getStatus
(),
Response
.
Status
.
NOT_FOUND
.
getStatusCode
());
String
responseAsString
=
clientResponse
.
getEntity
(
String
.
class
);
Assert
.
assertNotNull
(
responseAsString
);
...
...
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