-
Notifications
You must be signed in to change notification settings - Fork 1
/
hudi-stat.sh
46 lines (42 loc) · 1.47 KB
/
hudi-stat.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
path="$1"
shift
table=$(basename "$path")
sections=$@
export APP_HOME="$(
cd "$(dirname $(readlink -nf "$0"))"
pwd -P
)"
echo "-------------- [ $(date '+%F %T') ] --------------" >> $APP_HOME/hudi-stat.log
for section in $sections; do
echo
echo "[ ${section^^} ]"
echo
if [[ "$section" == "storage" ]]; then
# show file layout from local with tree cli
aws s3 sync --delete $path $APP_HOME/$table --exclude "*$" --exclude ".hoodie/*" --exclude "*/.hoodie*" &>/dev/null
tree --du -ahs -D --timefmt '%T' --noreport $APP_HOME/$table
echo "tree $APP_HOME/$table" >> $APP_HOME/hudi-stat.log
else
# make hudi-cli scripts and execute
hudiCliScripts="$APP_HOME/.hudi-cli.scripts"
echo "connect --path $path" > "$hudiCliScripts"
case $section in
timeline)
echo "timeline show active" >> "$hudiCliScripts"
;;
compactions)
echo "compactions show all" >> "$hudiCliScripts"
;;
commits)
echo "commits show" >> "$hudiCliScripts"
;;
fsview)
echo "show fsview all" >> "$hudiCliScripts"
;;
esac
# for hudi-cli, only script mode can exit automatically
hudi-cli script "$hudiCliScripts" 2>/dev/null | grep -o -e '^[╔].*\|^[║].*\|^[╠].*\|^[╟].*\|^[╚].*'
cat "$hudiCliScripts" >> $APP_HOME/hudi-stat.log
fi
done