Skip to content

Commit 9f3d7cb

Browse files
authored
HDDS-14960. OM Web UI dashboard for Ozone Snapshot (#10027)
1 parent 584bb6a commit 9f3d7cb

15 files changed

Lines changed: 479 additions & 11 deletions

File tree

hadoop-hdds/framework/src/main/resources/webapps/static/ozone.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,8 @@
256256
ioLinkHref: '@',
257257
scanner: '<',
258258
scannerLinkHref: '@',
259+
snapshot: '@',
260+
snapshotLinkHref: '@'
259261
},
260262
templateUrl: 'static/templates/menu.html',
261263
controller: function($http) {

hadoop-hdds/framework/src/main/resources/webapps/static/templates/menu.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,6 @@
5858
</li>
5959
<li ng-show="$ctrl.iostatus"><a ng-href="{{$ctrl.ioLinkHref}}">IO Status</a></li>
6060
<li ng-show="$ctrl.scanner"><a ng-href="{{$ctrl.scannerLinkHref}}">Data Scanner</a></li>
61+
<li ng-show="$ctrl.snapshot"><a ng-href="{{$ctrl.snapshotLinkHref}}">Ozone Snapshot</a></li>
6162
</ul>
6263
</div><!--/.nav-collapse -->

hadoop-hdds/server-scm/src/main/resources/webapps/scm/scm-overview.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,4 +391,4 @@ <h2>Safemode rules statuses</h2>
391391
<td>{{typestat.value[1]}}</td>
392392
</tr>
393393
</tbody>
394-
</table>
394+
</table>

hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/SnapshotDiffJob.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public SnapshotDiffJob(long creationTime,
9494
this.largestEntryKey = largestEntryKey;
9595
}
9696

97-
public static Codec<SnapshotDiffJob> getCodec() {
97+
public static Codec<SnapshotDiffJob> codec() {
9898
return CODEC;
9999
}
100100

@@ -228,10 +228,10 @@ public String toString() {
228228
sb.append(", reason: ").append(reason);
229229
}
230230
if (status.equals(JobStatus.IN_PROGRESS) && subStatus != null) {
231-
sb.append(", subStatus: ").append(status);
231+
sb.append(", subStatus: ").append(subStatus);
232232
if (subStatus.equals(SubStatus.OBJECT_ID_MAP_GEN_FSO) ||
233233
subStatus.equals(SubStatus.OBJECT_ID_MAP_GEN_OBS)) {
234-
sb.append(String.format(", keysProcessedPercent: %.2f", keysProcessedPct));
234+
sb.append(String.format(", keysProcessedPct: %.2f", keysProcessedPct));
235235
}
236236
}
237237
return sb.toString();

hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/helpers/TestOmSnapshotDiffJobCodec.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
public class TestOmSnapshotDiffJobCodec {
3131
private final OldSnapshotDiffJobCodecForTesting oldCodec
3232
= new OldSnapshotDiffJobCodecForTesting();
33-
private final Codec<SnapshotDiffJob> newCodec = SnapshotDiffJob.getCodec();
33+
private final Codec<SnapshotDiffJob> newCodec = SnapshotDiffJob.codec();
3434

3535
@Test
3636
public void testOldJsonSerializedDataCanBeReadByNewCodec() throws Exception {

hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmSnapshotManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ private static CodecRegistry createCodecRegistryForSnapDiff() {
425425
// DiffReportEntry codec for Diff Report.
426426
registry.addCodec(SnapshotDiffReportOzone.DiffReportEntry.class,
427427
SnapshotDiffReportOzone.getDiffReportEntryCodec());
428-
registry.addCodec(SnapshotDiffJob.class, SnapshotDiffJob.getCodec());
428+
registry.addCodec(SnapshotDiffJob.class, SnapshotDiffJob.codec());
429429
return registry.build();
430430
}
431431

hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/SnapshotDiffManager.java

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,12 @@
9595
import java.util.function.BiFunction;
9696
import java.util.function.Consumer;
9797
import java.util.stream.Collectors;
98+
import javax.management.ObjectName;
9899
import org.apache.commons.io.file.PathUtils;
99100
import org.apache.commons.lang3.tuple.Pair;
101+
import org.apache.hadoop.hdds.HddsUtils;
100102
import org.apache.hadoop.hdds.StringUtils;
103+
import org.apache.hadoop.hdds.annotation.InterfaceAudience;
101104
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
102105
import org.apache.hadoop.hdds.utils.NativeLibraryNotLoadedException;
103106
import org.apache.hadoop.hdds.utils.db.CodecRegistry;
@@ -111,6 +114,7 @@
111114
import org.apache.hadoop.hdds.utils.db.managed.ManagedRocksDB;
112115
import org.apache.hadoop.hdfs.protocol.SnapshotDiffReport.DiffReportEntry;
113116
import org.apache.hadoop.hdfs.protocol.SnapshotDiffReport.DiffType;
117+
import org.apache.hadoop.metrics2.util.MBeans;
114118
import org.apache.hadoop.ozone.OFSPath;
115119
import org.apache.hadoop.ozone.OzoneConsts;
116120
import org.apache.hadoop.ozone.om.OMMetadataManager;
@@ -147,7 +151,8 @@
147151
/**
148152
* Class to generate snapshot diff.
149153
*/
150-
public class SnapshotDiffManager implements AutoCloseable {
154+
@InterfaceAudience.Private
155+
public class SnapshotDiffManager implements AutoCloseable, SnapshotDiffManagerMXBean {
151156
private static final Logger LOG =
152157
LoggerFactory.getLogger(SnapshotDiffManager.class);
153158
private static final Map<DiffType, String> DIFF_TYPE_STRING_MAP =
@@ -177,6 +182,7 @@ public class SnapshotDiffManager implements AutoCloseable {
177182
*/
178183
private final PersistentMap<String, SnapshotDiffJob> snapDiffJobTable;
179184
private final ExecutorService snapDiffExecutor;
185+
private ObjectName snapshotDiffManagerBeanName;
180186

181187
/**
182188
* Directory to keep hardlinks of SST files for a snapDiff job temporarily.
@@ -280,6 +286,7 @@ public SnapshotDiffManager(ManagedRocksDB db,
280286
// When we build snapDiff HA aware, we will revisit this.
281287
// Details: https://github.com/apache/ozone/pull/4438#discussion_r1149788226
282288
this.loadJobsOnStartUp();
289+
this.registerMXBean();
283290
}
284291

285292
@VisibleForTesting
@@ -1514,8 +1521,34 @@ void loadJobsOnStartUp() {
15141521
}
15151522
}
15161523

1524+
@Override
1525+
public List<SnapshotDiffJob> getSnapshotDiffJobs() {
1526+
List<SnapshotDiffJob> jobs = new ArrayList<>();
1527+
try (ClosableIterator<Map.Entry<String, SnapshotDiffJob>> iterator =
1528+
snapDiffJobTable.iterator()) {
1529+
while (iterator.hasNext()) {
1530+
jobs.add(iterator.next().getValue());
1531+
}
1532+
}
1533+
return jobs;
1534+
}
1535+
1536+
private void registerMXBean() {
1537+
this.snapshotDiffManagerBeanName = HddsUtils.registerWithJmxProperties(
1538+
"OzoneManager", "SnapshotDiffManager",
1539+
Collections.emptyMap(), this);
1540+
}
1541+
1542+
private void unregisterMXBean() {
1543+
if (this.snapshotDiffManagerBeanName != null) {
1544+
MBeans.unregister(this.snapshotDiffManagerBeanName);
1545+
this.snapshotDiffManagerBeanName = null;
1546+
}
1547+
}
1548+
15171549
@Override
15181550
public void close() {
1551+
unregisterMXBean();
15191552
if (snapDiffExecutor != null) {
15201553
closeExecutorService(snapDiffExecutor, "SnapDiffExecutor");
15211554
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.hadoop.ozone.om.snapshot;
19+
20+
import java.util.List;
21+
import org.apache.hadoop.hdds.annotation.InterfaceAudience;
22+
import org.apache.hadoop.ozone.om.helpers.SnapshotDiffJob;
23+
24+
/**
25+
* JMX interface for SnapshotDiffManager.
26+
*/
27+
@InterfaceAudience.Private
28+
public interface SnapshotDiffManagerMXBean {
29+
/**
30+
* Returns all snapshot diff jobs.
31+
* @return list of snapshot diff jobs
32+
*/
33+
List<SnapshotDiffJob> getSnapshotDiffJobs();
34+
}

hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/db/SnapshotDiffDBDefinition.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public final class SnapshotDiffDBDefinition extends DBDefinition.WithMap {
5151
public static final String SNAP_DIFF_JOB_TABLE_NAME = "snap-diff-job-table";
5252

5353
public static final DBColumnFamilyDefinition<String, SnapshotDiffJob> SNAP_DIFF_JOB_TABLE_DEF
54-
= new DBColumnFamilyDefinition<>(SNAP_DIFF_JOB_TABLE_NAME, StringCodec.get(), SnapshotDiffJob.getCodec());
54+
= new DBColumnFamilyDefinition<>(SNAP_DIFF_JOB_TABLE_NAME, StringCodec.get(), SnapshotDiffJob.codec());
5555
/**
5656
* Global table to keep the diff report. Each key is prefixed by the jobId
5757
* to improve look up and clean up. JobId comes from snap-diff-job-table.

hadoop-ozone/ozone-manager/src/main/resources/webapps/ozoneManager/index.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@
4949
<a class="navbar-brand" href="#">Ozone Manager</a>
5050
</div>
5151
<navmenu
52-
metrics="{ 'OM metrics' : '#!/metrics/ozoneManager', 'Rpc metrics' : '#!/metrics/rpc'}"></navmenu>
52+
metrics="{ 'OM metrics' : '#!/metrics/ozoneManager', 'Rpc metrics' : '#!/metrics/rpc'}"
53+
snapshot="true"
54+
snapshot-link-href="#!/snapshots"></navmenu>
5355
</div>
5456
</header>
5557

0 commit comments

Comments
 (0)