-
Notifications
You must be signed in to change notification settings - Fork 38
Improve reconnection settings #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
debasishg
merged 15 commits into
debasishg:master
from
fractaloop:improve-no-reconnection-settings
Apr 26, 2014
Merged
Changes from 14 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
e4eb99c
Rename ExponentialReconnectionPolicy to ExponentialReconnectionSettings
fractaloop 9782806
Add support for maximum attempts in the reconnection settings
fractaloop dffac61
Refactor RedisSpecBase to use the Akka TestKit
fractaloop d9223e4
Update ClientSpec to test no reconnection and reconnection policies
fractaloop f9015d9
Organize imports
fractaloop e6eaaf6
Add akka-testkit to the dependencies
fractaloop deefa68
Revert unconnected logic
fractaloop 2522043
Reconnect more quickly during tests
fractaloop 039b040
More reliable client termination. Now kills the most recent redis client
fractaloop d752e92
Switch to lazy reconnection schedule
fractaloop 76a7102
Convert attempts to a long to match maxAttempts
fractaloop e9aab41
Bugfix in CLIENT SETNAME
fractaloop d1f8f58
Close reconnecting clients after each use
fractaloop 5db9a52
Added a helper method to kill named clients, fixing test reliability
fractaloop 963c025
Ooops, leave that iter private
fractaloop File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -2,31 +2,37 @@ package com.redis | |
|
|
||
| import scala.concurrent.duration._ | ||
|
|
||
| import akka.util.Timeout | ||
| import akka.actor._ | ||
| import akka.testkit.TestKit | ||
| import akka.util.Timeout | ||
| import com.redis.RedisClientSettings.ConstantReconnectionSettings | ||
| import org.scalatest._ | ||
| import org.scalatest.concurrent.{Futures, ScalaFutures} | ||
| import org.scalatest.time._ | ||
|
|
||
| trait RedisSpecBase extends FunSpec | ||
| class RedisSpecBase(_system: ActorSystem) extends TestKit(_system) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice :) |
||
| with FunSpecLike | ||
| with Matchers | ||
| with Futures | ||
| with ScalaFutures | ||
| with BeforeAndAfterEach | ||
| with BeforeAndAfterAll { | ||
| import RedisSpecBase._ | ||
|
|
||
| // Akka setup | ||
| implicit val system = ActorSystem("redis-test-"+ iter.next) | ||
| def this() = this(ActorSystem("redis-test-"+ RedisSpecBase.iter.next)) | ||
| implicit val executionContext = system.dispatcher | ||
| implicit val timeout = Timeout(2 seconds) | ||
|
|
||
| // Scalatest setup | ||
| implicit val defaultPatience = PatienceConfig(timeout = Span(5, Seconds), interval = Span(5, Millis)) | ||
|
|
||
| // Redis client setup | ||
| val client = RedisClient("localhost", 6379, settings = RedisClientSettings(reconnectionSettings = Some(ConstantReconnectionSettings(1000)))) | ||
| val client = RedisClient("localhost", 6379) | ||
|
|
||
| def withReconnectingClient(testCode: RedisClient => Any) = { | ||
| val client = RedisClient("localhost", 6379, settings = RedisClientSettings(reconnectionSettings = ConstantReconnectionSettings(100))) | ||
| testCode(client) | ||
| client.quit().futureValue should equal (true) | ||
| } | ||
|
|
||
| override def beforeEach = { | ||
| client.flushdb() | ||
|
|
@@ -50,6 +56,6 @@ trait RedisSpecBase extends FunSpec | |
|
|
||
| object RedisSpecBase { | ||
|
|
||
| private val iter = Iterator from 0 | ||
| val iter = Iterator from 0 | ||
|
|
||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if a command failure always means disconnection. As we already have termination management, another failure handling strategy might be needed IMHO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I think that means in this block the
IO(Tcp) ! Connectfailed. Wouldn't the same reconnection strategy apply to failed connections?I did remove the
context become unconnectedsince we are already in that state.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually
CommandFailedresults fromConnectmessage to the TCP manager. I think specifying an incorrectInetSocketAddresswill also result in aCommandFailedmessage.CommandFailedcan come also from failed writes due to throttling. See http://doc.akka.io/docs/akka/snapshot/scala/io-tcp.html#throttling-reads-and-writes. So it's not necessarily disconnection.