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

Fixes Restcomm#150 : Resubmissions of requests to alternate peers now possible until all peers exhausted, while respecting Weighted Round Robin balancing algorithm #156

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

stevedwyer-nasstar
Copy link

@stevedwyer-nasstar stevedwyer-nasstar commented May 14, 2020

Fixes #150

The IRouter interface now has a new method, processBusyOrUnableToDeliverAnswer(IRequest request, IPeerTable table) which can be called to send a request, which initially received a 3002 or 3004 response from one peer, to an alternate peer.

The PeerImpl class now has a helper method, isBusyOrUnableToDeliverAnswer(Avp avpResCode, IMessage answer), to unambiguously determine whether a response can be considered a Busy or Unable to Deliver response (quite simply whether the response was 3002 or 3004). A second method has also been added to this class, processBusyOrUnableToDeliverAnswer(IRequest request, IPeerTable table), which simply delegates resubmission to the IRouter's new processBusyOrUnableToDeliverAnswer(IRequest request, IPeerTable table) method, when the Router Implementation supports this (see below [^1] for details).

In the PeerImpl's connect() method, the above two methods are used to determine whether a response was a Busy or Unable to deliver response, and, when this is the case, delegates resubmission to the IRouter's new processBusyOrUnableToDeliverAnswer(IRequest request, IPeerTable table) method.

In RouterImpl, an overloaded method selectPeer(IMessage message, List availablePeers) has been added, to allow the default RouterImpl and subclasses (WeightedRoundRobinRouter & WeightedLeastConnectionsRouter) to resend the original request after selecting an alternate peer. In the default PeerImpl and the other existing subclasses, this overloaded method simply calls selectPeer(List availablePeers), in order to maintain the original behaviour.

A new Router class has been defined, WeightedRoundRobinResubmittingRouter, into which the actual functionality has been implemented. This has been copied from WeightedRoundRobinRouter. This new class was defined in order to protect existing users from any possible undesirable side-effects from changes in routing functionality. So, in order to have Busy or Unable to Deliver responses retried on alternate peers, the WeightedRoundRobinResubmittingRouter needs to be configured as the chosen RouterEngine in the Extensions section of the jDiameter config.

The WeightedRoundRobinResubmittingRouter will select alternate peers for resubmissions, until all peers have been exhausted for any given request, while respecting the Weighted Round Robin balancing algorithm.

[^1] To allow the PeerImpl to determine whether or not any particular Router implementation supports resubmissions, a method canProcessBusyOrUnableToDeliverAnswer() has been added to the IRouter interface. This method is implemented in RouterImpl to return false by default and must be overridden by classes supporting this functionality (currently only the WeightedRoundRobinResubmittingRouter).

It may be desirable to merge the functionality into the existing Router classes, rather than to have it exclusively in the newly defined WeightedRoundRobinResubmittingRouter. Please let me know whether this should be done.

Regarding Unit Testing:

The TestRouter class has been extended with Unit Tests covering various scenarios which the WeightedRoundRobinResubmittingRouter may encounter. The existing tests remain unchanged. TestRouter now extends junit.framework.TestCase, to ensure that the tests are run every time a Maven build is performed.

A log4j.properties file has been added to allow all logging output from classes under test to be directed to a ConsoleAppender.

Furthermore:
All code has been reformatted according to the Restcomm checkstyle standards.

Merge pull request RestComm#146 from StephenDwyer-kcom/master
…r class; changes require around peer selection and should move away from using CC-Request-Number AVP for signifying resubmissions. Interim commit only to manage change
…iting behaviour in WeightedRoundRobinRouter class. Tests added to validate WeightedRoundRobinResubmittingRouter selects previously unattempted peers for a resubmission of an existing message, based on existing weighted round robin algorithm.
…tting requests which have received a Busy or Unable to Deliver Answer from one peer, to an alternative peer, and to avoid perpetual re-submission of such requests
Copy link
Author

@stevedwyer-nasstar stevedwyer-nasstar left a comment

Choose a reason for hiding this comment

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

Commit 2575d51 reverted.

isProcessed = message == null;
}
avpResCode = message.getAvps().getAvp(RESULT_CODE);
Copy link
Author

Choose a reason for hiding this comment

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

I'm wondering now whether, because if a redirect was processed, the message (i.e. Answer) could possibly be a different message to when avpResCode was originally assigned its value, this assignment statement should be added again, to ensure the avpResCode contains the most recent value, and this particular change reverted?

Copy link
Author

Choose a reason for hiding this comment

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

Reverted

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.

Diameter error codes 3002 and 3004 are not working as expected
2 participants