Fxied BLUR-200 and in the process have changed how the log files are named. Current naming blur-$USER-$PROCESS_TYPE_(main|request|response).log and the blur commands and ZooKeeper processes do not have request or reponse logs.
Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/08f82119 Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/08f82119 Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/08f82119 Branch: refs/heads/master Commit: 08f8211911dec4522c83233e83b8b5ff99b12041 Parents: 4764689 Author: Aaron McCurry <[email protected]> Authored: Sun Aug 11 10:09:31 2013 -0400 Committer: Aaron McCurry <[email protected]> Committed: Sun Aug 11 10:09:31 2013 -0400 ---------------------------------------------------------------------- .../main/java/org/apache/blur/shell/Main.java | 41 +++++++++++++++++++- distribution/src/main/scripts/bin/blur | 8 ++-- .../main/scripts/bin/start-controller-server.sh | 4 +- .../src/main/scripts/bin/start-shard-server.sh | 4 +- .../main/scripts/bin/start-zookeeper-server.sh | 4 +- .../src/main/scripts/conf/log4j-command.xml | 37 ++++++++++++++++++ distribution/src/main/scripts/conf/log4j.xml | 6 +-- 7 files changed, 89 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/08f82119/blur-shell/src/main/java/org/apache/blur/shell/Main.java ---------------------------------------------------------------------- diff --git a/blur-shell/src/main/java/org/apache/blur/shell/Main.java b/blur-shell/src/main/java/org/apache/blur/shell/Main.java index 8d571b3..3206b87 100644 --- a/blur-shell/src/main/java/org/apache/blur/shell/Main.java +++ b/blur-shell/src/main/java/org/apache/blur/shell/Main.java @@ -41,8 +41,11 @@ import org.apache.blur.shell.Main.QuitCommand.QuitCommandException; import org.apache.blur.thirdparty.thrift_0_9_0.TException; import org.apache.blur.thrift.BadConnectionException; import org.apache.blur.thrift.BlurClient; +import org.apache.blur.thrift.BlurClientManager; import org.apache.blur.thrift.Connection; +import org.apache.blur.thrift.commands.BlurCommand; import org.apache.blur.thrift.generated.Blur; +import org.apache.blur.thrift.generated.Blur.Client; import org.apache.blur.thrift.generated.Blur.Iface; import org.apache.blur.thrift.generated.BlurException; import org.apache.blur.thrift.generated.Selector; @@ -362,8 +365,9 @@ public class Main { Blur.Iface client = BlurClient.getClient(cliShellOptions.getControllerConnectionString()); if (cliShellOptions.isShell()) { ConsoleReader reader = new ConsoleReader(); + PrintWriter out = new PrintWriter(reader.getOutput()); setConsoleReader(commands, reader); - reader.setPrompt(PROMPT); + setPrompt(client, reader, cliShellOptions.getControllerConnectionString(), out); List<Completer> completors = new LinkedList<Completer>(); @@ -375,7 +379,6 @@ public class Main { } String line; - PrintWriter out = new PrintWriter(reader.getOutput()); try { while ((line = reader.readLine()) != null) { line = line.trim(); @@ -410,11 +413,15 @@ public class Main { } } catch (BadConnectionException e) { out.println(e.getMessage()); + if (debug) { + e.printStackTrace(out); + } } finally { if (timed) { out.println("Last command took " + TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start) + "ms"); } } + setPrompt(client, reader, cliShellOptions.getControllerConnectionString(), out); } } } finally { @@ -442,6 +449,36 @@ public class Main { } } + private static void setPrompt(Iface client, ConsoleReader reader, String connectionStr, PrintWriter out) throws BlurException, + TException, CommandException, IOException { + List<String> shardClusterList; + try { + shardClusterList = BlurClientManager.execute(connectionStr, new BlurCommand<List<String>>() { + @Override + public List<String> call(Client client) throws BlurException, TException { + return client.shardClusterList(); + } + }, 0, 0, 0); + } catch (BadConnectionException e) { + out.println(e.getMessage() + " Connection (" + connectionStr + ")"); + out.flush(); + if (debug) { + e.printStackTrace(out); + } + System.exit(1); + throw e; //will never be called + } + if (shardClusterList.size() == 1) { + reader.setPrompt("blur (" + getCluster(client) + ")> "); + } else { + if (cluster == null) { + reader.setPrompt(PROMPT); + } else { + reader.setPrompt("blur (" + cluster + ")> "); + } + } + } + private static String[] removeLeadingShellFromScript(String[] args) { if (args.length > 0) { if (args[0].equals("shell")) { http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/08f82119/distribution/src/main/scripts/bin/blur ---------------------------------------------------------------------- diff --git a/distribution/src/main/scripts/bin/blur b/distribution/src/main/scripts/bin/blur index efbe9a3..aa4cd2c 100755 --- a/distribution/src/main/scripts/bin/blur +++ b/distribution/src/main/scripts/bin/blur @@ -21,11 +21,11 @@ bin=`cd "$bin"; pwd` . "$bin"/blur-config.sh PROC_NAME=$1 if [ $# -eq 0 ]; then - "$JAVA_HOME"/bin/java -Dblur.name=$PROC_NAME -Djava.library.path=$JAVA_LIBRARY_PATH $BLUR_COMMAND -Dblur.logs.dir=$BLUR_LOGS -Dblur.log.file=$PROC_NAME.log -cp $BLUR_CLASSPATH org.apache.blur.shell.Main shell help + "$JAVA_HOME"/bin/java -Dblur.name=$PROC_NAME -Djava.library.path=$JAVA_LIBRARY_PATH $BLUR_COMMAND -Dblur.logs.dir=$BLUR_LOGS -Dblur.log.file=blur-$USER-$PROC_NAME -Dlog4j.configuration=file://$BLUR_HOME/conf/log4j-command.xml -cp $BLUR_CLASSPATH org.apache.blur.shell.Main shell help elif [ $1 = "shell" ]; then - "$JAVA_HOME"/bin/java -Dblur.name=$PROC_NAME -Djava.library.path=$JAVA_LIBRARY_PATH $BLUR_COMMAND -Dblur.logs.dir=$BLUR_LOGS -Dblur.log.file=$PROC_NAME.log -cp $BLUR_CLASSPATH org.apache.blur.shell.Main ${@:2} + "$JAVA_HOME"/bin/java -Dblur.name=$PROC_NAME -Djava.library.path=$JAVA_LIBRARY_PATH $BLUR_COMMAND -Dblur.logs.dir=$BLUR_LOGS -Dblur.log.file=blur-$USER-$PROC_NAME -Dlog4j.configuration=file://$BLUR_HOME/conf/log4j-command.xml -cp $BLUR_CLASSPATH org.apache.blur.shell.Main ${@:2} elif [ $1 = "execute" ]; then - "$JAVA_HOME"/bin/java -Dblur.name=$PROC_NAME -Djava.library.path=$JAVA_LIBRARY_PATH $BLUR_COMMAND -Dblur.logs.dir=$BLUR_LOGS -Dblur.log.file=$PROC_NAME.log -cp $BLUR_CLASSPATH ${@:2} + "$JAVA_HOME"/bin/java -Dblur.name=$PROC_NAME -Djava.library.path=$JAVA_LIBRARY_PATH $BLUR_COMMAND -Dblur.logs.dir=$BLUR_LOGS -Dblur.log.file=blur-$USER-$PROC_NAME -Dlog4j.configuration=file://$BLUR_HOME/conf/log4j-command.xml -cp $BLUR_CLASSPATH ${@:2} else - "$JAVA_HOME"/bin/java -Dblur.name=$PROC_NAME -Djava.library.path=$JAVA_LIBRARY_PATH $BLUR_COMMAND -Dblur.logs.dir=$BLUR_LOGS -Dblur.log.file=$PROC_NAME.log -cp $BLUR_CLASSPATH org.apache.blur.shell.Main shell ${@:1} + "$JAVA_HOME"/bin/java -Dblur.name=$PROC_NAME -Djava.library.path=$JAVA_LIBRARY_PATH $BLUR_COMMAND -Dblur.logs.dir=$BLUR_LOGS -Dblur.log.file=blur-$USER-$PROC_NAME -Dlog4j.configuration=file://$BLUR_HOME/conf/log4j-command.xml -cp $BLUR_CLASSPATH org.apache.blur.shell.Main shell ${@:1} fi http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/08f82119/distribution/src/main/scripts/bin/start-controller-server.sh ---------------------------------------------------------------------- diff --git a/distribution/src/main/scripts/bin/start-controller-server.sh b/distribution/src/main/scripts/bin/start-controller-server.sh index 750152b..e484a77 100755 --- a/distribution/src/main/scripts/bin/start-controller-server.sh +++ b/distribution/src/main/scripts/bin/start-controller-server.sh @@ -32,8 +32,8 @@ while [ $INSTANCE -lt $BLUR_NUMBER_OF_CONTROLLER_SERVER_INSTANCES_PER_MACHINE ] fi fi - PROC_NAME=blur-controller-server-$HOSTNAME-$INSTANCE - nohup "$JAVA_HOME"/bin/java -Dblur.name=$PROC_NAME -Djava.library.path=$JAVA_LIBRARY_PATH -Dblur-controller-$INSTANCE $BLUR_CONTROLLER_JVM_OPTIONS -Dblur.logs.dir=$BLUR_LOGS -Dblur.log.file=$PROC_NAME.log -cp $BLUR_CLASSPATH org.apache.blur.thrift.ThriftBlurControllerServer -s $INSTANCE > "$BLUR_LOGS/$PROC_NAME.out" 2>&1 < /dev/null & + PROC_NAME=controller-server-$HOSTNAME-$INSTANCE + nohup "$JAVA_HOME"/bin/java -Dblur.name=$PROC_NAME -Djava.library.path=$JAVA_LIBRARY_PATH -Dblur-controller-$INSTANCE $BLUR_CONTROLLER_JVM_OPTIONS -Dblur.logs.dir=$BLUR_LOGS -Dblur.log.file=blur-$USER-$PROC_NAME -cp $BLUR_CLASSPATH org.apache.blur.thrift.ThriftBlurControllerServer -s $INSTANCE > "$BLUR_LOGS/blur-$USER-$PROC_NAME.out" 2>&1 < /dev/null & echo $! > $PID_FILE echo Controller [$INSTANCE] starting as process `cat $PID_FILE`. http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/08f82119/distribution/src/main/scripts/bin/start-shard-server.sh ---------------------------------------------------------------------- diff --git a/distribution/src/main/scripts/bin/start-shard-server.sh b/distribution/src/main/scripts/bin/start-shard-server.sh index 99a4611..d72f842 100755 --- a/distribution/src/main/scripts/bin/start-shard-server.sh +++ b/distribution/src/main/scripts/bin/start-shard-server.sh @@ -32,8 +32,8 @@ while [ $INSTANCE -lt $BLUR_NUMBER_OF_SHARD_SERVER_INSTANCES_PER_MACHINE ]; do fi fi - PROC_NAME=blur-shard-server-$HOSTNAME-$INSTANCE - nohup "$JAVA_HOME"/bin/java -Dblur.name=$PROC_NAME -Djava.library.path=$JAVA_LIBRARY_PATH -Dblur-shard-$INSTANCE $BLUR_SHARD_JVM_OPTIONS -Dblur.logs.dir=$BLUR_LOGS -Dblur.log.file=$PROC_NAME.log -cp $BLUR_CLASSPATH org.apache.blur.thrift.ThriftBlurShardServer -s $INSTANCE > "$BLUR_LOGS/$PROC_NAME.out" 2>&1 < /dev/null & + PROC_NAME=shard-server-$HOSTNAME-$INSTANCE + nohup "$JAVA_HOME"/bin/java -Dblur.name=$PROC_NAME -Djava.library.path=$JAVA_LIBRARY_PATH -Dblur-shard-$INSTANCE $BLUR_SHARD_JVM_OPTIONS -Dblur.logs.dir=$BLUR_LOGS -Dblur.log.file=blur-$USER-$PROC_NAME -cp $BLUR_CLASSPATH org.apache.blur.thrift.ThriftBlurShardServer -s $INSTANCE > "$BLUR_LOGS/blur-$USER-$PROC_NAME.out" 2>&1 < /dev/null & echo $! > $PID_FILE echo Shard [$INSTANCE] starting as process `cat $PID_FILE`. http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/08f82119/distribution/src/main/scripts/bin/start-zookeeper-server.sh ---------------------------------------------------------------------- diff --git a/distribution/src/main/scripts/bin/start-zookeeper-server.sh b/distribution/src/main/scripts/bin/start-zookeeper-server.sh index 2347cc8..becee2f 100755 --- a/distribution/src/main/scripts/bin/start-zookeeper-server.sh +++ b/distribution/src/main/scripts/bin/start-zookeeper-server.sh @@ -30,8 +30,8 @@ if [ $BLUR_MANAGE_ZK = true ]; then fi fi - PROC_NAME=blur-zk-$HOSTNAME - nohup "$JAVA_HOME"/bin/java -Dblur.name=$PROC_NAME -Djava.library.path=$JAVA_LIBRARY_PATH -Dblur-zk $BLUR_ZK_JVM_OPTIONS -Dblur.logs.dir=$BLUR_LOGS -Dblur.log.file=$PROC_NAME.log -cp $BLUR_CLASSPATH org.apache.zookeeper.server.quorum.QuorumPeerMain $BLUR_HOME/conf/default_zoo.cfg > "$BLUR_LOGS/$PROC_NAME.out" 2>&1 < /dev/null & + PROC_NAME=zk-$HOSTNAME + nohup "$JAVA_HOME"/bin/java -Dblur.name=$PROC_NAME -Djava.library.path=$JAVA_LIBRARY_PATH -Dblur-zk $BLUR_ZK_JVM_OPTIONS -Dblur.logs.dir=$BLUR_LOGS -Dblur.log.file=blur-$USER-$PROC_NAME -Dlog4j.configuration=file://$BLUR_HOME/conf/log4j-command.xml -cp $BLUR_CLASSPATH org.apache.zookeeper.server.quorum.QuorumPeerMain $BLUR_HOME/conf/default_zoo.cfg > "$BLUR_LOGS/blur-$USER-$PROC_NAME.out" 2>&1 < /dev/null & echo $! > $PID_FILE echo ZooKeeper starting as process `cat $PID_FILE`. else http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/08f82119/distribution/src/main/scripts/conf/log4j-command.xml ---------------------------------------------------------------------- diff --git a/distribution/src/main/scripts/conf/log4j-command.xml b/distribution/src/main/scripts/conf/log4j-command.xml new file mode 100644 index 0000000..8641734 --- /dev/null +++ b/distribution/src/main/scripts/conf/log4j-command.xml @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!-- +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. +--> +<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> + +<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> + + <appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender"> + <param name="File" value="${blur.logs.dir}/${blur.log.file}.log" /> + <param name="DatePattern" value="'.'yyyyMMdd" /> + <param name="Append" value="true" /> + <layout class="org.apache.log4j.PatternLayout"> + <param name="ConversionPattern" value="%-5p %d{yyyyMMdd_HH:mm:ss:SSS_z} [%t] %c{2}: %m%n" /> + </layout> + </appender> + + <root> + <priority value="INFO" /> + <appender-ref ref="FILE" /> + </root> +</log4j:configuration> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/08f82119/distribution/src/main/scripts/conf/log4j.xml ---------------------------------------------------------------------- diff --git a/distribution/src/main/scripts/conf/log4j.xml b/distribution/src/main/scripts/conf/log4j.xml index 787fc13..102ea5e 100644 --- a/distribution/src/main/scripts/conf/log4j.xml +++ b/distribution/src/main/scripts/conf/log4j.xml @@ -32,7 +32,7 @@ under the License. </appender> <appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender"> - <param name="File" value="${blur.logs.dir}/${blur.log.file}" /> + <param name="File" value="${blur.logs.dir}/${blur.log.file}_main.log" /> <param name="DatePattern" value="'.'yyyyMMdd" /> <param name="Append" value="true" /> <layout class="org.apache.log4j.PatternLayout"> @@ -45,7 +45,7 @@ under the License. </appender> <appender name="REQUEST_LOG_FILE" class="org.apache.log4j.DailyRollingFileAppender"> - <param name="File" value="${blur.logs.dir}/request_${blur.name}.log" /> + <param name="File" value="${blur.logs.dir}/${blur.log.file}_request.log" /> <param name="DatePattern" value="'.'yyyyMMdd" /> <param name="Append" value="true" /> <layout class="org.apache.log4j.PatternLayout"> @@ -58,7 +58,7 @@ under the License. </appender> <appender name="RESPONSE_LOG_FILE" class="org.apache.log4j.DailyRollingFileAppender"> - <param name="File" value="${blur.logs.dir}/response_${blur.name}.log" /> + <param name="File" value="${blur.logs.dir}/${blur.log.file}_response.log" /> <param name="DatePattern" value="'.'yyyyMMdd" /> <param name="Append" value="true" /> <layout class="org.apache.log4j.PatternLayout">
