From 63ce1593c5b78eb172773e7498d9c321debe81e8 Mon Sep 17 00:00:00 2001 From: Jason Lowe Date: Tue, 27 Jun 2017 17:12:42 -0500 Subject: [PATCH] YARN-6738. LevelDBCacheTimelineStore should reuse ObjectMapper instances. Contributed by Zoltan Haindrich --- .../yarn/server/timeline/LevelDBCacheTimelineStore.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timeline-pluginstorage/src/main/java/org/apache/hadoop/yarn/server/timeline/LevelDBCacheTimelineStore.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timeline-pluginstorage/src/main/java/org/apache/hadoop/yarn/server/timeline/LevelDBCacheTimelineStore.java index ccf2d944a76..7379dd6844a 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timeline-pluginstorage/src/main/java/org/apache/hadoop/yarn/server/timeline/LevelDBCacheTimelineStore.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timeline-pluginstorage/src/main/java/org/apache/hadoop/yarn/server/timeline/LevelDBCacheTimelineStore.java @@ -286,6 +286,7 @@ public void remove() { } }; } + static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); @SuppressWarnings("unchecked") private V getEntityForKey(byte[] key) throws IOException { @@ -293,8 +294,7 @@ private V getEntityForKey(byte[] key) throws IOException { if (resultRaw == null) { return null; } - ObjectMapper entityMapper = new ObjectMapper(); - return (V) entityMapper.readValue(resultRaw, TimelineEntity.class); + return (V) OBJECT_MAPPER.readValue(resultRaw, TimelineEntity.class); } private byte[] getStartTimeKey(K entityId) {