Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BIGTOP-1561. Add Presto as a component #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions bigtop-packages/src/common/presto/do-component-build
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/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.

set -ex

. `dirname $0`/bigtop.bom

mvn clean install -DskipTests

mkdir -p build/presto-${PRESTO_VERSION}
mkdir -p build/presto-${PRESTO_VERSION}/docs

# Server
tar -C build/presto-${PRESTO_VERSION} --strip-components=1 -xzf presto-server/target/presto-server-${PRESTO_VERSION}.tar.gz
# CLI
cp -ra presto-cli/target/presto-cli-${PRESTO_VERSION}-executable.jar build/presto-${PRESTO_VERSION}/bin/presto
# Docs
cp -ra presto-docs/target/html/* build/presto-${PRESTO_VERSION}/docs/
# JDBC
cp -ra presto-jdbc/target/presto-jdbc-${PRESTO_VERSION}.jar build/presto-${PRESTO_VERSION}/lib/
# Verifier
cp -ra presto-verifier/target/presto-verifier-${PRESTO_VERSION}-executable.jar build/presto-${PRESTO_VERSION}/bin/verifier
# Benchmark Driver
cp -ra presto-benchmark-driver/target/presto-benchmark-driver-${PRESTO_VERSION}-executable.jar build/presto-${PRESTO_VERSION}/bin/presto-benchmark-driver
205 changes: 205 additions & 0 deletions bigtop-packages/src/common/presto/install_presto.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
#!/bin/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.

set -e

usage() {
echo "
usage: $0 <options>
Required not-so-options:
--build-dir=DIR path to dist.dir
--source-dir=DIR path to package shared files dir
--prefix=PREFIX path to install into

Optional options:
--doc-dir=DIR path to install docs into [/usr/share/doc/presto]
--lib-dir=DIR path to install Presto home [/usr/lib/presto]
--installed-lib-dir=DIR path where lib-dir will end up on target system
--bin-dir=DIR path to install bins [/usr/bin]
... [ see source for more similar options ]
"
exit 1
}

OPTS=$(getopt \
-n $0 \
-o '' \
-l 'prefix:' \
-l 'doc-dir:' \
-l 'lib-dir:' \
-l 'installed-lib-dir:' \
-l 'bin-dir:' \
-l 'source-dir:' \
-l 'build-dir:' -- "$@")

if [ $? != 0 ] ; then
usage
fi

eval set -- "$OPTS"
while true ; do
case "$1" in
--prefix)
PREFIX=$2 ; shift 2
;;
--build-dir)
BUILD_DIR=$2 ; shift 2
;;
--source-dir)
SOURCE_DIR=$2 ; shift 2
;;
--doc-dir)
DOC_DIR=$2 ; shift 2
;;
--lib-dir)
LIB_DIR=$2 ; shift 2
;;
--installed-lib-dir)
INSTALLED_LIB_DIR=$2 ; shift 2
;;
--bin-dir)
BIN_DIR=$2 ; shift 2
;;
--)
shift ; break
;;
*)
echo "Unknown option: $1"
usage
exit 1
;;
esac
done

for var in PREFIX BUILD_DIR SOURCE_DIR; do
if [ -z "$(eval "echo \$$var")" ]; then
echo Missing param: $var
usage
fi
done

if [ -f "$SOURCE_DIR/bigtop.bom" ]; then
. $SOURCE_DIR/bigtop.bom
fi

MAN_DIR=${MAN_DIR:-/usr/share/man/man1}
DOC_DIR=${DOC_DIR:-/usr/share/doc/presto}
LIB_DIR=${LIB_DIR:-/usr/lib/presto}
VAR_DIR=${VAR_DIR:-/var/lib/presto}
LOG_DIR=${LOG_DIR:-/var/log/presto}
RUN_DIR=${RUN_DIR:-/var/run/presto}
INSTALLED_LIB_DIR=${INSTALLED_LIB_DIR:-/usr/lib/presto}
BIN_DIR=${BIN_DIR:-/usr/bin}
CONF_DIR=${CONF_DIR:-/etc/presto}
CONF_DIST_DIR=${CONF_DIST_DIR:-/etc/presto.dist}
DEFAULT_DIR=${DEFAULT_DIR:-/etc/default}

install -d -m 0755 $PREFIX/$CONF_DIST_DIR
install -d -m 0755 $PREFIX/$LIB_DIR
install -d -m 0755 $PREFIX/$LIB_DIR/lib
install -d -m 0755 $PREFIX/$LIB_DIR/bin
install -d -m 0755 $PREFIX/$LIB_DIR/var
install -d -m 0755 $PREFIX/$LIB_DIR/plugin
install -d -m 0755 $PREFIX/$DOC_DIR
install -d -m 0755 $PREFIX/$VAR_DIR
install -d -m 0755 $PREFIX/$LOG_DIR
install -d -m 0755 $PREFIX/$RUN_DIR
install -d -m 0755 $PREFIX/$DEFAULT_DIR

cp -ra ${BUILD_DIR}/* $PREFIX/$LIB_DIR/
mv $PREFIX/$LIB_DIR/docs/* $PREFIX/$DOC_DIR/

chmod +x $PREFIX/$LIB_DIR/bin/{presto,verifier,presto-benchmark-driver}

install -d -m 0755 $PREFIX/$CONF_DIST_DIR
install -d -m 0755 $PREFIX/$CONF_DIST_DIR/catalog

cat > $PREFIX/$CONF_DIST_DIR/node.properties <<EOF
node.environment=production
node.id=ffffffff-ffff-ffff-ffff-ffffffffffff
node.data-dir=/var/lib/presto/
EOF

cat > $PREFIX/$CONF_DIST_DIR/jvm.config <<EOF
-server
-Xmx16G
-XX:+UseG1GC
-XX:G1HeapRegionSize=32M
-XX:+UseGCOverheadLimit
-XX:+ExplicitGCInvokesConcurrent
-XX:+HeapDumpOnOutOfMemoryError
-XX:+ExitOnOutOfMemoryError
-DHADOOP_USER_NAME=hive
EOF

cat > $PREFIX/$CONF_DIST_DIR/config.properties <<EOF
# A single machine for testing that will function as both a coordinator and worker
coordinator=true
node-scheduler.include-coordinator=true
http-server.http.port=8080
query.max-memory=5GB
query.max-memory-per-node=1GB
discovery-server.enabled=true
discovery.uri=http://localhost:8080

# Minimal configuration for the coordinator:
#coordinator=true
#node-scheduler.include-coordinator=false
#http-server.http.port=8080
#query.max-memory=5GB
#query.max-memory-per-node=1GB
#discovery-server.enabled=true
#discovery.uri=http://example.net:8080

# Minimal configuration for the workers:
#coordinator=false
#http-server.http.port=8080
#query.max-memory=50GB
#query.max-memory-per-node=1GB
#discovery.uri=http://example.net:8080

http-server.log.path=/var/log/presto/http-request.log
EOF

cat > $PREFIX/$CONF_DIST_DIR/log.properties <<EOF
com.facebook.presto=INFO
EOF

cat > $PREFIX/$CONF_DIST_DIR/catalog/tpch.properties <<EOF
connector.name=tpch
EOF

cat > $PREFIX/$CONF_DIST_DIR/catalog/jmx.properties <<EOF
connector.name=jmx
EOF

# Wrappers
install -d -m 0755 $PREFIX/$BIN_DIR
for wrap in bin/presto bin/verifier; do
cat > $PREFIX/$BIN_DIR/`basename $wrap` <<EOF
#!/bin/bash

# Autodetect JAVA_HOME if not defined
. /usr/lib/bigtop-utils/bigtop-detect-javahome

exec $INSTALLED_LIB_DIR/$wrap "\$@"
EOF
chmod 755 $PREFIX/$BIN_DIR/`basename $wrap`
done

ln -s ${LOG_DIR} $PREFIX/$LIB_DIR/log
ln -s ${CONF_DIR} $PREFIX/$LIB_DIR/etc
70 changes: 70 additions & 0 deletions bigtop-packages/src/common/presto/presto-server.svc
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# 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.

TYPE="server"
DAEMON="presto-${TYPE}"
DESC="Presto ${TYPE}"
EXEC_PATH="/usr/lib/presto/bin/launcher"
SVC_USER="presto"
WORKING_DIR="/usr/lib/presto"
DAEMON_FLAGS="--launcher-config /usr/lib/presto/bin/launcher.properties --jvm-config /etc/presto/jvm.config --config /etc/presto/config.properties --data-dir /var/lib/presto/ --pid-file /var/run/presto/${DAEMON}.pid --launcher-log-file /var/log/presto/${DAEMON}.out --server-log-file /var/log/presto/${DAEMON}.log"
CONF_DIR="/etc/presto"
PIDFILE="/var/run/presto/${DAEMON}.pid"

generate_start() {

cat <<'__EOT__'
start() {
# node.id
sed -i -e "s#ffffffff-ffff-ffff-ffff-ffffffffffff#$(cat /proc/sys/kernel/random/uuid)#" ${CONF_DIR}/node.properties

[ -x $EXE_FILE ] || exit $ERROR_PROGRAM_NOT_INSTALLED
log_success_msg "Starting $DESC (${DAEMON}): "

checkstatusofproc
status=$?
if [ "$status" -eq "$STATUS_RUNNING" ]; then
log_success_msg "${DESC} is running"
exit 0
fi

su -s /bin/bash $SVC_USER -c "${EXEC_PATH} start $DAEMON_FLAGS"

sleep 3

checkstatusofproc
RETVAL=$?
[ $RETVAL -eq $STATUS_RUNNING ] && touch $LOCKFILE
return $RETVAL
}
__EOT__

}

generate_stop() {

cat <<'__EOT__'
stop() {
log_success_msg "Stopping $DESC (${DAEMON}): "
su -s /bin/bash $SVC_USER -c "${EXEC_PATH} stop $DAEMON_FLAGS"
RETVAL=$?

[ $RETVAL -eq $RETVAL_SUCCESS ] && rm -f $LOCKFILE $PIDFILE
return $RETVAL
}
__EOT__

}

1 change: 1 addition & 0 deletions bigtop-packages/src/deb/presto/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--- This is auto-generated
1 change: 1 addition & 0 deletions bigtop-packages/src/deb/presto/compat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9
54 changes: 54 additions & 0 deletions bigtop-packages/src/deb/presto/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# 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.

Source: presto
Section: misc
Priority: extra
Maintainer: Bigtop <dev@bigtop.apache.org>
Build-Depends: debhelper (>= 9)
Standards-Version: 3.9.4
Homepage: https://prestodb.io/

Package: presto
Architecture: any
Depends: adduser, bigtop-utils (>= 0.7)
Description: https://prestodb.io/
Presto is an open source distributed SQL query engine for running
interactive analytic queries against data sources of all sizes ranging
from gigabytes to petabytes.

Package: presto-server
Architecture: all
Depends: presto (= ${source:Version})
Description: Server for Presto
Server for Presto

Package: presto-cli
Architecture: all
Depends: presto (= ${source:Version})
Description: Presto CLI
Presto CLI

Package: presto-jdbc
Architecture: all
Depends: presto (= ${source:Version})
Description: Presto JDBC Driver
JDBC Driver for Presto

Package: presto-doc
Architecture: all
Depends:
Description: Presto Documentation
Presto Documentation
15 changes: 15 additions & 0 deletions bigtop-packages/src/deb/presto/copyright
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Format: http://dep.debian.net/deps/dep5
Source: https://prestodb.io/
Upstream-Name: Presto

Files: *
Copyright: 2013, Facebook
License: Apache-2.0

Files debian/*
Copyright: 2011, The Apache Software Foundation
License: Apache-2.0

License: Apache-2.0
On Debian systems, the complete text of the Apache 2.0 license
can be found in "/usr/share/common-licenses/Apache-2.0".
3 changes: 3 additions & 0 deletions bigtop-packages/src/deb/presto/presto-cli.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/usr/bin/presto
/usr/lib/presto/bin/presto

1 change: 1 addition & 0 deletions bigtop-packages/src/deb/presto/presto-doc.install
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/usr/share/doc/presto
1 change: 1 addition & 0 deletions bigtop-packages/src/deb/presto/presto-jdbc.install
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/usr/lib/presto/lib/presto-jdbc*.jar
Loading