You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sentry.apache.org by ja...@apache.org on 2014/06/08 04:54:30 UTC
git commit: SENTRY-207: Sentry script should return non-zero exist
status in error conditions
Repository: incubator-sentry
Updated Branches:
refs/heads/master 5f91a3e58 -> 1e96a028b
SENTRY-207: Sentry script should return non-zero exist status in error conditions
(Sravya Tirukkovalur via Jarek Jarcec Cecho)
Project: http://git-wip-us.apache.org/repos/asf/incubator-sentry/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-sentry/commit/1e96a028
Tree: http://git-wip-us.apache.org/repos/asf/incubator-sentry/tree/1e96a028
Diff: http://git-wip-us.apache.org/repos/asf/incubator-sentry/diff/1e96a028
Branch: refs/heads/master
Commit: 1e96a028b981c0bd7e44f76822a8ff29be65fe00
Parents: 5f91a3e
Author: Jarek Jarcec Cecho <ja...@apache.org>
Authored: Sat Jun 7 19:53:51 2014 -0700
Committer: Jarek Jarcec Cecho <ja...@apache.org>
Committed: Sat Jun 7 19:53:51 2014 -0700
----------------------------------------------------------------------
.../sentry/service/thrift/SentryService.java | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/1e96a028/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/SentryService.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/SentryService.java b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/SentryService.java
index eefcb0a..bbe5542 100644
--- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/SentryService.java
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/SentryService.java
@@ -26,8 +26,10 @@ import java.net.MalformedURLException;
import java.net.ServerSocket;
import java.security.PrivilegedExceptionAction;
import java.util.HashSet;
+import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
import java.util.concurrent.ThreadFactory;
import javax.security.auth.Subject;
@@ -61,7 +63,7 @@ import org.slf4j.LoggerFactory;
import com.google.common.base.Preconditions;
import com.google.common.collect.Sets;
-public class SentryService implements Runnable {
+public class SentryService implements Callable {
private static final Logger LOGGER = LoggerFactory
.getLogger(SentryService.class);
@@ -129,7 +131,7 @@ public class SentryService implements Runnable {
}
@Override
- public void run() {
+ public String call() throws Exception{
LoginContext loginContext = null;
try {
if (kerberos) {
@@ -152,7 +154,8 @@ public class SentryService implements Runnable {
}
} catch (Throwable t) {
LOGGER.error("Error starting server", t);
- } finally {
+ throw t;
+ }finally {
status = Status.NOT_STARTED;
if (loginContext != null) {
try {
@@ -162,6 +165,7 @@ public class SentryService implements Runnable {
}
}
}
+ return null;
}
private void runServer() throws Exception {
@@ -223,13 +227,18 @@ public class SentryService implements Runnable {
&& thriftServer.isServing();
}
- public synchronized void start() {
+ public synchronized void start() throws Exception{
if (status != Status.NOT_STARTED) {
throw new IllegalStateException("Cannot start when " + status);
}
LOGGER.info("Attempting to start...");
status = Status.STARTED;
- serviceExecutor.submit(this);
+ Future future = serviceExecutor.submit(this);
+ try{
+ future.get();
+ }finally{
+ serviceExecutor.shutdown();
+ }
}
public synchronized void stop() {