You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by dk...@apache.org on 2015/05/29 18:04:25 UTC
[2/4] incubator-tinkerpop git commit: process AsciiDoc files in
parallel
process AsciiDoc files in parallel
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/1faaaf3f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/1faaaf3f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/1faaaf3f
Branch: refs/heads/preprocessor
Commit: 1faaaf3ffccc9f57a46a8e53befae421fd55298f
Parents: f3c056f
Author: Daniel Kuppitz <da...@hotmail.com>
Authored: Fri May 29 17:57:17 2015 +0200
Committer: Daniel Kuppitz <da...@hotmail.com>
Committed: Fri May 29 17:57:17 2015 +0200
----------------------------------------------------------------------
docs/preprocessor/preprocess-file.sh | 45 +++++++++++++++++
docs/preprocessor/preprocess.sh | 81 +++++++++++++++----------------
2 files changed, 85 insertions(+), 41 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1faaaf3f/docs/preprocessor/preprocess-file.sh
----------------------------------------------------------------------
diff --git a/docs/preprocessor/preprocess-file.sh b/docs/preprocessor/preprocess-file.sh
new file mode 100755
index 0000000..eb305bf
--- /dev/null
+++ b/docs/preprocessor/preprocess-file.sh
@@ -0,0 +1,45 @@
+#!/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.
+#
+
+TP_HOME=`pwd`
+CONSOLE_HOME=`readlink -f ${TP_HOME}/gremlin-console/target/apache-gremlin-console-*-standalone`
+
+input=$1
+name=`basename ${input}`
+output="${TP_HOME}/target/postprocess-asciidoc/${name}"
+
+echo "${input} > ${output}"
+
+if [ $(grep -c '^\[gremlin' ${input}) -gt 0 ]; then
+ pushd "${CONSOLE_HOME}" > /dev/null
+ bin/gremlin.sh -e ${TP_HOME}/docs/preprocessor/processor.groovy ${input} > ${input}.groovy
+ ec=${PIPESTATUS[0]}
+ if [ ${ec} -eq 0 ]; then
+ HADOOP_GREMLIN_LIBS="${CONSOLE_HOME}/ext/hadoop-gremlin/lib" bin/gremlin.sh ${input}.groovy | awk 'BEGIN {b=1} /\1IGNORE/ {b=!b} !/\1IGNORE/ {if(a&&b)print} /\1START/ {a=1}' | grep -v '^WARN ' | sed 's/^==>\x01//' > ${output}
+ ec=${PIPESTATUS[0]}
+ rm -f ${input}.groovy
+ fi
+ rm -f ${input}.groovy
+ popd > /dev/null
+ exit ${ec}
+else
+ cp ${input} ${output}
+fi
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1faaaf3f/docs/preprocessor/preprocess.sh
----------------------------------------------------------------------
diff --git a/docs/preprocessor/preprocess.sh b/docs/preprocessor/preprocess.sh
index 506f177..76b5aec 100755
--- a/docs/preprocessor/preprocess.sh
+++ b/docs/preprocessor/preprocess.sh
@@ -28,63 +28,62 @@ if [ ! -f bin/gremlin.sh ]; then
fi
mkdir -p target/postprocess-asciidoc
-
rm -rf target/postprocess-asciidoc/*
mkdir target/postprocess-asciidoc/tmp
cp -R docs/{static,stylesheets} target/postprocess-asciidoc/
TP_HOME=`pwd`
CONSOLE_HOME=`readlink -f ${TP_HOME}/gremlin-console/target/apache-gremlin-console-*-standalone`
+PLUGIN_DIR="${CONSOLE_HOME}/ext"
TP_VERSION=$(cat pom.xml | grep -A1 '<artifactId>tinkerpop</artifactId>' | grep -Po '(?<=<version>).*(?=</version>)')
# install Hadoop plugin
hadoopPlugin=$(find . -name "HadoopGremlinPlugin.java")
-hadoopPluginName=`echo $hadoopPlugin | cut -d '/' -f2`
-hadoopPluginClass=`echo $hadoopPlugin | grep -Po '(?<=src/main/java/).*(?=\.java)' | tr '/' '.'`
-match=`grep -c "$hadoopPluginClass" ${CONSOLE_HOME}/ext/plugins.txt`
-if [ ! -z "${hadoopPluginName}" -a ! -d "${CONSOLE_HOME}/ext/${hadoopPluginName}" -a $match -eq 0 ]; then
+hadoopPluginName=`echo ${hadoopPlugin} | cut -d '/' -f2`
+hadoopPluginClass=`echo ${hadoopPlugin} | grep -Po '(?<=src/main/java/).*(?=\.java)' | tr '/' '.'`
+hadoopPluginDirectory="${PLUGIN_DIR}/${hadoopPluginName}"
+match=`grep -c "$hadoopPluginClass" ${PLUGIN_DIR}/plugins.txt`
+
+trap cleanup INT
+
+function cleanup() {
+ # remove Hadoop plugin if it wasn't installed prior pre-processing
+ if [ "${rmHadoopPlugin}" == "1" ]; then
+ rm -rf "${PLUGIN_DIR}/${hadoopPluginName}"
+ sed -e "/${hadoopPluginClass}/d" "${PLUGIN_DIR}/plugins.txt" > "${PLUGIN_DIR}/plugins.txt."
+ mv "${PLUGIN_DIR}/plugins.txt." "${PLUGIN_DIR}/plugins.txt"
+ fi
+ find "${TP_HOME}/docs/src/" -name "*.asciidoc.groovy" | xargs rm -f
+}
+
+if [ ! -z "${hadoopPluginName}" -a ! -d "${hadoopPluginDirectory}" -a ${match} -eq 0 ]; then
rmHadoopPlugin=1
- echo -e "\n${hadoopPluginClass}" >> "${CONSOLE_HOME}/ext/plugins.txt"
- mkdir -p "${CONSOLE_HOME}/ext/${hadoopPluginName}/"{lib,plugin}
- cp ${hadoopPluginName}/target/*${TP_VERSION}.jar "${CONSOLE_HOME}/ext/${hadoopPluginName}/lib"
- cp ${hadoopPluginName}/target/*${TP_VERSION}.jar "${CONSOLE_HOME}/ext/${hadoopPluginName}/plugin"
+ echo -e "\n${hadoopPluginClass}" >> "${PLUGIN_DIR}/plugins.txt"
+ mkdir -p "${PLUGIN_DIR}/${hadoopPluginName}/"{lib,plugin}
+ #cp ${hadoopPluginName}/target/*${TP_VERSION}.jar "${PLUGIN_DIR}/${hadoopPluginName}/lib"
+ cp ${hadoopPluginName}/target/*${TP_VERSION}.jar "${PLUGIN_DIR}/${hadoopPluginName}/plugin"
libdir=`readlink -f ${hadoopPluginName}/target/*-standalone/lib/`
if [ -d "${libdir}" ]; then
- cp ${libdir}/*.jar "${CONSOLE_HOME}/ext/${hadoopPluginName}/lib"
- cp ${libdir}/*.jar "${CONSOLE_HOME}/ext/${hadoopPluginName}/plugin"
+ #cp ${libdir}/*.jar "${PLUGIN_DIR}/${hadoopPluginName}/lib"
+ cp ${libdir}/*.jar "${PLUGIN_DIR}/${hadoopPluginName}/plugin"
fi
- rm -f "${CONSOLE_HOME}/ext/hadoop-gremlin"/*/slf4j-*.jar
+ cp */target/*${TP_VERSION}.jar "${PLUGIN_DIR}/${hadoopPluginName}/lib"
+ for libdir in $(find . -name lib | grep -v ext); do
+ cp ${libdir}/*.jar "${PLUGIN_DIR}/${hadoopPluginName}/lib"
+ done
+ #rm -f "${PLUGIN_DIR}/hadoop-gremlin"/*/slf4j-*.jar
+ rm -f "${PLUGIN_DIR}/hadoop-gremlin"/plugin/slf4j-*.jar
+ echo "System.exit(0)" > "${PLUGIN_DIR}/${hadoopPluginName}/init.groovy"
+ ${CONSOLE_HOME}/bin/gremlin.sh "${PLUGIN_DIR}/${hadoopPluginName}/init.groovy" > /dev/null 2> /dev/null
fi
-for input in $(find "${TP_HOME}/docs/src/" -name "*.asciidoc")
-do
- name=`basename $input`
- output="${TP_HOME}/target/postprocess-asciidoc/${name}"
- echo "${input} > ${output}"
- if [ $(grep -c '^\[gremlin' $input) -gt 0 ]; then
- pushd "${CONSOLE_HOME}" > /dev/null
- bin/gremlin.sh -e ${TP_HOME}/docs/preprocessor/processor.groovy $input > $input.groovy
- ec=${PIPESTATUS[0]}
- if [ $ec -eq 0 ]; then
- HADOOP_GREMLIN_LIBS=`pwd`/ext/hadoop-gremlin/lib bin/gremlin.sh $input.groovy | awk 'BEGIN {b=1} /\1IGNORE/ {b=!b} !/\1IGNORE/ {if(a&&b)print} /\1START/ {a=1}' | grep -v '^WARN ' | sed 's/^==>\x01//' > $output
- ec=${PIPESTATUS[0]}
- rm -f $input.groovy
- popd > /dev/null
- fi
- rm -f $input.groovy
- if [ $ec -ne 0 ]; then
- popd > /dev/null
- exit $ec
- fi
- else
- cp $input $output
- fi
-done
+# copy Gremlin-Hadoop configuration files
+cp ${TP_HOME}/hadoop-gremlin/conf/* "${CONSOLE_HOME}/conf/"
-if [ "{$rmHadoopPlugin}" == "1" ]; then
- rm -rf "${CONSOLE_HOME}/ext/${hadoopPluginName}"
- sed -e "/${hadoopClassName}/d" "${CONSOLE_HOME}/ext/plugins.txt" > "${CONSOLE_HOME}/ext/plugins.txt."
- mv "${CONSOLE_HOME}/ext/plugins.txt." "${CONSOLE_HOME}/ext/plugins.txt"
-fi
+# process *.asciidoc files
+#find "${TP_HOME}/docs/src/" -name "*.asciidoc" | xargs -n1 -P0 "${TP_HOME}/docs/preprocessor/preprocess-file.sh"
+find "${TP_HOME}/docs/src/" -name "implementations.asciidoc" | xargs -n1 -P0 "${TP_HOME}/docs/preprocessor/preprocess-file.sh"
+
+cleanup
popd > /dev/null