Skip to content

Calculate running sessions per user #19

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
merged 7 commits into from
Feb 15, 2016
Merged

Conversation

innokenty
Copy link
Member

1. Calculate running sessions for each (user; browser; version)

Change the behavior of the /stats: accept only logged in users and return a json as the result which maps browser names to browser versions and then to the number of sessions that users has currently running. Like that:

$ curl http://user:password@gridrouter.host/stats

⬇︎

{
  "chrome" : {
    "45.0" : 1
  },
  "firefox" : {
    "33.0" : 2,
    "34.0" : 7
  }
}

The old sessions that are not updated are evicted from the map after the timeout that can be configured by property grid.router.evict.sessions.timeout.seconds with defaults to 2 minutes.

Providing a different session storage than default in-memory implementation should work in a distributed multi-headed Grid Router runtime if properly synchronized via any library chosen.

2. Provide hub error message to client

Respond to the client with the error message returned by the last hub tried, when unable to create new session on any hub. Instead of just responding with the default error message which does not help a lot.

@innokenty
Copy link
Member Author

call @baev @eroshenkoam @smecsia

@@ -64,7 +63,7 @@
private HostSelectionStrategy hostSelectionStrategy;

@Autowired
private GridStats stats;
private SessionStorage sessionStorage;
Copy link
Contributor

Choose a reason for hiding this comment

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

CRITICAL Make "sessionStorage" transient or serializable. rule

@innokenty
Copy link
Member Author

Sonar finally noticed that we have a 100+ lines long method in RouteServlet :)

@innokenty
Copy link
Member Author

And also it finally has noticed that all our @Autowired servlet fields are not @Serializable.

@smecsia
Copy link
Member

smecsia commented Dec 9, 2015

@baev Sonar is right. Servlet fields must be Serializable, so it's a bad idea to autowire them.

@innokenty
Copy link
Member Author

Despite these persisting Sonar issues PR is finally ready to merge.

@innokenty
Copy link
Member Author

Test this please

@innokenty
Copy link
Member Author

These quota reload tests again... >_<

Respond to the client with the error message returned
by the last hub tried, when unable to create new session
on any hub. Instead of just responding with the default
error message which does not help a lot.
@@ -116,7 +117,7 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)

String target = route + request.getRequestURI();
HttpResponse hubResponse = client.execute(post(target, message));
JsonMessage hubMessage = JsonMessageFactory.from(hubResponse.getEntity().getContent());
hubMessage = JsonMessageFactory.from(hubResponse.getEntity().getContent());

if (hubResponse.getStatusLine().getStatusCode() == SC_OK) {
Copy link
Contributor

Choose a reason for hiding this comment

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

MAJOR Refactor this code to not nest more than 3 if/for/while/switch/try statements. rule

@innokenty
Copy link
Member Author

test this please

2 similar comments
@innokenty
Copy link
Member Author

test this please

@innokenty
Copy link
Member Author

test this please

@qatools-ci
Copy link
Contributor

SonarQube analysis reported 5 issues:

  • CRITICAL 3 critical
  • MAJOR 2 major

Watch the comments in this conversation to review them.
Note: the following issues could not be reported as comments because they are located on lines that are not displayed in this pull request:

@smecsia smecsia merged commit 92831da into seleniumkit:master Feb 15, 2016
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.

3 participants