You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by GitBox <gi...@apache.org> on 2017/12/11 14:12:21 UTC

[GitHub] bfach10 closed pull request #335: ACCUMULO-4755 Custom Serializer for AbstractId Types

bfach10 closed pull request #335: ACCUMULO-4755 Custom Serializer for AbstractId Types
URL: https://github.com/apache/accumulo/pull/335
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/AbstractId.java b/core/src/main/java/org/apache/accumulo/core/client/impl/AbstractId.java
index 9bf7341fb2..20ebdbef76 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/AbstractId.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/AbstractId.java
@@ -16,6 +16,8 @@
  */
 package org.apache.accumulo.core.client.impl;
 
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
 import static java.nio.charset.StandardCharsets.UTF_8;
 import static java.util.Objects.requireNonNull;
 
@@ -25,6 +27,7 @@
 /**
  * An abstract identifier class for comparing equality of identifiers of the same type.
  */
+@JsonSerialize(using = AbstractIdSerializer.class)
 public abstract class AbstractId implements Comparable<AbstractId>, Serializable {
 
   private static final long serialVersionUID = -155513612834787244L;
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/AbstractIdSerializer.java b/core/src/main/java/org/apache/accumulo/core/client/impl/AbstractIdSerializer.java
new file mode 100644
index 0000000000..41e682b709
--- /dev/null
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/AbstractIdSerializer.java
@@ -0,0 +1,36 @@
+/*
+ * 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.accumulo.core.client.impl;
+
+import org.codehaus.jackson.JsonGenerator;
+import org.codehaus.jackson.map.SerializerProvider;
+import org.codehaus.jackson.map.ser.std.SerializerBase;
+
+import java.io.IOException;
+
+public class AbstractIdSerializer extends SerializerBase<AbstractId> {
+
+  public AbstractIdSerializer() {
+    super(AbstractId.class, true);
+  }
+
+  @Override public void serialize(AbstractId id, JsonGenerator jgen, SerializerProvider provider) throws IOException {
+    jgen.writeStartObject();
+    jgen.writeString(id.canonicalID());
+    jgen.writeEndObject();
+  }
+}
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/problems/ProblemSummaryInformation.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/problems/ProblemSummaryInformation.java
index 165bf86cfc..9f688c01a6 100644
--- a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/problems/ProblemSummaryInformation.java
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/problems/ProblemSummaryInformation.java
@@ -29,7 +29,7 @@
 
   // Variable names become JSON keys
   public String tableName;
-  public String tableID;
+  public Table.ID tableID;
 
   public Integer fileRead;
   public Integer fileWrite;
@@ -53,7 +53,7 @@ public ProblemSummaryInformation() {}
    */
   public ProblemSummaryInformation(String tableName, Table.ID tableId, Integer fileRead, Integer fileWrite, Integer tableLoad) {
     this.tableName = tableName;
-    this.tableID = tableId.canonicalID();
+    this.tableID = tableId;
     this.fileRead = fileRead;
     this.fileWrite = fileWrite;
     this.tableLoad = tableLoad;
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tables/TableInformation.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tables/TableInformation.java
index cacd3424a5..d15104611a 100644
--- a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tables/TableInformation.java
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tables/TableInformation.java
@@ -30,7 +30,7 @@
 
   // Variable names become JSON keys
   public String tablename;
-  public String tableId;
+  public Table.ID tableId;
   public String tableState;
 
   public int tablets;
@@ -75,7 +75,7 @@ public TableInformation() {}
    */
   public TableInformation(String tableName, Table.ID tableId, String tableState) {
     this.tablename = tableName;
-    this.tableId = tableId.canonicalID();
+    this.tableId = tableId;
     this.tableState = tableState;
   }
 
@@ -95,7 +95,7 @@ public TableInformation(String tableName, Table.ID tableId, String tableState) {
    */
   public TableInformation(String tableName, Table.ID tableId, TableInfo info, Double holdTime, String tableState) {
     this.tablename = tableName;
-    this.tableId = tableId.canonicalID();
+    this.tableId = tableId;
 
     this.tablets = info.tablets;
     this.offlineTablets = info.tablets - info.onlineTablets;
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/CurrentOperations.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/CurrentOperations.java
index 50f9bff6af..fab1969ae3 100644
--- a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/CurrentOperations.java
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/CurrentOperations.java
@@ -30,7 +30,7 @@
   // Variable names become JSON keys
   public String name;
   public String tablet;
-  public String tableID;
+  public Table.ID tableID;
   public long entries;
   public double ingest;
   public double query;
@@ -74,7 +74,7 @@ public CurrentOperations() {}
   public CurrentOperations(String name, Table.ID tableId, String tablet, long entries, double ingest, double query, Double minorAvg, Double minorStdDev,
       Double minorAvgES, Double majorAvg, Double majorStdDev, Double majorAvgES) {
     this.name = name;
-    this.tableID = tableId.canonicalID();
+    this.tableID = tableId;
     this.tablet = tablet;
     this.entries = entries;
     this.ingest = ingest;


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services