2016-12-20 5 views
0

몇 가지 장벽에 도달하면 일부 Akka 다중 노드 테스트를 수행하고 하나의 노드를 다시 시작하려고합니다. 뭔가 같이 :Akka 다중 노드 테스트에서 노드를 다시 시작하는 방법은 무엇입니까?

runOn(nodeA) { 
    // do something while both nodes are up and running 

    enterBarrier("nodeBCrashes") 

    // do something while I'm the only node up and running 

    enterBarrier("bothNodesUp") 

    // do something with both nodes up and running again 
} 

runOn(nodeB) { 
    // do something while both nodes are up and running 

    crash() 
    enterBarrier("nodeBCrashes") 

    // do nothing because I'm out 

    enterBarrier("bothNodesUp") 
    start() 

    // do something with both nodes up and running again 

} 

이 할 수없는가요, 적어도 (이 종료 노드 B를 할 수 있어야하고, 같은 akka.remote.netty.tcp.port와 다른 nodeC에서 을 시작하는 방법이 필요합니다 엄격히 필요하다).

우리가 상황을 하나 개의 노드 충돌을 다시 한 후 다시 시작 가능 :

runOn(nodeA) { 
    // do something while both nodes are up and running 

    enterBarrier("nodeBCrashes") 

    // do something while I'm the only node up and running 

    enterBarrier("bothNodesUp") 

    // do something with both nodes up and running again 
} 

runOn(nodeB) { 
    // do something while both nodes are up and running 

    enterBarrier("nodeBCrashes") 
    shutdown() 

} 

// How I can delay nodeC start until nodeA reaches bothNodesUp barrier? 
runOn(nodeC) {  
    // do something when both nodes are up and running 
} 

문제와 같은 뭔가를 재개 할 수 있습니다?

  1. 노드를 다시 시작할 수 있습니까?
  2. 그렇지 않은 경우 나머지 노드가 베리어에 도달하면 노드를 시작할 수 있습니까?
  3. 동일한 akka.remote.netty.tcp.port를 다른 노드 (병렬로 실행하면 안 됨)에 할당 할 수 있습니까? 난 *.opts 파일을 시도했지만 성공하지 않고,이 방법은 무엇입니까?

답변

1

충돌 한 포트와 동일한 포트를 다시 사용하여 ActorSystem을 다시 시작할 수 있어야합니다. Akka 자신의 다중 노드 테스트에서 다음을 수행합니다.

lazy val restartedSecondSystem = ActorSystem(
    system, 
    ConfigFactory.parseString("akka.remote.netty.tcp.port=" + secondUniqueAddress.address.port.get). 
     withFallback(system.settings.config)) 

    ...  

    runOn(nodeB) {   
    shutdown(secondSystem) 
    } 

    enterBarrier("second-shutdown") 

    runOn(nodeB) { 
    Cluster(restartedSecondSystem).joinSeedNodes(seedNodes) 
    } 

더 많은 단서를 보려면 Akka의 소스 코드에서 다음 테스트를 확인하십시오.

https://github.com/akka/akka/blob/master/akka-cluster/src/multi-jvm/scala/akka/cluster/RestartNodeSpec.scala

https://github.com/akka/akka/blob/master/akka-cluster/src/multi-jvm/scala/akka/cluster/RestartNode2Spec.scala

https://github.com/akka/akka/blob/master/akka-cluster/src/multi-jvm/scala/akka/cluster/RestartNode3Spec.scala