Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions core/src/main/scala/org/apache/spark/SparkEnv.scala
Original file line number Diff line number Diff line change
Expand Up @@ -374,13 +374,15 @@ object SparkEnv extends Logging {
val memoryManager: MemoryManager =
conf.getOption("spark.memory.manager").filterNot(_.equalsIgnoreCase("default"))
.map(Utils.classForName(_)
.getConstructor(classOf[SparkConf], classOf[Int])
.newInstance(conf, Int.box(numUsableCores))
.asInstanceOf[MemoryManager]).getOrElse {
if (useLegacyMemoryManager) {
new StaticMemoryManager(conf, numUsableCores)
} else {
UnifiedMemoryManager(conf, numUsableCores)
.getConstructor(classOf[SparkConf], classOf[Int])
.newInstance(conf, Int.box(numUsableCores))
.asInstanceOf[MemoryManager]).getOrElse {
SparkSnappyUtils.loadSnappyManager(conf, numUsableCores).getOrElse {
if (useLegacyMemoryManager) {
new StaticMemoryManager(conf, numUsableCores)
} else {
UnifiedMemoryManager(conf, numUsableCores)
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An explicit setting of "spark.memory.manager" should override SnappyUMM. So this should be changed in the getOrElse block of previous code:

      conf.getOption("spark.memory.manager").filterNot(_.equalsIgnoreCase("default"))
      ...
          .asInstanceOf[MemoryManager]).getOrElse {
            SparkSnappyUtils.loadSnappyManager(conf, numUsableCores).getOrElse {
              if (useLegacyMemoryManager)
              ...
            }
          }

}
}

Expand Down
55 changes: 55 additions & 0 deletions core/src/main/scala/org/apache/spark/SparkSnappyUtils.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Copyright (c) 2017 SnappyData, Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you
* may not use this file except in compliance with the License. You
* may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License. See accompanying
* LICENSE file.
*/

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the previous copyright header of SnappyData as owner was correct (filehdr.txt). Since this file is created in our repo only, so original copyright cannot be Apache's.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is with scala-style. I could not find a way to allow either-or kind of setting in scala style checker. It fails if not Apache.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh. Perhaps add full SnappyData header below instead of modification header.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

package org.apache.spark

import org.apache.spark.memory.MemoryManager
import org.apache.spark.util.Utils


object SparkSnappyUtils {

val SNAPPY_UNIFIED_MEMORY_MANAGER_CLASS = "org.apache.spark.memory.SnappyUnifiedMemoryManager"

def loadSnappyManager(conf: SparkConf, numUsableCores: Int): Option[MemoryManager] = {
try {
Some(Utils.classForName(SNAPPY_UNIFIED_MEMORY_MANAGER_CLASS)
.getConstructor(classOf[SparkConf], classOf[Int])
.newInstance(conf, Int.box(numUsableCores))
.asInstanceOf[MemoryManager])
} catch {
case ex: ClassNotFoundException => None
}
}

}