Twitter-Finagle을 사용하여 서버를 만듭니다. 서버의 각 RPC 기능에서 Finagle 클라이언트를 사용하여 다른 서버의 RPC를 호출하면됩니다. 같은 : 나는 lsof -p
를 사용하여 다른 서버에 너무 많은 연결이 있다는 것을 발견,Twitter Finagle이 너무 많은 파일 열기
org.jboss.netty.channel.socket.nio.AbstractNioSelector: Failed to accept a connection
java.io.IOException: open too many files
을 그리고 :
는def rpc() = {
// finagleClient is created in a std way according to Finagle's Doc:
// val client = Thrift.newIface[Hello.FutureIface]("localhost:8080")
// http://twitter.github.io/finagle/guide/Protocols.html#thrift-and-scrooge
//
val f: Future[xx] = finagleClient.otherRpc()
f onSuccess { // do something }
f onFailure { // handle exception }
}
하지만, 너무 오래하지, 오류가 발생 (약 5000 연결!). 어떻게 될지 알고 싶습니다. 제가 놓친 것이 있습니까?
================ 문제는 PLZ Scala: Why mapValues produces a view and is there any stable alternatives?에, 지도의 mapValue 방법 어쩌면 까다로운 참조 =============
해결
val resultIsAView = m.mapValue(mapFunction)
mapFunction
함수가 결과보기 resultIsAView
사용될 때마다 다시 계산된다.
감사! 스티브. FinagleClient가 하나만 생성되었음을 확인합니다. 어쩌면'otherRpc' 서버가 응답이 없습니다. RPC 제한 시간을 설정하는 방법이 있습니까? RPC 시간 초과를 더 짧게 설정하면 많은 추가 연결이 생성되지 않습니다. – hliu
호출에 타임 아웃을 추가하기 위해'finagleClient.otherRpc(). within (50.milliseconds)'와 같은 것을 할 수 있습니다. –