GEODE-2601: Fixing banner being logged twice during locator startup (now only 
logs once if both locator and distributed systems are started)


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/6c330bfa
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/6c330bfa
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/6c330bfa

Branch: refs/heads/feature/GEODE-2804
Commit: 6c330bfaae64b531da163c28715ad1230371fea9
Parents: ebf9b02
Author: YehEmily <emilyyeh1...@gmail.com>
Authored: Thu Jun 8 14:40:39 2017 -0700
Committer: Hitesh Khamesra <hkhame...@pivotal.io>
Committed: Mon Jun 19 13:47:59 2017 -0700

----------------------------------------------------------------------
 .../internal/InternalDistributedSystem.java     | 32 +++++++++-----------
 .../distributed/internal/InternalLocator.java   |  3 +-
 .../internal/logging/LogWriterFactory.java      | 16 +++++-----
 3 files changed, 23 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/6c330bfa/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
 
b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
index 85f9146..d77e8b9 100644
--- 
a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
+++ 
b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
@@ -1797,7 +1797,7 @@ public class InternalDistributedSystem extends 
DistributedSystem
   @Override
   public Statistics[] getStatistics() {
     List<Statistics> statsList = this.statsList;
-    return (Statistics[]) statsList.toArray(new Statistics[0]);
+    return statsList.toArray(new Statistics[0]);
   }
 
   // StatisticsFactory methods
@@ -1829,7 +1829,7 @@ public class InternalDistributedSystem extends 
DistributedSystem
   }
 
   public FunctionStats getFunctionStats(String textId) {
-    FunctionStats stats = (FunctionStats) 
functionExecutionStatsMap.get(textId);
+    FunctionStats stats = functionExecutionStatsMap.get(textId);
     if (stats == null) {
       stats = new FunctionStats(this, textId);
       FunctionStats oldStats = functionExecutionStatsMap.putIfAbsent(textId, 
stats);
@@ -1870,7 +1870,7 @@ public class InternalDistributedSystem extends 
DistributedSystem
    */
   public interface StatisticsVisitor {
 
-    public void visit(Statistics stat);
+    void visit(Statistics stat);
   }
 
   public Set<String> getAllFunctionExecutionIds() {
@@ -2167,7 +2167,7 @@ public class InternalDistributedSystem extends 
DistributedSystem
   private void notifyResourceEventListeners(ResourceEvent event, Object 
resource) {
     for (Iterator<ResourceEventsListener> iter = resourceListeners.iterator(); 
iter.hasNext();) {
       try {
-        ResourceEventsListener listener = (ResourceEventsListener) iter.next();
+        ResourceEventsListener listener = iter.next();
         listener.handleEvent(event, resource);
       } catch (CancelException e) {
         // ignore
@@ -2302,7 +2302,7 @@ public class InternalDistributedSystem extends 
DistributedSystem
               boolean isDurableClient = false;
 
               if (dca != null) {
-                isDurableClient = ((dca.getId() == null || 
dca.getId().isEmpty()) ? false : true);
+                isDurableClient = (!(dca.getId() == null || 
dca.getId().isEmpty()));
               }
 
               ((InternalDistributedSystem) ds).disconnect(false,
@@ -2337,7 +2337,7 @@ public class InternalDistributedSystem extends 
DistributedSystem
      * 
      * @param sys the the system we are disconnecting from process should take 
before returning.
      */
-    public void onDisconnect(InternalDistributedSystem sys);
+    void onDisconnect(InternalDistributedSystem sys);
 
   }
 
@@ -2352,7 +2352,7 @@ public class InternalDistributedSystem extends 
DistributedSystem
      * @param oldSystem the old DS, which is in a partially disconnected state 
and cannot be used
      *        for messaging
      */
-    public void reconnecting(InternalDistributedSystem oldSystem);
+    void reconnecting(InternalDistributedSystem oldSystem);
 
     /**
      * Invoked after a reconnect to the distributed system
@@ -2360,8 +2360,7 @@ public class InternalDistributedSystem extends 
DistributedSystem
      * @param oldSystem the old DS
      * @param newSystem the new DS
      */
-    public void onReconnect(InternalDistributedSystem oldSystem,
-        InternalDistributedSystem newSystem);
+    void onReconnect(InternalDistributedSystem oldSystem, 
InternalDistributedSystem newSystem);
   }
 
   /**
@@ -2374,7 +2373,7 @@ public class InternalDistributedSystem extends 
DistributedSystem
      * 
      * @param sys
      */
-    public void onShutdown(InternalDistributedSystem sys);
+    void onShutdown(InternalDistributedSystem sys);
   }
 
   /**
@@ -2427,10 +2426,7 @@ public class InternalDistributedSystem extends 
DistributedSystem
       return false;
     }
     boolean newDsConnected = (rds == null || !rds.isConnected());
-    if (!newDsConnected) {
-      return false;
-    }
-    return true;
+    return newDsConnected;
   }
 
 
@@ -2754,7 +2750,7 @@ public class InternalDistributedSystem extends 
DistributedSystem
         if (newDM instanceof DistributionManager) {
           // Admin systems don't carry a cache, but for others we can now 
create
           // a cache
-          if (((DistributionManager) newDM).getDMType() != 
DistributionManager.ADMIN_ONLY_DM_TYPE) {
+          if (newDM.getDMType() != DistributionManager.ADMIN_ONLY_DM_TYPE) {
             try {
               CacheConfig config = new CacheConfig();
               if (cacheXML != null) {
@@ -2962,7 +2958,7 @@ public class InternalDistributedSystem extends 
DistributedSystem
     /**
      * Invoked after a connection to the distributed system is created
      */
-    public void onConnect(InternalDistributedSystem sys);
+    void onConnect(InternalDistributedSystem sys);
   }
 
   public String forceStop() {
@@ -3064,8 +3060,8 @@ public class InternalDistributedSystem extends 
DistributedSystem
    * Privacy Violations that Fortify will complain about.
    * </p>
    */
-  public static interface CreationStackGenerator {
+  public interface CreationStackGenerator {
 
-    public Throwable generateCreationStack(final DistributionConfig config);
+    Throwable generateCreationStack(final DistributionConfig config);
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/6c330bfa/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java
 
b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java
index c299dd0..ae548c4 100644
--- 
a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java
+++ 
b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java
@@ -478,9 +478,8 @@ public class InternalLocator extends Locator implements 
ConnectListener {
     if (logWriter == null) {
       logWriter = LogWriterFactory.createLogWriterLogger(false, false, 
this.config,
           !startDistributedSystem);
-      if (logger.isDebugEnabled()) {
+      if (logger.isDebugEnabled())
         logger.debug("LogWriter for locator is created.");
-      }
     }
 
     if (securityLogWriter == null) {

http://git-wip-us.apache.org/repos/asf/geode/blob/6c330bfa/geode-core/src/main/java/org/apache/geode/internal/logging/LogWriterFactory.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/logging/LogWriterFactory.java
 
b/geode-core/src/main/java/org/apache/geode/internal/logging/LogWriterFactory.java
index 999bca9..c4fecfd 100755
--- 
a/geode-core/src/main/java/org/apache/geode/internal/logging/LogWriterFactory.java
+++ 
b/geode-core/src/main/java/org/apache/geode/internal/logging/LogWriterFactory.java
@@ -87,19 +87,19 @@ public class LogWriterFactory {
         // LOG:CONFIG:
         logger.info(LogMarker.CONFIG, Banner.getString(null));
       }
+      System.setProperty(InternalLocator.INHIBIT_DM_BANNER, "true"); // Ensure 
no more banners will
+                                                                     // be 
logged
     } else {
       logger.debug("skipping banner - " + InternalLocator.INHIBIT_DM_BANNER + 
" is set to true");
     }
 
     // log the config
-    if (logConfig) {
-      if (!isLoner) {
-        // LOG:CONFIG: changed from config to info
-        logger.info(LogMarker.CONFIG,
-            LocalizedMessage.create(
-                
LocalizedStrings.InternalDistributedSystem_STARTUP_CONFIGURATIONN_0,
-                config.toLoggerString()));
-      }
+    if (logConfig && !isLoner) {
+      // LOG:CONFIG: changed from config to info
+      logger.info(LogMarker.CONFIG,
+          LocalizedMessage.create(
+              
LocalizedStrings.InternalDistributedSystem_STARTUP_CONFIGURATIONN_0,
+              config.toLoggerString()));
     }
 
     return logger;

Reply via email to