-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
robin
committed
Jun 28, 2013
1 parent
3489e7d
commit c4be048
Showing
9 changed files
with
211 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<configuration> | ||
|
||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> | ||
<target>System.out</target> | ||
<encoder> | ||
<pattern>%date{MM/dd HH:mm:ss} %-5level[%thread] %logger{1} - %msg%n</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<!-- <appender name="FILE" class="ch.qos.logback.core.FileAppender"> | ||
<file>akka.log</file> | ||
<append>false</append> | ||
<encoder> | ||
<pattern>%date{MM/dd HH:mm:ss} %-5level[%thread] %logger{1} - %msg%n</pattern> | ||
</encoder> | ||
</appender> --> | ||
|
||
<logger name="akka" level="INFO" /> | ||
|
||
<root level="DEBUG"> | ||
<appender-ref ref="CONSOLE"/> | ||
</root> | ||
|
||
</configuration> |
30 changes: 30 additions & 0 deletions
30
scala/metrics/metrics/src/main/scala/com/ansvia/belajar/Metrics.scala
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,30 @@ | ||
package com.ansvia.belajar | ||
|
||
import com.yammer.metrics.scala.Instrumented | ||
import com.yammer.metrics.reporting.ConsoleReporter | ||
import java.util.concurrent.TimeUnit | ||
|
||
object Metrics extends Instrumented { | ||
|
||
lazy val reporter = ConsoleReporter.enable(metricsRegistry, 5, TimeUnit.SECONDS) | ||
|
||
def main(args:Array[String]){ | ||
|
||
reporter | ||
|
||
while(true){ | ||
metrics.timer("sleeper").time { | ||
val min = 1000 | ||
val max = 20000 | ||
val rand:Long = (min + (math.random * ((max - min) + 1)).toInt) | ||
println("seep in %d ms...".format(rand)) | ||
Thread.sleep(rand.toLong) | ||
println("wake up after %d ms!".format(rand)) | ||
} | ||
} | ||
} | ||
|
||
} | ||
|
||
|
||
|
13 changes: 13 additions & 0 deletions
13
scala/metrics/metrics/src/test/scala/com/ansvia/belajar/MetricsSpec.scala
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,13 @@ | ||
package com.ansvia.belajar | ||
|
||
import org.specs2.mutable._ | ||
|
||
class MetricsSpec extends Specification { | ||
|
||
"Hello" should { | ||
"match 5 characters" in { | ||
"hello".length must equalTo(5) | ||
} | ||
} | ||
|
||
} |
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,32 @@ | ||
import sbt._ | ||
import Keys._ | ||
|
||
// Author: Robin | ||
|
||
object Build extends Build { | ||
import BuildSettings._ | ||
import Dependencies._ | ||
|
||
// root | ||
lazy val root = Project("root", file(".")) | ||
.aggregate(examples, metrics) | ||
.settings(basicSettings: _*) | ||
.settings(noPublishing: _*) | ||
|
||
// modules | ||
lazy val examples = Project("examples", file("examples")) | ||
.settings(moduleSettings: _*) | ||
.settings(libraryDependencies ++= | ||
compile(ansviaCommons) ++ | ||
test(specs2) ++ | ||
runtime(logback) | ||
) | ||
|
||
lazy val metrics = Project("metrics", file("metrics")) | ||
.settings(moduleSettings: _*) | ||
.settings(libraryDependencies ++= | ||
compile(ansviaCommons, metricScala) ++ | ||
test(specs2) ++ | ||
runtime(logback) | ||
) | ||
} |
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,70 @@ | ||
import sbt._ | ||
import Keys._ | ||
//import com.github.siasia.WebPlugin._ | ||
//import ls.Plugin._ | ||
|
||
object BuildSettings { | ||
|
||
lazy val basicSettings = seq( | ||
version := "0.0.1-alpha", | ||
homepage := Some(new URL("http://ansvia.com")), | ||
organization := "com.ansvia.belajar", | ||
organizationHomepage := Some(new URL("http://ansvia.com")), | ||
description := "", | ||
startYear := Some(2012), | ||
licenses := Seq("Apache 2" -> new URL("http://www.apache.org/licenses/LICENSE-2.0.txt")), | ||
scalaVersion := "2.9.1", | ||
resolvers ++= Dependencies.resolutionRepos, | ||
scalacOptions := Seq("-deprecation", "-encoding", "utf8") | ||
) | ||
|
||
lazy val moduleSettings = basicSettings ++ seq( | ||
// scaladoc settings | ||
(scalacOptions in doc) <++= (name, version).map { (n, v) => Seq("-doc-title", n, "-doc-version", v) }, | ||
|
||
// publishing | ||
credentials += Credentials(Path.userHome / ".ivy2" / ".credentials"), | ||
crossPaths := false, | ||
publishMavenStyle := true | ||
|
||
// LS | ||
// (LsKeys.tags in LsKeys.lsync) := Seq("http", "server", "client", "async"), | ||
// (LsKeys.docsUrl in LsKeys.lsync) := Some(new URL("http://spray.github.com/spray/api/spray-can/")), | ||
// (externalResolvers in LsKeys.lsync) := Seq("spray repo" at "http://repo.spray.cc") | ||
) | ||
|
||
lazy val noPublishing = seq( | ||
publish := (), | ||
publishLocal := () | ||
) | ||
|
||
lazy val withPublishing = seq( | ||
publishTo <<= version { (v:String) => | ||
val ansviaRepo = "http://scala.repo.ansvia.com/nexus" | ||
if(v.trim.endsWith("SNAPSHOT")) | ||
Some("snapshots" at ansviaRepo + "/content/repositories/snapshots") | ||
else | ||
Some("releases" at ansviaRepo + "/content/repositories/releases") | ||
}, | ||
|
||
credentials += Credentials(Path.userHome / ".ivy2" / ".credentials"), | ||
|
||
publishArtifact in Test := false, | ||
|
||
pomIncludeRepository := { _ => false }, | ||
|
||
crossPaths := false, | ||
|
||
pomExtra := ( | ||
<url>http://your.info.url.here</url> | ||
<developers> | ||
<developer> | ||
<id>your id here</id> | ||
<name>Your name here</name> | ||
<url>http://your.site.here.com</url> | ||
</developer> | ||
</developers>) | ||
) | ||
|
||
} | ||
|
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,21 @@ | ||
import sbt._ | ||
|
||
object Dependencies { | ||
val resolutionRepos = Seq( | ||
"typesafe repo" at "http://repo.typesafe.com/typesafe/releases/", | ||
"glassfish repo" at "http://download.java.net/maven/glassfish/", | ||
"spray repo" at "http://repo.spray.cc/", | ||
"Ansvia repo" at "http://scala.repo.ansvia.com/releases/" | ||
) | ||
|
||
def compile (deps: ModuleID*): Seq[ModuleID] = deps map (_ % "compile") | ||
def provided (deps: ModuleID*): Seq[ModuleID] = deps map (_ % "provided") | ||
def test (deps: ModuleID*): Seq[ModuleID] = deps map (_ % "test") | ||
def runtime (deps: ModuleID*): Seq[ModuleID] = deps map (_ % "runtime") | ||
def container (deps: ModuleID*): Seq[ModuleID] = deps map (_ % "container") | ||
|
||
val ansviaCommons = "com.ansvia" % "ansvia-commons" % "0.0.6" | ||
val specs2 = "org.specs2" %% "specs2" % "1.12.4" | ||
val logback = "ch.qos.logback" % "logback-classic" % "1.0.9" | ||
val metricScala = "nl.grons" %% "metrics-scala" % "2.2.0" | ||
} |
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 @@ | ||
sbt.version=0.12.2 |
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,17 @@ | ||
//libraryDependencies <+= sbtVersion(v => "com.github.siasia" %% "xsbt-web-plugin" % (v + "-0.2.11")) | ||
|
||
//addSbtPlugin("me.lessis" % "ls-sbt" % "0.1.1") | ||
|
||
resolvers ++= Seq( | ||
"Ansvia repo" at "http://scala.repo.ansvia.com/releases" | ||
// "less is" at "http://repo.lessis.me", | ||
// "coda" at "http://repo.codahale.com" | ||
) | ||
|
||
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.1.0") | ||
|
||
addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.7.0") | ||
|
||
//addSbtPlugin("com.ansvia" % "onedir" % "0.4") | ||
|
||
//addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.8.3") |