{{ message }}
Repository navigation
Expand file tree
/
Copy pathzshrc
More file actions
250 lines (219 loc) · 10.6 KB
/
Copy pathzshrc
File metadata and controls
250 lines (219 loc) · 10.6 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
# 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.
# Path to your Oh My Zsh installation.
export ZSH="$HOME/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time Oh My Zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
ZSH_THEME="robbyrussell"
zstyle ':omz:update' mode disabled # disable automatic updates
# Which plugins would you like to load?
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git ssh)
source $ZSH/oh-my-zsh.sh
# Start Impala devcontainer customizations.
export IMPALA_HOME="${HOME}/impala"
export IMPALA_LINKER="mold"
export PATH="${PATH}:${IMPALA_HOME}/be/build/debug/service"
setup-asf-gerrit-remote() {
GIT_CFG_USER="$(git config user.name)"
echo -n "Enter Github.com Username, press return to use default of '${GIT_CFG_USER}'> "
read -r GIT_USER
if [[ -z "${GIT_USER}" ]]; then
GIT_USER="${GIT_CFG_USER}"
fi
pushd "${IMPALA_HOME}"
git remote add asf-gerrit "ssh://${GIT_USER}@gerrit.cloudera.org:29418/Impala-ASF" 2>/dev/null
git remote set-url asf-gerrit "ssh://${GIT_USER}@gerrit.cloudera.org:29418/Impala-ASF"
echo
echo "asf-gerrit remote:"
git remote -v | grep asf-gerrit
echo
popd
echo
echo "Add this SSH public key to Gerrit: "
cat "${HOME}/.ssh/id_ed25519.pub"
echo
}
omake ()
{
BASENAME="${1%.*}"
BASENAME=${BASENAME##*/}
MAKEFILE=$(grep -l "$BASENAME.cc.o:" $IMPALA_HOME/be/src/*/CMakeFiles/*.dir/build.make)
MAKEFILE=${MAKEFILE#$IMPALA_HOME/}
make DEBUG_NOOPT=1 -s -f $MAKEFILE ${MAKEFILE%/*}/$BASENAME.cc.o
}
mvn-debug-front-end() {
local target_test=${1}
if [[ -z ${target_test} ]]; then
echo "Error: undefined target test"
else
mvn \
-Dmaven.surefire.debug="-Xdebug \
-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 \
-Xnoagent \
-Djava.compiler=NONE" \
-fae \
-Dtest="${target_test}" \
test
fi
}
mvn-run-front-end() {
local target_test=${1}
if [[ -z ${target_test} ]]; then
echo "Error: undefined target test"
else
mvn test -Dtest="${target_test}"
fi
}
resolve-minidump() {
local log_dir="${1:-$IMPALA_LOGS_DIR/cluster}"
local minidump_file
if [[ "${log_dir}" == *".dmp" ]]; then
minidump_file="${log_dir}"
else
minidump_file=$(grep "Wrote minidump to " "${log_dir}/impalad.ERROR" | rev | cut -d" " -f1 | rev)
fi
if [[ -z "${minidump_file}" ]]; then
echo "Error: minidump file '${minidump_file}' not found"
return 1
fi
echo "Resolving minidump: ${minidump_file}"
resolve_minidumps.py --minidump_file "${minidump_file}" --output_file /tmp/resolve.txt
cat /tmp/resolve.txt | head -n 100
}
setup-postgis() {
local db_name="${1:-gisdb}"
echo "Setting up PostGIS extension for PostgreSQL in the '${db_name}' database."
sudo apt install -y postgresql-common gnupg2
sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y
POSTGRES_VER=$(sudo -u postgres psql -c "select version();" | grep "PostgreSQL" | sed -E 's/^\s*PostgreSQL\s*([0-9]+).*$/\1/')
sudo apt install -y "postgresql-${POSTGRES_VER}-postgis-3"
sudo apt install -y postgis
sudo -u postgres --preserve-env=db_name psql -c "CREATE DATABASE ${db_name};"
sudo -u postgres --preserve-env=db_name psql -c "ALTER DATABASE ${db_name} OWNER TO hiveuser;"
sudo -u postgres --preserve-env=db_name psql -d "${db_name}" -c "CREATE EXTENSION postgis;"
sudo -u postgres --preserve-env=db_name psql -d "${db_name}" -c "SELECT postgis_full_version();"
echo; echo "Adding connection to VSCode settings.json for database '${db_name}'."
if [[ $(grep -c "localhost-${db_name}" "${IMPALA_HOME}/.vscode/settings.json") -gt 0 ]]; then
echo "Connection localhost-${db_name} already exists; no change made."
else
awk -v db_name="${db_name}" '
BEGIN { in_sqltools = 0; inserted = 0 }
{
if ($0 ~ /"sqltools.connections"[[:space:]]*:[[:space:]]*\[/) in_sqltools = 1
if (in_sqltools && !inserted && $0 ~ /^[[:space:]]*\][[:space:]]*$/) {
print " ,"
print " {"
print " \"ssh\": \"Disabled\","
print " \"previewLimit\": 50,"
print " \"server\": \"localhost\","
print " \"port\": 5432,"
print " \"driver\": \"PostgreSQL\","
print " \"name\": \"localhost-" db_name "\",";
print " \"database\": \"" db_name "\",";
print " \"username\": \"hiveuser\","
print " \"password\": \"password\""
print " }"
inserted = 1
in_sqltools = 0
}
print
}
' "${IMPALA_HOME}/.vscode/settings.json" > "${IMPALA_HOME}/.vscode/settings.json.tmp" && mv "${IMPALA_HOME}/.vscode/settings.json.tmp" "${IMPALA_HOME}/.vscode/settings.json"
fi
}
alias ga="git add"
alias gb="git branch"
alias gba="git branch -a"
alias gbv="git branch -v"
alias gc="git commit -v"
alias gd="git diff"
alias grv="git remote -v"
alias gs="git status"
alias critique='pushd "${IMPALA_HOME}" && ./bin/jenkins/critique-gerrit-review.py --dryrun; popd'
alias restart-minicluster='pushd "${IMPALA_HOME}" && ./testdata/bin/run-all.sh; popd'
alias restart-hdfs='pushd "${IMPALA_HOME}" && ./testdata/bin/run-mini-dfs.sh; popd'
alias restart-hive='pushd "${IMPALA_HOME}" && ./testdata/bin/run-hive-server.sh; popd'
alias push-asf-gerrit-draft="git push asf-gerrit HEAD:refs/drafts/master"
alias push-asf-gerrit-publish="git push asf-gerrit HEAD:refs/for/master"
alias build-fe="pushd \${IMPALA_HOME} && make -j\${IMPALA_BUILD_THREADS} java; popd"
alias build-be="pushd \${IMPALA_HOME} && make -j\${IMPALA_BUILD_THREADS} impalad; popd"
alias build-all="pushd \${IMPALA_HOME} && ./buildall.sh -skiptests -noclean; popd"
help() {
# Define colors
local CYAN='\033[0;36m'
local GREEN='\033[0;32m'
local YELLOW='\033[1;33m'
local BOLD='\033[1m'
local NC='\033[0m'
echo
echo
echo -e "${CYAN}${BOLD}Welcome to Impala Devcontainer${NC}"
echo "Here are some helpful commands to get you started:"
echo
echo -e "${GREEN}${BOLD}Dependency Management Commands${NC}"
echo -e " * ${YELLOW}restart-hdfs${NC}: Starts or restarts HDFS"
echo -e " * ${YELLOW}restart-hive${NC}: Starts or restarts Hive"
echo -e " * ${YELLOW}restart-minicluster${NC}: Starts or restarts all supporting services (HMS, HDFS, Kudu, etc)"
echo -e " * ${YELLOW}setup-postgis${NC}: Sets up PostGIS extension for PostgreSQL. Defaults to the 'gisdb' database. Can specify a different database name as the first argument."
echo
echo -e "${GREEN}${BOLD}Build Commands${NC}"
echo -e " * ${YELLOW}build-be${NC}: Build the Impala backend code."
echo -e " * ${YELLOW}build-fe${NC}: Build the Impala frontend code."
echo -e " * ${YELLOW}build-all${NC}: Build the entire Impala project (including frontend, backend, and test code) without clean or running tests."
echo -e " * ${YELLOW}omake${NC}: Build a single '.o' file. Pass only the file name without any extension. For example, 'omake rpc-trace'."
echo
echo -e "${GREEN}${BOLD}Test/Debugging Commands${NC}"
echo -e " * ${YELLOW}mvn-debug-front-end${NC}: Runs JUnit tests in debug mode and waits for a debugger to connect. Use the 'JUnit FE Debug' debug configuration to connect to the waiting tests. Specify the tests to run as a comma separated string of class names or ClassName#testMethodName. Must be run from the 'fe' directory."
echo -e " * ${YELLOW}mvn-run-front-end${NC}: Runs JUnit tests. Specify the tests to run as a comma separated string of class names or ClassName#testMethodName. Must be run from the 'fe' directory."
echo -e " * ${YELLOW}resolve-minidump${NC}: Resolves minidump files to '/tmp/resolve.txt', and prints the first 100 lines. Can be used in multiple ways:"
echo -e " 1. No arguments -- Parses impalad.ERROR log file to locate the minidump file to resolve."
echo -e " 2. Log dir as only argument -- Parses impalad.ERROR log file in the specified directory to locate the minidump file to resolve."
echo -e " 3. Minidump file as only argument -- Resolves the specified minidump file to '/tmp/resolve.txt' and prints the first 100 lines."
echo
echo -e "${GREEN}${BOLD}Git Aliases${NC}"
echo -e " * ${YELLOW}ga${NC}: alias for 'git add'"
echo -e " * ${YELLOW}gb${NC}: alias for 'git branch'"
echo -e " * ${YELLOW}gba${NC}: alias for 'git branch -a'"
echo -e " * ${YELLOW}gbv${NC}: alias for 'git branch -v'"
echo -e " * ${YELLOW}gc${NC}: alias for 'git commit -v'"
echo -e " * ${YELLOW}gd${NC}: alias for 'git diff'"
echo -e " * ${YELLOW}grv${NC}: alias for 'git remote -v'"
echo -e " * ${YELLOW}gs${NC}: alias for 'git status'"
echo
echo -e "${GREEN}${BOLD}Gerrit Commands:${NC}"
echo -e " * ${YELLOW}critique${NC}: Dry run the Jenkins critque Gerrit review."
echo -e " * ${YELLOW}push-asf-gerrit-draft${NC}: Pushes the current branch to Gerrit as a draft patch set."
echo -e " * ${YELLOW}push-asf-gerrit-publish${NC}: Pushes the current branch to Gerrit as a published patch set."
echo -e " * ${YELLOW}setup-asf-gerrit-remote${NC}: Configures the 'asf-gerrit' git remote to point to the Gerrit repository for Impala. The remote is added with the SSH URL, so make sure you have your SSH keys set up properly to push to Gerrit."
echo
}
unsetopt AUTO_PUSHD
unset IMPALA_TOOLCHAIN_COMMIT_HASH
. "${IMPALA_HOME}/bin/impala-config.sh"
. "${IMPALA_HOME}/bin/set-classpath.sh"
cd "${IMPALA_HOME}"
echo
echo
echo "Welcome to Impala Devcontainer. Type 'help' for a list of available shell commands."
echo
# End Impala devcontainer customizations.
You can’t perform that action at this time.
