forked from VoltDB/voltdb
/
exporttofile
executable file
·123 lines (104 loc) · 4.02 KB
/
exporttofile
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
#!/usr/bin/env bash
# This file is part of VoltDB.
# Copyright (C) 2008-2011 VoltDB Inc.
#
# This file contains original code and/or modifications of original code.
# Any modifications made by VoltDB Inc. are licensed under the following
# terms and conditions:
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
# Original license for parts of this script copied from or influenced by
# the Hadoop startup script:
#
# 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.
# The VoltDB Export-To-File command script
#
# Environment Variables
# JAVA_HOME The java implementation to use. Overrides JAVA_HOME.
# JAVA_HEAP_MAX The maximum amount of heap to use, in MB. Default is 1024.
# VOLTDB_OPTS Extra Java runtime options.
# LOG4J_CONFIG_PATH Path to alternate log4j configuration
bin=`dirname "$0"`
bin=`cd "$bin"; pwd`
# resolve links - $0 may be a softlink
this="$0"
while [ -h "$this" ]; do
ls=`ls -ld "$this"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '.*/.*' > /dev/null; then
this="$link"
else
this=`dirname "$this"`/"$link"
fi
done
# convert relative path to absolute path
bin=`dirname "$this"`
script=`basename "$this"`
bin=`cd "$bin"; pwd`
this="$bin/$script"
# the root of the VoltDB installation
export VOLTDB_HOME=`dirname "$this"`/..
JAVA=`which java`
JAVA_HEAP_MAX=-Xmx512m
# some Java parameters
if [ "$JAVA_HOME" != "" ]; then
#echo "run java in $JAVA_HOME"
JAVA=$JAVA_HOME/bin/java
fi
# check envvars to see if a user overrides log4j conf
if [ -z "${LOG4J_CONFIG_PATH}" ]; then
if [ -f "$VOLTDB_HOME/src/frontend/log4j.xml" ]; then
LOG4J_CONFIG_PATH=$VOLTDB_HOME/src/frontend/log4j.xml
elif [ -f "$VOLTDB_HOME/voltdb/log4j.xml" ]; then
LOG4J_CONFIG_PATH=$VOLTDB_HOME/voltdb/log4j.xml
else
echo "Couldn't find log4j configuration file."
exit 1
fi
fi
VOLTDBJAR=`ls $VOLTDB_HOME/voltdb/voltdb-2.*.jar`
if [ -n "${VOLTDBJAR}" ]; then
CLASSPATH=$VOLTDBJAR
else
echo "Couldn't find compiled VoltDB jar to run."
exit 1
fi
# add libs to CLASSPATH
for f in $VOLTDB_HOME/lib/*.jar; do
CLASSPATH=${CLASSPATH}:$f;
done
CLASSPATH=${CLASSPATH}:${EXTRA_CLASSPATH}
# run it
export CMDVAL="$JAVA $JAVA_HEAP_MAX $VOLTDB_OPTS -Dlog4j.configuration=file://${LOG4J_CONFIG_PATH} "
export CMDVAL=$CMDVAL"-classpath $CLASSPATH org.voltdb.exportclient.ExportToFileClient $@"
#echo $CMDVAL
exec $CMDVAL