-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #367 from tumblr/bhaskar-distributed-cache
Introducing hazel cast for clustered operation of collins
- Loading branch information
Showing
232 changed files
with
3,024 additions
and
2,448 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,33 @@ | ||
package collins.cache | ||
|
||
import com.google.common.cache.CacheBuilderSpec | ||
|
||
import collins.guava.GuavaConfig | ||
import collins.hazelcast.HazelcastConfig | ||
import collins.util.config.Configurable | ||
import collins.util.config.ConfigurationException | ||
|
||
object CacheConfig extends Configurable { | ||
|
||
override val namespace = "cache" | ||
override val referenceConfigFilename = "cache_reference.conf" | ||
|
||
def enabled = getBoolean("enabled", true) | ||
def specification = getString("specification", "maximumSize=10000,expireAfterWrite=10s,recordStats") | ||
def cacheType = getString("type", "in-memory") | ||
|
||
override protected def validateConfig() { | ||
logger.debug(s"Loading domain model cache specification enabled - $enabled") | ||
if (enabled) { | ||
logger.debug("Validating domain model cache specification") | ||
CacheBuilderSpec.parse(specification) | ||
if (cacheType != "in-memory" && cacheType != "distributed") | ||
throw new ConfigurationException("Please specify cache type of 'in-memory' or 'distributed'") | ||
|
||
if (cacheType == "in-memory") { | ||
if (!GuavaConfig.enabled) { | ||
throw new ConfigurationException("In memory cache uses Guava, please enable and configure it.") | ||
} | ||
} else { | ||
if (!HazelcastConfig.enabled) { | ||
throw new ConfigurationException("Distributed cache uses hazelcast, please enable and configure it.") | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package collins.callbacks | ||
|
||
trait CallbackDatum { | ||
def compare(z: Any): Boolean | ||
} | ||
|
||
case class StringDatum(val e: String) extends CallbackDatum { | ||
override def compare(z: Any): Boolean = { | ||
if (z == null) | ||
return false | ||
val ar = z.asInstanceOf[AnyRef] | ||
if (ar.getClass != classOf[StringDatum]) | ||
false | ||
else { | ||
val other = ar.asInstanceOf[StringDatum] | ||
this.e.equals(other.e) | ||
} | ||
} | ||
} | ||
|
||
case class CallbackDatumHolder(val datum: Option[CallbackDatum]) { | ||
override def equals(z: Any): Boolean = { | ||
if (z == null) | ||
return false | ||
val ar = z.asInstanceOf[AnyRef] | ||
if (ar.getClass != classOf[CallbackDatumHolder]) | ||
false | ||
else { | ||
val other = ar.asInstanceOf[CallbackDatumHolder] | ||
(this.datum, other.datum) match { | ||
case (Some(s), Some(t)) => s.compare(t) | ||
case _ => false | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.