geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bschucha...@apache.org
Subject incubator-geode git commit: GEODE-956 Product use log shows duplicate entries
Date Mon, 21 Mar 2016 16:22:25 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/develop 8645fe038 -> 68dab4af5


GEODE-956 Product use log shows duplicate entries

The product use logger was adding up the load of all of the servers and
displaying it, but each load is a float between zero and 1.0 so the total
was always zero.  I've modified it to figure out the correct connection
count for each CacheServer and also log the subscription queue count.

The list of servers now has duplicate entries removed by putting all of
the servers into a Set.


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

Branch: refs/heads/develop
Commit: 68dab4af591ba631234d156a84b5306ea39fe22f
Parents: 8645fe0
Author: Bruce Schuchardt <bschuchardt@pivotal.io>
Authored: Mon Mar 21 09:17:02 2016 -0700
Committer: Bruce Schuchardt <bschuchardt@pivotal.io>
Committed: Mon Mar 21 09:22:09 2016 -0700

----------------------------------------------------------------------
 .../internal/AutoConnectionSourceImpl.java      | 10 +--
 .../internal/locator/LocatorListResponse.java   |  8 ++-
 .../internal/InternalDistributedSystem.java     |  6 ++
 .../distributed/internal/ServerLocator.java     | 70 ++++++++++++--------
 .../internal/ProductUseLogDUnitTest.java        | 50 +++++++++++---
 .../management/ClientHealthStatsDUnitTest.java  |  2 +-
 .../sanctionedDataSerializables.txt             |  2 +-
 7 files changed, 98 insertions(+), 50 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/68dab4af/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/AutoConnectionSourceImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/AutoConnectionSourceImpl.java
b/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/AutoConnectionSourceImpl.java
index 6fe1c6b..dfc9b14 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/AutoConnectionSourceImpl.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/AutoConnectionSourceImpl.java
@@ -174,16 +174,10 @@ public class AutoConnectionSourceImpl implements ConnectionSource {
     QueueConnectionRequest request  = new QueueConnectionRequest(proxyId,numServers,excludedServers,
serverGroup,findDurableQueue);
     QueueConnectionResponse response = (QueueConnectionResponse) queryLocators(request);
     if (response==null) {
-      // why log a warning if we are going to throw the caller and exception?
-      //getLogger().warning("Unable to connect to any locators in the list " + locators);
       throw new NoAvailableLocatorsException("Unable to connect to any locators in the list
" + locators);
     }
     //TODO - do this logic on the server side, return one list in the message.
     List result = response.getServers();
-//    if(getLogger().fineEnabled()) {
-//      getLogger().fine("Received queue connection response with server " + result+" excludeList:"+excludedServers);
-//    }
-    
     return result;
   }
   
@@ -242,9 +236,9 @@ public class AutoConnectionSourceImpl implements ConnectionSource {
   protected void updateLocatorList(LocatorListResponse response) {
     if (response == null) return;
     isBalanced = response.isBalanced();
-    ArrayList<ServerLocation> locatorResponse = response.getLocators();
+    List<ServerLocation> locatorResponse = response.getLocators();
 
-    ArrayList<InetSocketAddress> newLocators  = new ArrayList<InetSocketAddress>(locatorResponse.size());
+    List<InetSocketAddress> newLocators  = new ArrayList<InetSocketAddress>(locatorResponse.size());
 
     Set<InetSocketAddress> badLocators  = new HashSet<InetSocketAddress>(initialLocators);
     for(Iterator<ServerLocation> itr = locatorResponse.iterator(); itr.hasNext(); )
{

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/68dab4af/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/locator/LocatorListResponse.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/locator/LocatorListResponse.java
b/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/locator/LocatorListResponse.java
index a9ab821..f1261d9 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/locator/LocatorListResponse.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/locator/LocatorListResponse.java
@@ -20,7 +20,9 @@ import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.List;
 
+import com.gemstone.gemfire.distributed.internal.ServerLocation;
 import com.gemstone.gemfire.internal.DataSerializableFixedID;
 
 /**
@@ -29,7 +31,7 @@ import com.gemstone.gemfire.internal.DataSerializableFixedID;
  */
 public class LocatorListResponse extends ServerLocationResponse {
   /** ArrayList of ServerLocations for controllers */
-  private ArrayList controllers;
+  private List<ServerLocation> controllers;
   private boolean isBalanced;
   private boolean locatorsFound = false;
 
@@ -37,7 +39,7 @@ public class LocatorListResponse extends ServerLocationResponse {
   public LocatorListResponse() {
   }
   
-  public LocatorListResponse(ArrayList locators, boolean isBalanced) {
+  public LocatorListResponse(List<ServerLocation> locators, boolean isBalanced) {
     this.controllers = locators;
     if (locators != null && !locators.isEmpty()) {
       this.locatorsFound = true;
@@ -62,7 +64,7 @@ public class LocatorListResponse extends ServerLocationResponse {
    * Returns an array list of type ServerLocation containing controllers.
    * @return list of controllers
    */
-  public ArrayList getLocators() {
+  public List<ServerLocation> getLocators() {
     return this.controllers;
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/68dab4af/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/InternalDistributedSystem.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/InternalDistributedSystem.java
b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/InternalDistributedSystem.java
index 8fc884a..62755ca 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/InternalDistributedSystem.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/InternalDistributedSystem.java
@@ -947,6 +947,12 @@ public class InternalDistributedSystem
       this.forcedDisconnect = true;
       resetReconnectAttemptCounter();
       if (sampler.isSamplingEnabled()) {
+        try {
+          // give the stat sampler time to take another sample
+          Thread.sleep(this.config.getStatisticSampleRate() * 2);
+        } catch (InterruptedException e) {
+          Thread.currentThread().interrupt();
+        }
         if (sampler.getStatSamplerStats().getJvmPauses() > 0) {
           try {
             // if running tests then create a heap dump

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/68dab4af/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/ServerLocator.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/ServerLocator.java
b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/ServerLocator.java
index 644bf63..965c1e7 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/ServerLocator.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/ServerLocator.java
@@ -79,10 +79,12 @@ public class ServerLocator implements TcpHandler, DistributionAdvisee
{
   private final LocatorStats stats;
   private LocatorLoadSnapshot loadSnapshot = new LocatorLoadSnapshot();
   private Map<ServerLocation, DistributedMember> ownerMap = new HashMap<ServerLocation,
DistributedMember>();
-  private volatile ArrayList cachedLocators;
+  private volatile List<ServerLocation> cachedLocators;
   private final Object cachedLocatorsLock = new Object();
   
   private final static AtomicInteger profileSN = new AtomicInteger();
+
+  private static final long SERVER_LOAD_LOG_INTERVAL = (60 * 60 * 1000); // log server load
once an hour
   
   private final String logFile;
   private final String hostName;
@@ -90,6 +92,8 @@ public class ServerLocator implements TcpHandler, DistributionAdvisee {
   
   private ProductUseLog productUseLog;
 
+  private volatile long lastLogTime;
+
   ServerLocator() throws IOException {
     this.port = 10334;
     this.hostName = SocketCreator.getLocalHost().getCanonicalHostName();
@@ -232,7 +236,7 @@ public class ServerLocator implements TcpHandler, DistributionAdvisee
{
   }
   
   private Object getLocatorListResponse(LocatorListRequest request) {
-    ArrayList controllers = getLocators();
+    List<ServerLocation> controllers = getLocators();
     boolean balanced = loadSnapshot.hasBalancedConnections(request.getServerGroup());
     return new LocatorListResponse(controllers, balanced);
   }
@@ -358,16 +362,16 @@ public class ServerLocator implements TcpHandler, DistributionAdvisee
{
   
 
   
-  private ArrayList getLocators() {
+  private List<ServerLocation> getLocators() {
     if(cachedLocators != null) {
       return cachedLocators;
     }
     else {
       synchronized(cachedLocatorsLock) {
-        List profiles = advisor.fetchControllers();
-        ArrayList result = new ArrayList(profiles.size() + 1);
-        for (Iterator itr = profiles.iterator(); itr.hasNext(); ) {
-          result.add(buildServerLocation((ControllerProfile) itr.next()));
+        List<ControllerProfile> profiles = advisor.fetchControllers();
+        List<ServerLocation> result = new ArrayList<>(profiles.size() + 1);
+        for (ControllerProfile profile: profiles) {
+          result.add(buildServerLocation(profile));
         }
         result.add(new ServerLocation(hostNameForClients,port));
         cachedLocators = result;
@@ -400,7 +404,6 @@ public class ServerLocator implements TcpHandler, DistributionAdvisee
{
     } else {
       cachedLocators = null;
     }
-    logServers();
   }
 
   /**
@@ -434,38 +437,53 @@ public class ServerLocator implements TcpHandler, DistributionAdvisee
{
     }
     loadSnapshot.updateLoad(location, load, clientIds);
     this.stats.incServerLoadUpdates();
+    logServers();
   }
 
   private void logServers() {
     if (productUseLog != null) {
-      StringBuilder sb = new StringBuilder(1000);
       Map<ServerLocation, ServerLoad> loadMap = getLoadMap();
       if (loadMap.size() == 0) {
         return;
       }
       
+      long now = System.currentTimeMillis();
+      long lastLogTime = this.lastLogTime;
+      if (now < lastLogTime + SERVER_LOAD_LOG_INTERVAL) {
+        return;
+      }
+      this.lastLogTime = now;
+      
+      int queues = 0;
       int connections = 0;
       for (ServerLoad l: loadMap.values()) {
-        connections += l.getConnectionLoad();
+        queues += l.getSubscriptionConnectionLoad();
+        connections = (int)Math.ceil(l.getConnectionLoad() / l.getLoadPerConnection());
       }
-      sb.append("server summary: ")
-        .append(loadMap.size())
-        .append(" cache servers with ")
-        .append(connections)
-        .append(" client connections")
-        .append(File.separator)
-      .append("current cache servers : ");
       
+      Set<DistributedMember> servers;
       synchronized(ownerMap) {
-        String[] ids = new String[ownerMap.size()];
-        int i=0;
-        for (DistributedMember id: ownerMap.values()) {
-          ids[i++] = id.toString();
-        }
-        Arrays.sort(ids);
-        for (i=0; i<ids.length; i++) {
-          sb.append(ids[i]).append(' ');
-        }
+        servers = new HashSet<>(ownerMap.values());
+      }
+
+      StringBuilder sb = new StringBuilder(1000);
+      sb.append("server count: ")
+        .append(servers.size())
+        .append(" connected client count: ")
+        .append(connections)
+        .append(" client subscription queue count: ")
+        .append(queues)
+        .append(System.lineSeparator())
+        .append("current servers : ");
+      
+      String[] ids = new String[servers.size()];
+      int i=0;
+      for (DistributedMember id: servers) {
+        ids[i++] = id.toString();
+      }
+      Arrays.sort(ids);
+      for (i=0; i<ids.length; i++) {
+        sb.append(ids[i]).append(' ');
       }
       productUseLog.log(sb.toString());
     }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/68dab4af/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/ProductUseLogDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/ProductUseLogDUnitTest.java
b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/ProductUseLogDUnitTest.java
index e2217b5..7715280 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/ProductUseLogDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/ProductUseLogDUnitTest.java
@@ -24,17 +24,24 @@ import java.util.Properties;
 
 import com.gemstone.gemfire.cache.Cache;
 import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.RegionShortcut;
+import com.gemstone.gemfire.cache.client.ClientCache;
+import com.gemstone.gemfire.cache.client.ClientCacheFactory;
+import com.gemstone.gemfire.cache.client.ClientRegionShortcut;
 import com.gemstone.gemfire.cache.server.CacheServer;
+import com.gemstone.gemfire.cache30.CacheTestCase;
 import com.gemstone.gemfire.distributed.Locator;
 import com.gemstone.gemfire.internal.AvailablePort;
 import com.gemstone.gemfire.internal.cache.CacheServerImpl;
 import com.gemstone.gemfire.test.dunit.Assert;
 import com.gemstone.gemfire.test.dunit.DistributedTestCase;
 import com.gemstone.gemfire.test.dunit.Host;
+import com.gemstone.gemfire.test.dunit.SerializableCallable;
 import com.gemstone.gemfire.test.dunit.SerializableRunnable;
 import com.gemstone.gemfire.test.dunit.VM;
 
-public class ProductUseLogDUnitTest extends DistributedTestCase {
+public class ProductUseLogDUnitTest extends CacheTestCase {
 
   public ProductUseLogDUnitTest(String name) {
     super(name);
@@ -50,6 +57,7 @@ public class ProductUseLogDUnitTest extends DistributedTestCase {
   public void testMembershipMonitoring() throws Exception {
     Host host = Host.getHost(0);
     VM vm0 = host.getVM(0);
+    VM vm1 = host.getVM(1);
 
     // use a locator so we will monitor server load and record member->server mappings
     int locatorPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
@@ -67,10 +75,11 @@ public class ProductUseLogDUnitTest extends DistributedTestCase {
     assertTrue(logFile.exists());
     
     assertTrue(logFile.exists());
-    vm0.invoke(new SerializableRunnable("get system") {
-      public void run() {
-        InternalDistributedSystem system = getSystem();
-        Cache cache = CacheFactory.create(system);
+    int serverPort = (Integer)vm0.invoke(new SerializableCallable("get system") {
+      public Object call() {
+        getSystem();
+        getCache();
+        cache.createRegionFactory(RegionShortcut.REPLICATE).create("myregion");
         CacheServer server = cache.addCacheServer();
         server.setPort(0);
         try {
@@ -78,17 +87,40 @@ public class ProductUseLogDUnitTest extends DistributedTestCase {
         } catch (IOException e) {
           Assert.fail("failed to start server", e);
         }
+        return server.getPort();
+      }
+    });
+    
+    vm1.invoke(new SerializableRunnable("create a client") {
+      public void run() {
+        ClientCache clientCache = new ClientCacheFactory()
+            .setPoolSubscriptionEnabled(true)
+            .addPoolServer("localhost", serverPort)
+            .create();
+        Region r = clientCache.createClientRegionFactory(ClientRegionShortcut.PROXY).create("myregion");
+        r.registerInterest(".*");
+        r.put("somekey", "somevalue");
+      }
+    });
+    
+    vm0.invoke(new SerializableRunnable("check region") {
+      public void run() {
+        Region r = cache.getRegion("myregion");
+        Assert.assertNotNull(r.get("somekey"));
       }
     });
 
+    
     // wait for the server info to be received and logged 
-//    pause(2 * BridgeServerImpl.FORCE_LOAD_UPDATE_FREQUENCY * 1000);
+    Thread.sleep(2 * CacheServer.DEFAULT_LOAD_POLL_INTERVAL);
 
     system.disconnect();
 
     String logContents = readFile(logFile);
     assertTrue("expected " + logFile + " to contain a View", logContents.contains("View"));
-    assertTrue("expected " + logFile + " to contain 'server summary'", logContents.contains("server
summary"));
+    assertTrue("expected " + logFile + " to have a server count of 1", logContents.contains("server
count: 1"));
+    assertTrue("expected " + logFile + " to have a client count of 1" , logContents.contains("client
count: 1"));
+    assertTrue("expected " + logFile + " to have a queue count of 1", logContents.contains("queue
count: 1"));
   }
   
   private String readFile(File file) throws IOException {
@@ -101,8 +133,4 @@ public class ProductUseLogDUnitTest extends DistributedTestCase {
     return sb.toString();
   }
 
-  @Override
-  public final void preTearDown() throws Exception {
-    disconnectAllFromDS();
-  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/68dab4af/geode-core/src/test/java/com/gemstone/gemfire/management/ClientHealthStatsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/ClientHealthStatsDUnitTest.java
b/geode-core/src/test/java/com/gemstone/gemfire/management/ClientHealthStatsDUnitTest.java
index 6751aea..721be03 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/ClientHealthStatsDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/ClientHealthStatsDUnitTest.java
@@ -237,7 +237,7 @@ public class ClientHealthStatsDUnitTest extends DistributedTestCase {
     props.setProperty(DistributionConfig.DURABLE_CLIENT_ID_NAME, "durable-"+clientNum);
     props.setProperty(DistributionConfig.DURABLE_CLIENT_TIMEOUT_NAME, "300000");
 
-    props.setProperty("log-file", getTestMethodName()+"_client_" + clientNum + ".log");
+//    props.setProperty("log-file", getTestMethodName()+"_client_" + clientNum + ".log");
     props.setProperty("log-level", "info");
     props.setProperty("statistic-archive-file", getTestMethodName()+"_client_" + clientNum
         + ".gfs");

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/68dab4af/geode-core/src/test/resources/com/gemstone/gemfire/codeAnalysis/sanctionedDataSerializables.txt
----------------------------------------------------------------------
diff --git a/geode-core/src/test/resources/com/gemstone/gemfire/codeAnalysis/sanctionedDataSerializables.txt
b/geode-core/src/test/resources/com/gemstone/gemfire/codeAnalysis/sanctionedDataSerializables.txt
index a6e951a..0dda2e6 100644
--- a/geode-core/src/test/resources/com/gemstone/gemfire/codeAnalysis/sanctionedDataSerializables.txt
+++ b/geode-core/src/test/resources/com/gemstone/gemfire/codeAnalysis/sanctionedDataSerializables.txt
@@ -59,7 +59,7 @@ fromData,31,2a2bb80005b500032ab40003c600122ab40003b600049a00082a04b50002b1
 toData,9,2ab400032bb80006b1
 
 com/gemstone/gemfire/cache/client/internal/locator/LocatorListResponse,2
-fromData,41,2a2bb80006b500032a2bb900070100b500052ab40003c600122ab40003b600049a00082a04b50002b1
+fromData,43,2a2bb80006b500032a2bb900070100b500052ab40003c600142ab40003b9000401009a00082a04b50002b1
 toData,19,2ab400032bb800082b2ab40005b900090200b1
 
 com/gemstone/gemfire/cache/client/internal/locator/LocatorStatusResponse,2


Mime
View raw message