You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by mr...@apache.org on 2016/06/15 16:25:07 UTC
[14/50] [abbrv] usergrid git commit: Revert "Service manager's init()
method now retries if unable to get application."
Revert "Service manager's init() method now retries if unable to get application."
This reverts commit 223521e4150e520c92560bbea873b6a024e18a0e.
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/0970e1df
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/0970e1df
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/0970e1df
Branch: refs/heads/master
Commit: 0970e1dfa1b7f54204b6ad82e4bf01da84b38618
Parents: b03f6a9
Author: Dave Johnson <sn...@apache.org>
Authored: Tue May 24 14:36:44 2016 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Tue May 24 14:36:44 2016 -0400
----------------------------------------------------------------------
.../main/resources/usergrid-default.properties | 5 --
.../usergrid/services/ServiceManager.java | 52 +++-----------------
2 files changed, 8 insertions(+), 49 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/0970e1df/stack/config/src/main/resources/usergrid-default.properties
----------------------------------------------------------------------
diff --git a/stack/config/src/main/resources/usergrid-default.properties b/stack/config/src/main/resources/usergrid-default.properties
index 35e12ae..4f57cdd 100644
--- a/stack/config/src/main/resources/usergrid-default.properties
+++ b/stack/config/src/main/resources/usergrid-default.properties
@@ -628,11 +628,6 @@ usergrid.auth.cache.inmemory.size=3000
# all (= in + out)'
usergrid.rest.default-connection-param=all
-# In a busy cluster the Service Manager's init() may fail (usually a time-out) on the first
-# attempt to communicate with Cassandra or ElasticSearch so we retry on failure, using an
-# interval that is longer than the default (10s) Cassandra connection time-out.
-service.manager.retry.interval=15000
-service.manager.max.retries=5
############################## Usergrid Testing #############################
http://git-wip-us.apache.org/repos/asf/usergrid/blob/0970e1df/stack/services/src/main/java/org/apache/usergrid/services/ServiceManager.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/ServiceManager.java b/stack/services/src/main/java/org/apache/usergrid/services/ServiceManager.java
index 1ed73d6..a9892f5 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/ServiceManager.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/ServiceManager.java
@@ -50,6 +50,7 @@ import static org.apache.usergrid.utils.InflectionUtils.pluralize;
public class ServiceManager {
+
private static final Logger logger = LoggerFactory.getLogger( ServiceManager.class );
/** A pointer that signals we couldn't find a class */
@@ -68,10 +69,6 @@ public class ServiceManager {
public static final String APPLICATION_REQUESTS_PER = APPLICATION_REQUESTS + ".";
public static final String IMPL = "Impl";
- public static final String SERVICE_MANAGER_RETRY_INTERVAL = "service.manager.retry.interval";
-
- public static final String SERVICE_MANAGER_MAX_RETRIES= "service.manager.max.retries";
-
private Application application;
private UUID applicationId;
@@ -99,60 +96,27 @@ public class ServiceManager {
this.qm = qm;
this.properties = properties;
- Integer retryInterval;
- try {
- Object retryIntervalObject = properties.get( SERVICE_MANAGER_RETRY_INTERVAL ).toString();
- retryInterval = Integer.parseInt( retryIntervalObject.toString() );
- } catch ( NumberFormatException nfe ) {
- retryInterval = 15000;
- }
-
- Integer maxRetries;
- try {
- Object maxRetriesObject = properties.get( SERVICE_MANAGER_MAX_RETRIES ).toString();
- maxRetries = Integer.parseInt( maxRetriesObject.toString() );
- } catch ( NumberFormatException nfe ) {
- maxRetries = 5;
- }
-
if ( em != null ) {
-
try {
- int retryCount = 0;
- boolean appNotFound = true;
-
- while ( appNotFound && retryCount <= maxRetries ) {
-
- application = em.getApplication();
-
- if ( application != null ) {
- appNotFound = false;
- applicationId = application.getUuid();
- } else {
- Thread.sleep( retryInterval );
- retryCount++;
- }
- }
-
- if ( application == null ) {
- Exception e = new RuntimeException( "application id {" + em.getApplicationId() + "} is returning null" );
- logger.error( "Failed to get application", e );
+ application = em.getApplication();
+ if(application == null){
+ Exception e = new RuntimeException("application id {"+em.getApplicationId()+"} is returning null");
+ logger.error("Failed to get application",e);
throw e;
}
-
- } catch ( Exception e ) {
+ applicationId = application.getUuid();
+ }
+ catch ( Exception e ) {
logger.error( "ServiceManager init failure", e );
throw new RuntimeException( e );
}
}
-
if ( properties != null ) {
String packages = properties.getProperty( SERVICE_PACKAGE_PREFIXES );
if ( !StringUtils.isEmpty( packages ) ) {
setServicePackagePrefixes( packages );
}
}
-
return this;
}