You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by st...@apache.org on 2020/04/27 09:06:29 UTC
[phoenix] branch 4.x updated: PHOENIX-5789 try to standardize on a
JSON library
This is an automated email from the ASF dual-hosted git repository.
stoty pushed a commit to branch 4.x
in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/4.x by this push:
new ba22c2d PHOENIX-5789 try to standardize on a JSON library
ba22c2d is described below
commit ba22c2d52bcfa205a52b2bd44cc572c4fd20ac76
Author: Richard Antal <an...@gmail.com>
AuthorDate: Wed Apr 15 10:14:57 2020 +0200
PHOENIX-5789 try to standardize on a JSON library
---
.../phoenix/end2end/BackwardCompatibilityIT.java | 20 +++++------
.../apache/phoenix/end2end/IndexRebuildTaskIT.java | 2 +-
.../it/resources/compatible_client_versions.json | 3 +-
.../phoenix/coprocessor/TaskRegionObserver.java | 12 +++----
.../coprocessor/tasks/IndexRebuildTask.java | 39 +++++++++++-----------
.../phoenix/mapreduce/JsonToKeyValueMapper.java | 6 ++--
.../bulkload/TargetTableRefFunctions.java | 17 ++++------
.../index/automation/PhoenixMRJobSubmitter.java | 23 ++++---------
.../org/apache/phoenix/schema/MetaDataClient.java | 15 +++++----
.../java/org/apache/phoenix/util/JacksonUtil.java} | 33 ++++++++++++++----
.../org/apache/phoenix/util/PhoenixMRJobUtil.java | 3 +-
.../phoenix/tracingwebapp/http/TraceServlet.java | 6 ++--
12 files changed, 91 insertions(+), 88 deletions(-)
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BackwardCompatibilityIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BackwardCompatibilityIT.java
index ee105e2..6dad745 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BackwardCompatibilityIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BackwardCompatibilityIT.java
@@ -65,10 +65,9 @@ import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
-import com.google.gson.stream.JsonReader;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
/**
* This class is meant for testing all compatible client versions
@@ -139,13 +138,12 @@ public class BackwardCompatibilityIT {
hbaseProfile = m.group();
}
List<String> clientVersions = Lists.newArrayList();
- JsonParser jsonParser = new JsonParser();
- JsonReader jsonReader =
- new JsonReader(new FileReader(COMPATIBLE_CLIENTS_JSON));
- JsonObject jsonObject =
- jsonParser.parse(jsonReader).getAsJsonObject();
- for (JsonElement clientVersion : jsonObject.get(hbaseProfile).getAsJsonArray()) {
- clientVersions.add(clientVersion.getAsString() + "-HBase-" + hbaseProfile);
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true);
+ JsonNode jsonNode = mapper.readTree(new FileReader(COMPATIBLE_CLIENTS_JSON));
+ JsonNode HBaseProfile = jsonNode.get(hbaseProfile);
+ for (final JsonNode clientVersion : HBaseProfile) {
+ clientVersions.add(clientVersion.textValue() + "-HBase-" + hbaseProfile);
}
return clientVersions;
}
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexRebuildTaskIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexRebuildTaskIT.java
index c8e99b3..a0d0b87 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexRebuildTaskIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexRebuildTaskIT.java
@@ -139,7 +139,7 @@ public class IndexRebuildTaskIT extends BaseUniqueNamesOwnClusterIT {
count = getUtility().countRows(indexHTable);
assertEquals(0, count);
- String data = "{IndexName:" + indexName + "}";
+ String data = "{\"IndexName\":\"" + indexName + "\"}";
// Run IndexRebuildTask
TaskRegionObserver.SelfHealingTask task =
diff --git a/phoenix-core/src/it/resources/compatible_client_versions.json b/phoenix-core/src/it/resources/compatible_client_versions.json
index 49a5297..8308f17 100644
--- a/phoenix-core/src/it/resources/compatible_client_versions.json
+++ b/phoenix-core/src/it/resources/compatible_client_versions.json
@@ -16,8 +16,7 @@
* limitations under the License.
*/
{
- "_comment": "Lists all phoenix compatible client versions against the current branch version for a given hbase profile \
- If hbase profile is 1.3, phoenix client versions 4.14.3 and 4.15.0 are tested against current branch version",
+ "_comment": "Lists all phoenix compatible client versions against the current branch version for a given hbase profile If hbase profile is 1.3, phoenix client versions 4.14.3 and 4.15.0 are tested against current branch version",
"1.3": ["4.14.3", "4.15.0"],
"1.4": ["4.14.3", "4.15.0"],
"1.5": ["4.15.0"]
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/TaskRegionObserver.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/TaskRegionObserver.java
index 5418e9d..e2cc782 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/TaskRegionObserver.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/TaskRegionObserver.java
@@ -30,10 +30,11 @@ import java.util.concurrent.TimeUnit;
import javax.annotation.concurrent.GuardedBy;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.apache.phoenix.util.JacksonUtil;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.CoprocessorEnvironment;
import org.apache.hadoop.hbase.coprocessor.BaseRegionObserver;
@@ -245,10 +246,9 @@ public class TaskRegionObserver extends BaseRegionObserver {
if (Strings.isNullOrEmpty(data)) {
data = "{}";
}
- JsonParser jsonParser = new JsonParser();
- JsonObject jsonObject = jsonParser.parse(data).getAsJsonObject();
- jsonObject.addProperty(TASK_DETAILS, taskStatus);
- data = jsonObject.toString();
+ JsonNode jsonNode = JacksonUtil.getObjectReader().readTree(data);
+ ((ObjectNode) jsonNode).put(TASK_DETAILS, taskStatus);
+ data = jsonNode.toString();
Timestamp endTs = new Timestamp(EnvironmentEdgeManager.currentTimeMillis());
Task.addTask(connForTask, taskRecord.getTaskType(), taskRecord.getTenantId(), taskRecord.getSchemaName(),
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/tasks/IndexRebuildTask.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/tasks/IndexRebuildTask.java
index 3bf9dfb..4e3b639 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/tasks/IndexRebuildTask.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/tasks/IndexRebuildTask.java
@@ -18,8 +18,10 @@
package org.apache.phoenix.coprocessor.tasks;
import com.google.common.base.Strings;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.apache.phoenix.util.JacksonUtil;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
@@ -66,9 +68,8 @@ public class IndexRebuildTask extends BaseTask {
if (Strings.isNullOrEmpty(taskRecord.getData())) {
data = "{}";
}
- JsonParser jsonParser = new JsonParser();
- JsonObject jsonObject = jsonParser.parse(data).getAsJsonObject();
- String indexName = getIndexName(jsonObject);
+ JsonNode jsonNode = JacksonUtil.getObjectReader(JsonNode.class).readValue(data);
+ String indexName = getIndexName(jsonNode);
if (Strings.isNullOrEmpty(indexName)) {
String str = "Index name is not found. Index rebuild cannot continue " +
"Data : " + data;
@@ -77,16 +78,16 @@ public class IndexRebuildTask extends BaseTask {
}
boolean shouldDisable = false;
- if (jsonObject.has(DISABLE_BEFORE)) {
- String disableBefore = jsonObject.get(DISABLE_BEFORE).toString();
+ if (jsonNode.has(DISABLE_BEFORE)) {
+ String disableBefore = jsonNode.get(DISABLE_BEFORE).toString();
if (!Strings.isNullOrEmpty(disableBefore)) {
shouldDisable = Boolean.valueOf(disableBefore);
}
}
boolean rebuildAll = false;
- if (jsonObject.has(REBUILD_ALL)) {
- String rebuildAllStr = jsonObject.get(REBUILD_ALL).toString();
+ if (jsonNode.has(REBUILD_ALL)) {
+ String rebuildAllStr = jsonNode.get(REBUILD_ALL).toString();
if (!Strings.isNullOrEmpty(rebuildAllStr)) {
rebuildAll = Boolean.valueOf(rebuildAllStr);
}
@@ -104,9 +105,10 @@ public class IndexRebuildTask extends BaseTask {
Job job = indexToolRes.getValue();
- jsonObject.addProperty(JOB_ID, job.getJobID().toString());
+ ((ObjectNode) jsonNode).put(JOB_ID, job.getJobID().toString());
Task.addTask(conn.unwrap(PhoenixConnection.class ), taskRecord.getTaskType(), taskRecord.getTenantId(), taskRecord.getSchemaName(),
- taskRecord.getTableName(), PTable.TaskStatus.STARTED.toString(), jsonObject.toString(), taskRecord.getPriority(),
+ taskRecord.getTableName(), PTable.TaskStatus.STARTED.toString(),
+ jsonNode.toString(), taskRecord.getPriority(),
taskRecord.getTimeStamp(), null, true);
// It will take some time to finish, so we will check the status in a separate task.
return null;
@@ -130,24 +132,23 @@ public class IndexRebuildTask extends BaseTask {
}
- private String getIndexName(JsonObject jsonObject) {
+ private String getIndexName(JsonNode jsonNode) {
String indexName = null;
// Get index name from data column.
- if (jsonObject.has(INDEX_NAME)) {
- indexName = jsonObject.get(INDEX_NAME).toString().replaceAll("\"", "");
+ if (jsonNode.has(INDEX_NAME)) {
+ indexName = jsonNode.get(INDEX_NAME).toString().replaceAll("\"", "");
}
return indexName;
}
- private String getJobID(String data) {
+ private String getJobID(String data) throws JsonProcessingException {
if (Strings.isNullOrEmpty(data)) {
data = "{}";
}
- JsonParser jsonParser = new JsonParser();
- JsonObject jsonObject = jsonParser.parse(data).getAsJsonObject();
+ JsonNode jsonNode = JacksonUtil.getObjectReader().readTree(data);
String jobId = null;
- if (jsonObject.has(JOB_ID)) {
- jobId = jsonObject.get(JOB_ID).toString().replaceAll("\"", "");
+ if (jsonNode.has(JOB_ID)) {
+ jobId = jsonNode.get(JOB_ID).textValue().replaceAll("\"", "");
}
return jobId;
}
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/JsonToKeyValueMapper.java b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/JsonToKeyValueMapper.java
index 962667a..9702fd0 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/JsonToKeyValueMapper.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/JsonToKeyValueMapper.java
@@ -26,7 +26,7 @@ import org.apache.phoenix.util.ColumnInfo;
import org.apache.phoenix.util.UpsertExecutor;
import org.apache.phoenix.util.json.JsonUpsertExecutor;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.phoenix.util.JacksonUtil;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
@@ -65,11 +65,9 @@ public class JsonToKeyValueMapper extends FormatToBytesWritableMapper<Map<?, ?>>
@VisibleForTesting
static class JsonLineParser implements LineParser<Map<?, ?>> {
- private final ObjectMapper mapper = new ObjectMapper();
-
@Override
public Map<?, ?> parse(String input) throws IOException {
- return mapper.readValue(input, Map.class);
+ return JacksonUtil.getObjectReader(Map.class).readValue(input);
}
}
}
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/bulkload/TargetTableRefFunctions.java b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/bulkload/TargetTableRefFunctions.java
index 6e0da73..922a183 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/bulkload/TargetTableRefFunctions.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/bulkload/TargetTableRefFunctions.java
@@ -21,7 +21,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.phoenix.util.JacksonUtil;
import com.google.common.base.Function;
import com.google.common.collect.Lists;
@@ -37,8 +37,7 @@ public class TargetTableRefFunctions {
@Override
public String apply(TargetTableRef input) {
try {
- ObjectMapper mapper = new ObjectMapper();
- return mapper.writeValueAsString(input);
+ return JacksonUtil.getObjectWriter().writeValueAsString(input);
} catch (IOException e) {
throw new RuntimeException(e);
}
@@ -51,8 +50,7 @@ public class TargetTableRefFunctions {
@Override
public TargetTableRef apply(String json) {
try {
- ObjectMapper mapper = new ObjectMapper();
- return mapper.readValue(json, TargetTableRef.class);
+ return JacksonUtil.getObjectReader(TargetTableRef.class).readValue(json);
} catch (IOException e) {
throw new RuntimeException(e);
}
@@ -69,8 +67,7 @@ public class TargetTableRefFunctions {
for(TargetTableRef table : input) {
tableNames.add(table.getPhysicalName());
}
- ObjectMapper mapper = new ObjectMapper();
- return mapper.writeValueAsString(tableNames);
+ return JacksonUtil.getObjectWriter().writeValueAsString(tableNames);
} catch (IOException e) {
throw new RuntimeException(e);
}
@@ -87,8 +84,7 @@ public class TargetTableRefFunctions {
for(TargetTableRef table : input) {
tableNames.add(table.getLogicalName());
}
- ObjectMapper mapper = new ObjectMapper();
- return mapper.writeValueAsString(tableNames);
+ return JacksonUtil.getObjectWriter().writeValueAsString(tableNames);
} catch (IOException e) {
throw new RuntimeException(e);
}
@@ -102,8 +98,7 @@ public class TargetTableRefFunctions {
@Override
public List<String> apply(String json) {
try {
- ObjectMapper mapper = new ObjectMapper();
- return mapper.readValue(json, ArrayList.class);
+ return JacksonUtil.getObjectReader(ArrayList.class).readValue(json);
} catch (IOException e) {
throw new RuntimeException(e);
}
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/automation/PhoenixMRJobSubmitter.java b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/automation/PhoenixMRJobSubmitter.java
index 3d8962c..06a334d 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/automation/PhoenixMRJobSubmitter.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/automation/PhoenixMRJobSubmitter.java
@@ -56,14 +56,11 @@ import org.apache.phoenix.util.PhoenixMRJobUtil;
import org.apache.phoenix.util.PhoenixMRJobUtil.MR_SCHEDULER_TYPE;
import org.apache.phoenix.util.UpgradeUtil;
import org.apache.phoenix.util.ZKBasedMasterElectionUtil;
-import org.codehaus.jettison.json.JSONArray;
-import org.codehaus.jettison.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.reflect.TypeToken;
+import com.fasterxml.jackson.databind.JsonNode;
+import org.apache.phoenix.util.JacksonUtil;
public class PhoenixMRJobSubmitter {
@@ -313,25 +310,19 @@ public class PhoenixMRJobSubmitter {
+ "," + YarnApplication.state.RUNNING);
String response = PhoenixMRJobUtil.getJobsInformationFromRM(rmAddress, urlParams);
LOGGER.debug("Already Submitted/Running Apps = " + response);
- JSONObject jobsJson = new JSONObject(response);
- JSONObject appsJson = jobsJson.optJSONObject(YarnApplication.APPS_ELEMENT);
+ JsonNode jsonNode = JacksonUtil.getObjectReader().readTree(response);
+ JsonNode appsJson = jsonNode.get(YarnApplication.APPS_ELEMENT);
Set<String> yarnApplicationSet = new HashSet<String>();
if (appsJson == null) {
return yarnApplicationSet;
}
- JSONArray appJson = appsJson.optJSONArray(YarnApplication.APP_ELEMENT);
+ JsonNode appJson = appsJson.get(YarnApplication.APP_ELEMENT);
if (appJson == null) {
return yarnApplicationSet;
}
- for (int i = 0; i < appJson.length(); i++) {
-
- Gson gson = new GsonBuilder().create();
- YarnApplication yarnApplication =
- gson.fromJson(appJson.getJSONObject(i).toString(),
- new TypeToken<YarnApplication>() {
- }.getType());
- yarnApplicationSet.add(yarnApplication.getName());
+ for (final JsonNode clientVersion : appJson) {
+ yarnApplicationSet.add(clientVersion.get("name").textValue());
}
return yarnApplicationSet;
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
index f9ba69a..c92383d 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
@@ -138,9 +138,7 @@ import java.util.Set;
import java.util.HashSet;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HColumnDescriptor;
-import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.annotations.VisibleForTesting;
-import com.google.gson.JsonObject;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.client.Admin;
@@ -172,6 +170,7 @@ import org.apache.phoenix.coprocessor.MetaDataProtocol.MutationCode;
import org.apache.phoenix.coprocessor.MetaDataProtocol.SharedTableState;
import org.apache.phoenix.schema.stats.GuidePostsInfo;
import org.apache.phoenix.util.ViewUtil;
+import org.apache.phoenix.util.JacksonUtil;
import org.apache.phoenix.exception.SQLExceptionCode;
import org.apache.phoenix.exception.SQLExceptionInfo;
import org.apache.phoenix.execute.MutationState;
@@ -4475,7 +4474,7 @@ public class MetaDataClient {
boolean wasAutoCommit = connection.getAutoCommit();
try {
String dataTableName = statement.getTableName();
- String indexName = statement.getTable().getName().getTableName();
+ final String indexName = statement.getTable().getName().getTableName();
boolean isAsync = statement.isAsync();
boolean isRebuildAll = statement.isRebuildAll();
String tenantId = connection.getTenantId() == null ? null : connection.getTenantId().getString();
@@ -4558,14 +4557,16 @@ public class MetaDataClient {
tenantId, indexName);
if (tasks == null || tasks.size() == 0) {
Timestamp ts = new Timestamp(EnvironmentEdgeManager.currentTimeMillis());
- JsonObject jsonObject = new JsonObject();
- jsonObject.addProperty(INDEX_NAME, indexName);
- jsonObject.addProperty(REBUILD_ALL, true);
+ Map<String, Object> props = new HashMap<String, Object>() {{
+ put(INDEX_NAME, indexName);
+ put(REBUILD_ALL, true);
+ }};
try {
+ String json = JacksonUtil.getObjectWriter().writeValueAsString(props);
Task.addTask(connection, PTable.TaskType.INDEX_REBUILD,
tenantId, schemaName,
dataTableName, PTable.TaskStatus.CREATED.toString(),
- jsonObject.toString(), null, ts, null, true);
+ json, null, ts, null, true);
connection.commit();
} catch (IOException e) {
throw new SQLException("Exception happened while adding a System.Task" + e.toString());
diff --git a/phoenix-core/src/it/resources/compatible_client_versions.json b/phoenix-core/src/main/java/org/apache/phoenix/util/JacksonUtil.java
similarity index 52%
copy from phoenix-core/src/it/resources/compatible_client_versions.json
copy to phoenix-core/src/main/java/org/apache/phoenix/util/JacksonUtil.java
index 49a5297..86f0dde 100644
--- a/phoenix-core/src/it/resources/compatible_client_versions.json
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/JacksonUtil.java
@@ -15,10 +15,31 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-{
- "_comment": "Lists all phoenix compatible client versions against the current branch version for a given hbase profile \
- If hbase profile is 1.3, phoenix client versions 4.14.3 and 4.15.0 are tested against current branch version",
- "1.3": ["4.14.3", "4.15.0"],
- "1.4": ["4.14.3", "4.15.0"],
- "1.5": ["4.15.0"]
+package org.apache.phoenix.util;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectReader;
+import com.fasterxml.jackson.databind.ObjectWriter;
+
+public final class JacksonUtil {
+ private static final ObjectMapper mapper = new ObjectMapper();
+
+ private JacksonUtil() {
+ }
+
+ public static ObjectReader getObjectReader(Class clazz) {
+ return mapper.readerFor(clazz);
+ }
+
+ public static ObjectReader getObjectReader(){
+ return mapper.reader();
+ }
+
+ public static ObjectWriter getObjectWriter(Class clazz) {
+ return mapper.writerFor(clazz);
+ }
+
+ public static ObjectWriter getObjectWriter(){
+ return mapper.writer();
+ }
}
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/PhoenixMRJobUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/PhoenixMRJobUtil.java
index e0ed22d..fa35e46 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/PhoenixMRJobUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/PhoenixMRJobUtil.java
@@ -40,7 +40,6 @@ import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.Activ
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.ZooKeeper;
import org.apache.zookeeper.data.Stat;
-import org.codehaus.jettison.json.JSONException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -90,7 +89,7 @@ public class PhoenixMRJobUtil {
}
public static String getActiveResourceManagerAddress(Configuration config, String zkQuorum)
- throws IOException, InterruptedException, JSONException, KeeperException,
+ throws IOException, InterruptedException, KeeperException,
InvalidProtocolBufferException, ZooKeeperConnectionException {
// In case of yarn HA is NOT enabled
String resourceManager = PhoenixMRJobUtil.getRMWebAddress(config);
diff --git a/phoenix-tracing-webapp/src/main/java/org/apache/phoenix/tracingwebapp/http/TraceServlet.java b/phoenix-tracing-webapp/src/main/java/org/apache/phoenix/tracingwebapp/http/TraceServlet.java
index c0f82a0..db31d83 100755
--- a/phoenix-tracing-webapp/src/main/java/org/apache/phoenix/tracingwebapp/http/TraceServlet.java
+++ b/phoenix-tracing-webapp/src/main/java/org/apache/phoenix/tracingwebapp/http/TraceServlet.java
@@ -28,7 +28,8 @@ import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.phoenix.query.QueryServices;
import org.apache.phoenix.query.QueryServicesOptions;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.phoenix.util.JacksonUtil;
+
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
@@ -163,8 +164,7 @@ public class TraceServlet extends HttpServlet {
EntityFactory nutrientEntityFactory = new EntityFactory(con, sqlQuery);
List<Map<String, Object>> nutrients = nutrientEntityFactory
.findMultiple();
- ObjectMapper mapper = new ObjectMapper();
- json = mapper.writeValueAsString(nutrients);
+ json = JacksonUtil.getObjectWriter().writeValueAsString(nutrients);
} catch (Exception e) {
json = "{error:true,msg:'Server Error:" + e.getMessage() + "'}";
} finally {