[GitHub] [zookeeper] sonatype-lift[bot] commented on a diff in pull request #1902: ZOOKEEPER-4566: Create tool for recursive snapshot analysis
sonatype-lift[bot] commented on code in PR #1902: URL: https://github.com/apache/zookeeper/pull/1902#discussion_r918634205 ## bin/zkSnapshotRecursiveSummaryToolkit.sh: ## @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +# 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. + +# +# If this scripted is run out of /usr/bin or some other system bin directory +# it should be linked to and not copied. Things like java jar files are found +# relative to the canonical path of this script. +# + +# use POSIX interface, symlink is followed automatically +ZOOBIN="${BASH_SOURCE-$0}" +ZOOBIN="$(dirname "${ZOOBIN}")" +ZOOBINDIR="$(cd "${ZOOBIN}"; pwd)" + +if [ -e "$ZOOBIN/../libexec/zkEnv.sh" ]; then + . "$ZOOBINDIR"/../libexec/zkEnv.sh +else + . "$ZOOBINDIR"/zkEnv.sh +fi + +"$JAVA" -cp "$CLASSPATH" $JVMFLAGS \ Review Comment: The **ignoreall** command is active on this PR, all the existing Lift issues are ignored. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@zookeeper.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [zookeeper] sonatype-lift[bot] commented on a diff in pull request #1902: ZOOKEEPER-4566: Create tool for recursive snapshot analysis
sonatype-lift[bot] commented on code in PR #1902: URL: https://github.com/apache/zookeeper/pull/1902#discussion_r911947595 ## zookeeper-server/src/main/java/org/apache/zookeeper/server/SnapshotRecursiveSummary.java: ## @@ -0,0 +1,138 @@ +/** + * 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.zookeeper.server; + +import org.apache.jute.BinaryInputArchive; +import org.apache.jute.InputArchive; +import org.apache.yetus.audience.InterfaceAudience; +import org.apache.zookeeper.server.persistence.FileSnap; +import org.apache.zookeeper.server.persistence.SnapStream; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +/** + * Recursively processes a snapshot file collecting child node count and summarizes the data size + * below each node. + * "starting_node" defines the node where the recursion starts + * "max_depth" defines the depth where the tool still writes to the output. + * 0 means there is no depth limit, every non-leaf node's stats will be displayed, 1 means it will + * only contain the starting node's and it's children's stats, 2 ads another level and so on. + * This ONLY affects the level of details displayed, NOT the calculation. + */ +@InterfaceAudience.Public public class SnapshotRecursiveSummary { + + /** + * USAGE: SnapsotRecursiveSummary snapshot_file starting_node max_depth + * + */ + public static void main(String[] args) throws Exception { +if (args.length != 3) { + System.err.println(getUsage()); + System.exit(2); +} +int maxDepth = 0; +try { + maxDepth = Integer.valueOf(args[2]).intValue(); +} catch (NumberFormatException e) { + System.err.println(getUsage()); + System.exit(2); +} + +new SnapshotRecursiveSummary().run(args[0], args[1], maxDepth); + } + + public void run(String snapshotFileName, String startingNode, int maxDepth) throws IOException { +File snapshotFile = new File(snapshotFileName); Review Comment: I've recorded this as ignored for this pull request. If you change your mind, just comment `@sonatype-lift unignore`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@zookeeper.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [zookeeper] sonatype-lift[bot] commented on a diff in pull request #1902: ZOOKEEPER-4566: Create tool for recursive snapshot analysis
sonatype-lift[bot] commented on code in PR #1902: URL: https://github.com/apache/zookeeper/pull/1902#discussion_r911907134 ## zookeeper-server/src/main/java/org/apache/zookeeper/server/SnapshotRecursiveSummary.java: ## @@ -0,0 +1,138 @@ +/** + * 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.zookeeper.server; + +import org.apache.jute.BinaryInputArchive; +import org.apache.jute.InputArchive; +import org.apache.yetus.audience.InterfaceAudience; +import org.apache.zookeeper.server.persistence.FileSnap; +import org.apache.zookeeper.server.persistence.SnapStream; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +/** + * Recursively processes a snapshot file collecting child node count and summarizes the data size + * below each node. + * "starting_node" defines the node where the recursion starts + * "max_depth" defines the depth where the tool still writes to the output. + * 0 means there is no depth limit, every non-leaf node's stats will be displayed, 1 means it will + * only contain the starting node's and it's children's stats, 2 ads another level and so on. + * This ONLY affects the level of details displayed, NOT the calculation. + */ +@InterfaceAudience.Public public class SnapshotRecursiveSummary { + + /** + * USAGE: SnapsotRecursiveSummary snapshot_file starting_node max_depth + * + */ + public static void main(String[] args) throws Exception { +if (args.length != 3) { + System.err.println(getUsage()); + System.exit(2); +} +int maxDepth = 0; +try { + maxDepth = Integer.valueOf(args[2]).intValue(); +} catch (NumberFormatException e) { + System.err.println(getUsage()); + System.exit(2); +} + +new SnapshotRecursiveSummary().run(args[0], args[1], maxDepth); + } + + public void run(String snapshotFileName, String startingNode, int maxDepth) throws IOException { +File snapshotFile = new File(snapshotFileName); Review Comment: *[PATH_TRAVERSAL_IN](https://find-sec-bugs.github.io/bugs.htm#PATH_TRAVERSAL_IN):* This API (java/io/File.(Ljava/lang/String;)V) reads a file whose location might be specified by user input Reply with *"**@sonatype-lift help**"* for info about LiftBot commands. Reply with *"**@sonatype-lift ignore**"* to tell LiftBot to leave out the above finding from this PR. Reply with *"**@sonatype-lift ignoreall**"* to tell LiftBot to leave out all the findings from this PR and from the status bar in Github. When talking to LiftBot, you need to **refresh** the page to see its response. [Click here](https://help.sonatype.com/lift/talking-to-lift) to get to know more about LiftBot commands. --- Was this a good recommendation? [ [ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=289522632_comment_rating=1) ] - [ [ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=289522632_comment_rating=2) ] - [ [ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=289522632_comment_rating=3) ] - [ [ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=289522632_comment_rating=4) ] - [ [ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=289522632_comment_rating=5) ] ## zookeeper-server/src/main/java/org/apache/zookeeper/server/SnapshotRecursiveSummary.java: ## @@ -0,0 +1,138 @@ +/** + * 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