Skip to content

Commit

Permalink
SNAP-2071: Snappy UI becomes unresponsive on LowMemoryException (#999)
Browse files Browse the repository at this point in the history
* SNAP-2071: Snappy UI becomes unresponsive on LowMemoryException

Changes:
 - Adding time out while obtaining table stats from FunctionService in getStatsFromAllServers.
 - Returns last successful updated table stats in case obtaining table stats takes more than 5 seconds or any exception is thrown.
  • Loading branch information
snappy-sachin authored Apr 18, 2018
1 parent bed771d commit e2775f5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package io.snappydata

import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.{ConcurrentHashMap, TimeUnit}
import java.util.function.BiFunction

import scala.collection.JavaConverters._
Expand Down Expand Up @@ -170,12 +170,17 @@ object SnappyEmbeddedTableStatsProviderService extends TableStatsProviderService
try {
if (dataServers != null && dataServers.size() > 0) {
result = FunctionService.onMembers(dataServers)
.withCollector(new GfxdListResultCollector())
.execute(SnappyRegionStatsCollectorFunction.ID).getResult().
// .withCollector(new GfxdListResultCollector())
.execute(SnappyRegionStatsCollectorFunction.ID).getResult(5, TimeUnit.SECONDS).
asInstanceOf[java.util.ArrayList[SnappyRegionStatsCollectorResult]]
.asScala
}
}
catch {
case NonFatal(e) => log.warn(e.getMessage, e)
}

try {
// External Tables
val hiveTables: java.util.List[ExternalTableMetaData] =
Misc.getMemStore.getExternalCatalog.getHiveTables(true)
Expand All @@ -189,9 +194,17 @@ object SnappyEmbeddedTableStatsProviderService extends TableStatsProviderService
case NonFatal(e) => log.warn(e.getMessage, e)
}

(result.flatMap(_.getRegionStats.asScala),
result.flatMap(_.getIndexStats.asScala),
externalTables)
if(result.flatMap(_.getRegionStats.asScala).size == 0) {
// Return last updated tableSizeInfo
(tableSizeInfo.values.toSeq,
result.flatMap(_.getIndexStats.asScala),
externalTables)
} else {
// Return updated tableSizeInfo
(result.flatMap(_.getRegionStats.asScala),
result.flatMap(_.getIndexStats.asScala),
externalTables)
}
}

type PRIterator = PartitionedRegion#PRLocalScanIterator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import org.apache.spark.{Logging, SparkContext}
trait TableStatsProviderService extends Logging {

@volatile
private var tableSizeInfo = Map.empty[String, SnappyRegionStats]
protected var tableSizeInfo = Map.empty[String, SnappyRegionStats]
private var externalTableSizeInfo = Map.empty[String, SnappyExternalTableStats]
@volatile
private var indexesInfo = Map.empty[String, SnappyIndexStats]
Expand Down

0 comments on commit e2775f5

Please sign in to comment.