Added new exception for Bad Connections.
Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/823b0d83 Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/823b0d83 Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/823b0d83 Branch: refs/heads/0.2.0-newtypesystem Commit: 823b0d8322c194a40dc8badeab413a87109969ef Parents: 5d6feb2 Author: Gagan <[email protected]> Authored: Mon Jul 22 09:57:21 2013 +0530 Committer: Gagan <[email protected]> Committed: Mon Jul 22 09:57:21 2013 +0530 ---------------------------------------------------------------------- .../main/java/org/apache/blur/shell/Main.java | 7 +++- .../blur/thrift/BadConnectionException.java | 43 ++++++++++++++++++++ .../apache/blur/thrift/BlurClientManager.java | 2 +- 3 files changed, 50 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/823b0d83/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 0a6958d..7b53552 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 @@ -39,6 +39,7 @@ import jline.console.completer.StringsCompleter; import org.apache.blur.shell.Command.CommandException; 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.Connection; import org.apache.blur.thrift.generated.Blur; @@ -387,7 +388,9 @@ public class Main { if (debug) { e.printStackTrace(out); } - } finally { + }catch (BadConnectionException e){ + out.println(e.getMessage()); + }finally { if (timed) { out.println("Last command took " + TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start) + "ms"); } @@ -407,6 +410,8 @@ public class Main { } catch (BlurException e) { out.println(e.getMessage()); e.printStackTrace(out); + } catch (BadConnectionException e){ + out.println(e.getMessage()); } out.close(); return; http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/823b0d83/blur-thrift/src/main/java/org/apache/blur/thrift/BadConnectionException.java ---------------------------------------------------------------------- diff --git a/blur-thrift/src/main/java/org/apache/blur/thrift/BadConnectionException.java b/blur-thrift/src/main/java/org/apache/blur/thrift/BadConnectionException.java new file mode 100644 index 0000000..efed55a --- /dev/null +++ b/blur-thrift/src/main/java/org/apache/blur/thrift/BadConnectionException.java @@ -0,0 +1,43 @@ +package org.apache.blur.thrift; + +/** + * 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. + */ + +public class BadConnectionException extends RuntimeException { + + /** + * + */ + private static final long serialVersionUID = 1L; + + public BadConnectionException() { + super(); + } + + public BadConnectionException(String message) { + super(message); + } + + public BadConnectionException(Throwable cause) { + super(cause); + } + + public BadConnectionException(String message, Throwable cause) { + super(message, cause); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/823b0d83/blur-thrift/src/main/java/org/apache/blur/thrift/BlurClientManager.java ---------------------------------------------------------------------- diff --git a/blur-thrift/src/main/java/org/apache/blur/thrift/BlurClientManager.java b/blur-thrift/src/main/java/org/apache/blur/thrift/BlurClientManager.java index 2a25a29..46367c1 100644 --- a/blur-thrift/src/main/java/org/apache/blur/thrift/BlurClientManager.java +++ b/blur-thrift/src/main/java/org/apache/blur/thrift/BlurClientManager.java @@ -196,7 +196,7 @@ public class BlurClientManager { connectionErrorCount++; LOG.error("All connections are bad [" + connectionErrorCount + "]."); if (connectionErrorCount >= maxRetries) { - throw new IOException("All connections are bad."); + throw new BadConnectionException("Could not connect to controller/shard server. All connections are bad."); } try { Thread.sleep(1000);
