Skip to content

Instantly share code, notes, and snippets.

@maiha
maiha / probeActorRef.scala
Created August 27, 2014 04:34
check a selection has active Actor or not
private def probeActorRef(sel: ActorSelection): Unit = {
import scala.util.{Success, Failure}
import scala.concurrent.ExecutionContext.Implicits.global
import akka.util.Timeout
import scala.concurrent.duration._
implicit val timeout = Timeout(300.millis) // Timeout for the resolveOne call
sel.resolveOne().onComplete {
case Success(ref) =>
@maiha
maiha / DeadLetterWatcher.scala
Created August 27, 2014 09:03
DeadLetterWatcher
import akka.actor._
import com.typesafe.scalalogging.slf4j.StrictLogging
/** DeadLetterを監視するactor
*/
object DeadLetterWatcher {
val actorName = "dead_letter_watcher"
def props(): Props = Props(new DeadLetterWatcher)
def apply(context: ActorRefFactory): ActorRef = context.actorOf(props(), actorName)
}
scalaVersion := "2.11.2"
libraryDependencies ++= {
val v = "0.8.1"
("com.typesafe.akka" %% "akka-remote" % "2.3.5") ::
("org.scalaz" %% "scalaz-core" % "7.1.0") ::
("net.databinder" %% "unfiltered-jetty" % v) ::
("net.databinder" %% "unfiltered-filter" % v) ::
("com.chuusai" %% "shapeless" % "2.0.0") ::
("com.github.nscala-time" %% "nscala-time" % "1.4.0") ::
@maiha
maiha / InspectSession.scala
Created September 5, 2014 06:34
gatling-inspect-session
package study
/** gatling-2.0.0-RC3
* @example{
* ./bin/gatling.sh -nr -s study.InspectSession
* }
*/
import io.gatling.core.Predef._
import io.gatling.http.Predef._
@maiha
maiha / UseAkkaActor.scala
Created September 5, 2014 07:49
use akka actor in gatling
package study
/** gatling-2.0.0-RC3
* @example{
* ./bin/gatling.sh -nr -s study.UseAkkaActor
* }
*/
import io.gatling.core.Predef._
import io.gatling.http.Predef._
@maiha
maiha / gatling.log
Created September 9, 2014 08:48
NPE at gatling-2.0.0-RC3
17:39:00.605 [WARN ] i.g.h.a.AsyncHandlerActor - Request '/v1/jsevents' failed: java.lang.NullPointerException
[ERROR] [09/09/2014 17:39:00.642] [GatlingSystem-akka.actor.default-dispatcher-14] [akka://GatlingSystem/user/$h] null
java.io.IOException
at com.ning.http.client.providers.netty.request.NettyRequestSender.sendRequestWithCachedChannel(NettyRequestSender.java:222)
at com.ning.http.client.providers.netty.request.NettyRequestSender.sendRequestWithCertainForceConnect(NettyRequestSender.java:136)
at com.ning.http.client.providers.netty.request.NettyRequestSender.sendRequest(NettyRequestSender.java:113)
at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.execute(NettyAsyncHttpProvider.java:86)
at com.ning.http.client.AsyncHttpClient.executeRequest(AsyncHttpClient.java:491)
at io.gatling.http.ahc.HttpEngine.startHttpTransaction(HttpEngine.scala:249)
at io.gatling.http.action.HttpRequestAction$.startHttpTransaction$1(HttpRequestAction.scala:3
@maiha
maiha / Repeat.scala
Created September 11, 2014 18:10
gatling: repeat example
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._
class Repeat extends Simulation {
val httpProtocol = http.baseURL("http://localhost").inferHtmlResources()
val scn = scenario("repeat test").repeat(10) { exec(http("Home").get("/")) }
setUp(scn.inject(rampUsers(10) over(1)).protocols(httpProtocol))
}
@maiha
maiha / gist:9f305fb909fd357eb467
Last active November 9, 2016 11:30
akka: killとstopとPoisonPillの違い
stop: 現在処理中のメッセージを完了させる。それ以外のMailboxに溜まっているメッセージは処理しない
PoisonPill: メッセージの追加なので、投げた時点でたまっているメッセージが処理される (キュー消化+stop)
kill: ActorKilledExceptionが速攻出る(処理中の動作を破棄?)。その後はsupervisorのstrategyに依存(default:stop)。Mailboxはそのまま残る(restartしたactorが継続)
http://stackoverflow.com/questions/13847963/akka-kill-vs-stop-vs-poison-pill
@maiha
maiha / 1.Maiha.scala
Created September 22, 2014 07:15
FastCharSequence breaks EL (gatling-snapshot)
import io.gatling.core.Predef._
import io.gatling.http.Predef._
class Maiha extends Simulation {
val top =
exec(http("gatling.io")
.get("/")
.check(regex("""href="(.*?)"""").saveAs("url")) // should be "/assets/images/favicon.ico"
)
.exec(http("1st link")
@maiha
maiha / 1.候補(OSS)
Last active August 29, 2015 14:07
scalaで使えるjob schedulerの調査 (2014.10.03)
a) akka.actor.Scheduler
* akka bundle
* 生akka系
* 永続化: なし
* 使用例: 'system.scheduler.scheduleOnce(8 hours, self, StartDeliveryWorkers)'
* akka: 2.3 ready
* 開発: 活発 (akkaに依存)
b) akka-quartz-scheduler
* https://github.com/enragedginger/akka-quartz-scheduler