Rally Software

 View Only
  • 1.  Getting Connection still allocated.

    Posted Mar 21, 2020 04:23 PM
    Hi  

    We would like to know how to get rid of this exception. Please route this question to Java team from your  group.

    java.lang.IllegalStateException: Invalid use of BasicClientConnManager: connection still allocated.
    Make sure to release the connection before allocating another one.
    at org.apache.http.util.Asserts.check(Asserts.java:34)
    at org.apache.http.impl.conn.BasicClientConnectionManager.getConnection(BasicClientConnectionManager.java:163)
    at org.apache.http.impl.conn.BasicClientConnectionManager$1.getConnection(BasicClientConnectionManager.java:145)
    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:422)
    Here is my code how I am making singleton connection

    restApi = new RallyRestApi(new URI(rallyUrl), sessionID);
    restApi.setProxy(new URI(rallyProxy));
    rallyRestApi = restApi;

    We are trying with one rallyRestAPI object. Looks like there are some concurrent users who are hitting due to which we have got following issue.

    Kindly advise on following !! 

    Let  us know how many concurrent users, can use 1 RallyRestAPI object ? . I can setup that in my code.
    If there is better way to connect to rally ? 
    After how many connections you can block the API key? if it gets blocked what is procedure to get it unblocked. 

      Let us know if you have any dedicated  support team, where we can reach for questions for corporate teams. 




  • 2.  RE: Getting Connection still allocated.
    Best Answer

    Broadcom Employee
    Posted Mar 23, 2020 07:02 AM
    Hi, @ATUL RAY

    There might be some tips here: https://stackoverflow.com/questions/14866362/invalid-use-of-basicclientconnmanager-connection-still-allocated
    It looks like you have an issue with threads in Java code rather than the Restful API of Rally.

    I think there may be two parts to the follow-on questions you are asking:

    1. Capability of the Rest API on Rally.

    I have tested up to 2048 concurrent requests to Rally from the same program using worker threads making XmlHttpRequest calls. I didn't go any higher as it consumed all the processing power and memory on my test laptop to set up the threads, execute the calls and handle the results. The only limitation on accesses to our system are ones set by normal networking protocols. However, if you have a runaway piece of code (mishandled loop , for example), this may trigger an alarm and the username (via the APIKey)  making those calls will get blocked. Contacting our support is the only way to reverse that.

    2. Concurrency of accessing items in the Rally databases.

    When you are reading from work items in Rally, there are no issues with concurrency. When you try to write back and modify, then you can get errors returned that indicate that the data you are using to make the write-back is stale. This can happen with two concurrent writes to the same artefact. The other impact of concurrency is if you try to add a Feature as a parent to two separate User Stories in two separate threads. The data set in one of the threads can become obsolete after the other thread makes a successful write. The API detects this and will return an error. The only route forward from that point is to re-read the parent artefact and re-make the updates. It is possible to structure code so that this is avoided.

    If I didn't answer your questions, please let me know.​

    ------------------------------
    Nik
    Ask me a question, I'm All Ears!
    Rally Sales Engineer
    Rally Software
    ------------------------------



  • 3.  RE: Getting Connection still allocated.

    Posted Mar 25, 2020 02:57 AM
    Hi Nik,
    If I pass more than 70 Features list in doGet method, it fails stating URL is too long. looks like there is limitation on doGet requests. So I tried doPost I get 

    Exception in thread "main" java.io.IOException: HTTP/1.1 405 Could not find web service for ?/HierarchicalRequirement? using request method ?POST?.  However a service does exist at that path using method(s) ?GET?.Exception in thread "main" java.io.IOException: HTTP/1.1 405 Could not find web service for ?/HierarchicalRequirement? using request method ?POST?.  However a service does exist at that path using method(s) ?GET?. at com.rallydev.rest.client.HttpClient.executeRequest(HttpClient.java:163)

    Is there any way, I can pull the hierarchical response by passing list of features? this is my functional need. (without  worrying for  pagination). 
    Here is my code snippet for doPost. 

    public String getRallyHierarchy(List<String> featureApplicableList) throws IOException {
    RallyRestApi rallyRestApi = getRallyConnection();
    System.out.println(" Total List of Features :-"+featureApplicableList.size());
    String query = "";
    String initialQuery = "start=1&pagesize=2000&query=";
    String queryBraces = "";
    int i = 0;
    int len = featureApplicableList.size();
    for (String featureName : featureApplicableList) {

    query += "(Feature = \"/portfolioitem/feature/" + featureName + "\"" + ")";
    if (i != 0) {
    queryBraces += "(";
    query += ")";
    }
    if (i < len - 1)
    query += " OR ";
    i++;
    }

    String sParams = URLEncoder.encode("FormattedID,ObjectID,Name,Feature,Iteration,PlanEstimate,ScheduleState,Project,StartDate,EndDate,Blocked,BlockedReason,DisplayColor,Release,Predecessors,DragAndDropRank,PredecessorNotScheduled,PredecessorScheduledInSameOrLaterIteration,Defects,ReleaseDate,ReleaseStartDate");
    String sVar = "&includePermissions=true&compact=true&workspace=";

    String finalQuery = initialQuery + queryBraces + URLEncoder.encode(query, "UTF-8") + "&fetch=" + sParams + sVar + URLEncoder.encode("/workspace/" + AXP_WORKSPACE_ID) + "&_method=GET&key=" + sessionID;

    finalQuery = finalQuery.replaceAll("%28", "(");
    finalQuery = finalQuery.replaceAll("%29", ")");
    finalQuery = finalQuery.replaceAll("\\+", "%20");


    System.out.println(" WSAPIURL : "+rallyRestApi.getClient().getWsapiUrl()+"/HierarchicalRequirement?slug=%2Freleasetracking?");
    System.out.println("finalQuery: " + finalQuery);
    String response = rallyRestApi.getClient().doPost("/HierarchicalRequirement?slug=%2Freleasetracking?",finalQuery);



  • 4.  RE: Getting Connection still allocated.

    Broadcom Employee
    Posted Mar 25, 2020 03:58 AM
    Hi @ATUL RAY,

    There is a limit on the number of characters on a GET. Usually the problem comes up when you want to do: ((This) OR (that))​ type queries. When there are lots of items to OR together, the line quickly gets very long.

    Instead of doing code with that structure, I recommend that you rework the code so that it does one of the following:
    1. runs multiple shorter queries
    2. filter the artefact on a different field: e.g. "Fetch all those features that are in this project".
    3. Uses the Parent/Children relationships on all artefacts to fetch the Collections.

    Mechanism #3 is the one I use in all my apps. You will find an example here: https://github.com/nikantonelli/PortfolioItemTimeLine/blob/07754e3c60a715989b0a22dbdc89e4742975a787/App.js#L2297

    Even if you do a POST, you will end up generating far more network traffic than you really need.


    ------------------------------
    Nik
    Ask me a question, I'm All Ears!
    Rally Sales Engineer
    Rally Software
    ------------------------------