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
76fcba1a
Commit
76fcba1a
authored
Jan 16, 2015
by
Harish Butani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup: remove dependency on MetadataService in serialization code path
parent
3b68cbda
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
14 deletions
+14
-14
Serialization.scala
...scala/org/apache/hadoop/metadata/json/Serialization.scala
+12
-12
MetadataActor.scala
...he/hadoop/metadata/tools/simpleserver/MetadataActor.scala
+2
-2
No files found.
typesystem/src/main/scala/org/apache/hadoop/metadata/json/Serialization.scala
View file @
76fcba1a
...
@@ -63,19 +63,19 @@ class IdSerializer extends CustomSerializer[Id](format => ( {
...
@@ -63,19 +63,19 @@ class IdSerializer extends CustomSerializer[Id](format => ( {
}
}
))
))
class
TypedStructSerializer
(
val
typSystem
:
Option
[
MetadataService
]
=
None
)
extends
Serializer
[
ITypedStruct
]
{
class
TypedStructSerializer
()
extends
Serializer
[
ITypedStruct
]
{
def
currentMdSvc
=
typSystem
.
getOrElse
(
MetadataService
.
getCurrentService
()
)
def
typSystem
=
TypeSystem
.
getInstance
(
)
def
deserialize
(
implicit
format
:
Formats
)
=
{
def
deserialize
(
implicit
format
:
Formats
)
=
{
case
(
TypeInfo
(
clazz
,
ptype
),
json
)
if
classOf
[
ITypedStruct
].
isAssignableFrom
(
clazz
)
=>
json
match
{
case
(
TypeInfo
(
clazz
,
ptype
),
json
)
if
classOf
[
ITypedStruct
].
isAssignableFrom
(
clazz
)
=>
json
match
{
case
JObject
(
fs
)
=>
case
JObject
(
fs
)
=>
val
(
typ
,
fields
)
=
fs
.
partition
(
f
=>
f
.
_1
==
Serialization
.
STRUCT_TYPE_FIELD_NAME
)
val
(
typ
,
fields
)
=
fs
.
partition
(
f
=>
f
.
_1
==
Serialization
.
STRUCT_TYPE_FIELD_NAME
)
val
typName
=
typ
(
0
).
_2
.
asInstanceOf
[
JString
].
s
val
typName
=
typ
(
0
).
_2
.
asInstanceOf
[
JString
].
s
val
sT
=
currentMdSvc
.
getType
System
.
getDataType
(
val
sT
=
typ
System
.
getDataType
(
classOf
[
IConstructableType
[
IStruct
,
ITypedStruct
]],
typName
).
asInstanceOf
[
IConstructableType
[
IStruct
,
ITypedStruct
]]
classOf
[
IConstructableType
[
IStruct
,
ITypedStruct
]],
typName
).
asInstanceOf
[
IConstructableType
[
IStruct
,
ITypedStruct
]]
val
s
=
sT
.
createInstance
()
val
s
=
sT
.
createInstance
()
Serialization
.
deserializeFields
(
currentMdSvc
,
sT
,
s
,
fields
)
Serialization
.
deserializeFields
(
typSystem
,
sT
,
s
,
fields
)
s
s
case
x
=>
throw
new
MappingException
(
"Can't convert "
+
x
+
" to TypedStruct"
)
case
x
=>
throw
new
MappingException
(
"Can't convert "
+
x
+
" to TypedStruct"
)
}
}
...
@@ -96,10 +96,10 @@ class TypedStructSerializer(val typSystem : Option[MetadataService] = None) exte
...
@@ -96,10 +96,10 @@ class TypedStructSerializer(val typSystem : Option[MetadataService] = None) exte
}
}
}
}
class
TypedReferenceableInstanceSerializer
(
val
typSystem
:
Option
[
MetadataService
]
=
None
)
class
TypedReferenceableInstanceSerializer
()
extends
Serializer
[
ITypedReferenceableInstance
]
{
extends
Serializer
[
ITypedReferenceableInstance
]
{
def
currentMdSvc
=
typSystem
.
getOrElse
(
MetadataService
.
getCurrentService
()
)
def
typSystem
=
TypeSystem
.
getInstance
(
)
def
deserialize
(
implicit
format
:
Formats
)
=
{
def
deserialize
(
implicit
format
:
Formats
)
=
{
case
(
TypeInfo
(
clazz
,
ptype
),
json
)
if
classOf
[
ITypedReferenceableInstance
].
isAssignableFrom
(
clazz
)
=>
json
match
{
case
(
TypeInfo
(
clazz
,
ptype
),
json
)
if
classOf
[
ITypedReferenceableInstance
].
isAssignableFrom
(
clazz
)
=>
json
match
{
...
@@ -134,11 +134,11 @@ class TypedReferenceableInstanceSerializer(val typSystem : Option[MetadataServic
...
@@ -134,11 +134,11 @@ class TypedReferenceableInstanceSerializer(val typSystem : Option[MetadataServic
}
}
val
typName
=
typField
.
get
.
_2
.
asInstanceOf
[
JString
].
s
val
typName
=
typField
.
get
.
_2
.
asInstanceOf
[
JString
].
s
val
sT
=
currentMdSvc
.
getType
System
.
getDataType
(
val
sT
=
typ
System
.
getDataType
(
classOf
[
ClassType
],
typName
).
asInstanceOf
[
ClassType
]
classOf
[
ClassType
],
typName
).
asInstanceOf
[
ClassType
]
val
id
=
Serialization
.
deserializeId
(
idField
.
get
.
_2
)
val
id
=
Serialization
.
deserializeId
(
idField
.
get
.
_2
)
val
s
=
sT
.
createInstance
(
id
,
traitNames
:_
*
)
val
s
=
sT
.
createInstance
(
id
,
traitNames
:_
*
)
Serialization
.
deserializeFields
(
currentMdSvc
,
sT
,
s
,
fields
)
Serialization
.
deserializeFields
(
typSystem
,
sT
,
s
,
fields
)
traitsField
.
map
{
t
=>
traitsField
.
map
{
t
=>
val
tObj
:
JObject
=
t
.
_2
.
asInstanceOf
[
JObject
]
val
tObj
:
JObject
=
t
.
_2
.
asInstanceOf
[
JObject
]
...
@@ -146,10 +146,10 @@ class TypedReferenceableInstanceSerializer(val typSystem : Option[MetadataServic
...
@@ -146,10 +146,10 @@ class TypedReferenceableInstanceSerializer(val typSystem : Option[MetadataServic
val
tName
:
String
=
oTrait
.
_1
val
tName
:
String
=
oTrait
.
_1
val
traitJObj
:
JObject
=
oTrait
.
_2
.
asInstanceOf
[
JObject
]
val
traitJObj
:
JObject
=
oTrait
.
_2
.
asInstanceOf
[
JObject
]
val
traitObj
=
s
.
getTrait
(
tName
).
asInstanceOf
[
ITypedStruct
]
val
traitObj
=
s
.
getTrait
(
tName
).
asInstanceOf
[
ITypedStruct
]
val
tT
=
currentMdSvc
.
getType
System
.
getDataType
(
val
tT
=
typ
System
.
getDataType
(
classOf
[
TraitType
],
traitObj
.
getTypeName
).
asInstanceOf
[
TraitType
]
classOf
[
TraitType
],
traitObj
.
getTypeName
).
asInstanceOf
[
TraitType
]
val
(
tTyp
,
tFields
)
=
traitJObj
.
obj
.
partition
(
f
=>
f
.
_1
==
Serialization
.
STRUCT_TYPE_FIELD_NAME
)
val
(
tTyp
,
tFields
)
=
traitJObj
.
obj
.
partition
(
f
=>
f
.
_1
==
Serialization
.
STRUCT_TYPE_FIELD_NAME
)
Serialization
.
deserializeFields
(
currentMdSvc
,
tT
,
traitObj
,
tFields
)
Serialization
.
deserializeFields
(
typSystem
,
tT
,
traitObj
,
tFields
)
}
}
}
}
...
@@ -231,11 +231,11 @@ object Serialization {
...
@@ -231,11 +231,11 @@ object Serialization {
}
}
}.
toList
.
map
(
_
.
asInstanceOf
[
JField
])
}.
toList
.
map
(
_
.
asInstanceOf
[
JField
])
def
deserializeFields
[
T
<:
ITypedInstance
](
currentMdSvc
:
MetadataService
,
def
deserializeFields
[
T
<:
ITypedInstance
](
typeSystem
:
TypeSystem
,
sT
:
IConstructableType
[
_
,
T
],
sT
:
IConstructableType
[
_
,
T
],
s
:
T
,
fields
:
List
[
JField
]
)(
implicit
format
:
Formats
)
s
:
T
,
fields
:
List
[
JField
]
)(
implicit
format
:
Formats
)
=
{
=
{
MetadataService
.
setCurrentService
(
currentMdSvc
)
//
MetadataService.setCurrentService(currentMdSvc)
fields
.
foreach
{
f
=>
fields
.
foreach
{
f
=>
val
fName
=
f
.
_1
val
fName
=
f
.
_1
val
fInfo
=
sT
.
fieldMapping
.
fields
(
fName
)
val
fInfo
=
sT
.
fieldMapping
.
fields
(
fName
)
...
...
typesystem/src/main/scala/org/apache/hadoop/metadata/tools/simpleserver/MetadataActor.scala
View file @
76fcba1a
...
@@ -105,8 +105,8 @@ trait Json4sProtocol extends Json4sSupport {
...
@@ -105,8 +105,8 @@ trait Json4sProtocol extends Json4sSupport {
implicit
def
json4sFormats
:
Formats
=
implicit
def
json4sFormats
:
Formats
=
org
.
json4s
.
native
.
Serialization
.
formats
(
NoTypeHints
)
+
new
MultiplicitySerializer
+
org
.
json4s
.
native
.
Serialization
.
formats
(
NoTypeHints
)
+
new
MultiplicitySerializer
+
new
TypedStructSerializer
(
Some
(
new
MetadataService
(
memRepository
,
typeSystem
)))
+
new
TypedStructSerializer
+
new
TypedReferenceableInstanceSerializer
(
Some
(
new
MetadataService
(
memRepository
,
typeSystem
)))
+
new
TypedReferenceableInstanceSerializer
+
new
BigDecimalSerializer
+
new
BigIntegerSerializer
+
new
IdSerializer
new
BigDecimalSerializer
+
new
BigIntegerSerializer
+
new
IdSerializer
}
}
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