ACCUMULO-2582 Just use the Work status instead of data in ZK
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/be780974 Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/be780974 Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/be780974 Branch: refs/heads/master Commit: be7809748aab6eb296018a5c60846df7d5dac6d1 Parents: 80a1688 Author: Josh Elser <[email protected]> Authored: Tue May 27 17:09:42 2014 -0400 Committer: Josh Elser <[email protected]> Committed: Tue May 27 17:09:42 2014 -0400 ---------------------------------------------------------------------- .../monitor/servlets/ReplicationServlet.java | 55 ++++++++++---------- 1 file changed, 28 insertions(+), 27 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/be780974/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/ReplicationServlet.java ---------------------------------------------------------------------- diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/ReplicationServlet.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/ReplicationServlet.java index 9c6a1ea..234c7b4 100644 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/ReplicationServlet.java +++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/ReplicationServlet.java @@ -44,6 +44,7 @@ import org.apache.accumulo.core.metadata.MetadataTable; import org.apache.accumulo.core.metadata.RootTable; import org.apache.accumulo.core.replication.ReplicationSchema.WorkSection; import org.apache.accumulo.core.replication.ReplicationTarget; +import org.apache.accumulo.core.replication.StatusUtil; import org.apache.accumulo.core.replication.proto.Replication.Status; import org.apache.accumulo.core.security.Authorizations; import org.apache.accumulo.core.security.Credentials; @@ -213,43 +214,43 @@ public class ReplicationServlet extends BasicServlet { String filename = queueKeyPair.getKey(); ReplicationTarget target = queueKeyPair.getValue(); - byte[] data = zooCache.get(workQueuePath + "/" + queueKey); - - if (null != data) { - Scanner s = ReplicationTable.getScanner(conn); - s.setRange(Range.exact(filename)); - s.fetchColumn(WorkSection.NAME, target.toText()); + Scanner s = ReplicationTable.getScanner(conn); + s.setRange(Range.exact(filename)); + s.fetchColumn(WorkSection.NAME, target.toText()); + + // Fetch the work entry for this item + String status = "Unknown"; + Entry<Key,Value> kv = null; + try { + kv = Iterables.getOnlyElement(s); + } catch (NoSuchElementException e) { + log.trace("Could not find status of {} replicating to {}", filename, target); + status = "Unknown"; + } finally { + s.close(); + } - // Fetch the work entry for this item - String status = "Unknown"; - Entry<Key,Value> kv = null; + // If we found the work entry for it, try to compute some progress + if (null != kv) { try { - kv = Iterables.getOnlyElement(s); - } catch (NoSuchElementException e) { - log.trace("Could not find status of {} replicating to {}", filename, target); - status = "Unknown"; - } finally { - s.close(); - } - - // If we found the work entry for it, try to compute some progress - if (null != kv) { - try { - Status stat = Status.parseFrom(kv.getValue().get()); + Status stat = Status.parseFrom(kv.getValue().get()); + if (StatusUtil.isFullyReplicated(stat)) { + status = "Finished"; + } else { if (stat.getInfiniteEnd()) { status = stat.getBegin() + "/∞"; } else { status = stat.getBegin() + "/" + stat.getEnd(); } - } catch (InvalidProtocolBufferException e) { - log.warn("Could not deserialize protobuf for {}", kv.getKey(), e); - status = "Unknown"; } + } catch (InvalidProtocolBufferException e) { + log.warn("Could not deserialize protobuf for {}", kv.getKey(), e); + status = "Unknown"; } - - // Add a row in the table - replicationInProgress.addRow(filename, target.getPeerName(), target.getSourceTableId(), target.getRemoteIdentifier(), status); } + + // Add a row in the table + replicationInProgress.addRow(filename, target.getPeerName(), target.getSourceTableId(), target.getRemoteIdentifier(), status); } replicationInProgress.generate(req, sb);
