Skip to content
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

Added methods to poll the state of the PushManager and its client threads #3

Closed
wants to merge 5 commits into from

Conversation

Raibaz
Copy link

@Raibaz Raibaz commented Sep 13, 2013

Referring to issue #2, I added a couple of methods to make the PushManager state explicit; they actually shouldn't be necessary, since the shutdown and start method already don't shut down the connection or open them if they're already in the expected state, but I feel like this way is a little clearer and the PushManager.isRunning() method may come in handy.

What do you think?

@jchambers
Copy link
Owner

I think this is a good idea, but would you mind adding a couple unit tests? I'd love to make sure that ApnsClientThread#isRunning and PushManager#isRunning return the right things (especially right at startup/shutdown). I don't doubt that everything is great right now; this is just for protection against regressions in the future.

Also (and I acknowledge this is nit-picky), would you mind adding a short body to the javadoc comments you added for stylistic consistency?

Thanks kindly!

@Raibaz
Copy link
Author

Raibaz commented Sep 21, 2013

I added javadoc bodies and implemented some unit tests, but I'm not 101% sure they're correct...let me know what you think :)

public void testIsRunning() throws InterruptedException {
PushManager pm = this.getPushManager();

pm.start();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might add assertFalse(pm.isRunning()) before starting the push manager, but otherwise, I think this looks great!

@jchambers jchambers closed this Sep 21, 2013
@jchambers jchambers reopened this Sep 21, 2013
@jchambers
Copy link
Owner

Oops -- mis-click. Sorry!

@Raibaz
Copy link
Author

Raibaz commented Sep 27, 2013

I guess your idea of maintaining an internal flag is probably better than mine, since the actual implementation has an issue: you're right in saying that ApnsClientThread.isRunning should not be true if the thread state is CONNECT, but when the PushManager isn't started yet its threads are already in state CONNECT even if the PushManager hasn't been started and thus, in my mind, is not running.

We could solve this problem adding a NEW ClientState representing the state when the PushManager has been created but not started yet, but I guess adding a single boolean flag in the PushManager indicating if it has been started or not and if it is shutting down would probably be easier.

Going to do this as soon as I find some time.

@jchambers
Copy link
Owner

Going to do this as soon as I find some time.

Cool. Thanks for sticking with it!

We could solve this problem adding a NEW ClientState representing the state when the PushManager has been created but not started yet…

Actually, I think I'm going to need to do that in #4 anyhow. Will keep you posted.

@jchambers
Copy link
Owner

So I've made the check-client-state strategy even less feasible in #4 because I, uh, maybe got rid of ApnsClientThread.clientState. Instead, client state is stored in a local variable in the run method. The change should make the internal state machine much more readable and also means that when we DO shut down, we'll have a much better idea of the state of all notifications that had been sent up to that point. That said, I think it does mean that the best (only?) option for tracking PushManager state is by a flag maintained by the PushManager itself.

@jchambers
Copy link
Owner

@Raibaz Hate to say it, but we merged #4 and now there are some conflicts here.

@Raibaz
Copy link
Author

Raibaz commented Nov 2, 2013

I don't have a real connection available at the moment, will have a look
and solve next week
Il 02/nov/2013 19:30 "Jon Chambers" notifications@github.com ha scritto:

@Raibaz https://github.com/Raibaz Hate to say it, but we merged #4https://github.com/relayrides/pushy/pull/4and now there are some conflicts here.


Reply to this email directly or view it on GitHubhttps://github.com//pull/3#issuecomment-27627969
.

jchambers pushed a commit that referenced this pull request Nov 13, 2013
…vent loop group and the getExpiredTokens method has changed a bit. This should also cover what we were trying to do in #3.
@jchambers
Copy link
Owner

@Raibaz Closing this because I think we've got this covered in cc9b69f. Please let me know if you disagree.

@Raibaz
Copy link
Author

Raibaz commented Nov 14, 2013

Yep makes sense to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants