General Discussion

 View Only
Expand all | Collapse all

What is the Post API call to clear cache for a particular cda file queries only - Pentaho CTools

This thread has been viewed 53 times
  • 1.  What is the Post API call to clear cache for a particular cda file queries only - Pentaho CTools

    Posted 04-21-2022 14:17
    I am currently using the below:

    REST Client on PDI - method - POST
    URL- /pentaho/plugin/cda/api/cacheMonitor/removeAll
    Parameter- cdaSettingsId (cda file location/path)
    When I run this, it is clearing the whole cda cache and not just the queries cached from a particular cda file.

    Is there a url to clear only those queries that are cached from a specific cda file?

    ------------------------------
    Ramya Nadig
    Account Representative
    Randstad USA
    ------------------------------


  • 2.  RE: What is the Post API call to clear cache for a particular cda file queries only - Pentaho CTools

    Posted 04-22-2022 08:51

    Hi Ramya,

    the endpoint accepts two optional form parameters: cdaSettingsId and dataAccessId, both optional.
    When the former is not specified, the latter is ignored, and all entries are cleared.

    Could you be passing the parameter as a query string parameter?


    Otherwise, it could be an issue of the specific CDA cache implementation being used. Are you using the default cda.IQueryCache implementation, pt.webdetails.cda.cache.EHCacheQueryCache, declared in plugin.spring.xml? Or, possibly using CDC?

    Cheers



    ------------------------------
    Duarte Cunha Leao
    Software Development Engineer - Specialist
    Hitachi Vantara
    ------------------------------



  • 3.  RE: What is the Post API call to clear cache for a particular cda file queries only - Pentaho CTools

    Posted 04-22-2022 09:53
    Thank you! How do I find out which cache implementation is being used?

    Also, is there an API to build cache for a particular cda file or a particular dataAccessId in a cda file?

    ------------------------------
    Ramya Nadig
    Account Representative
    Randstad USA
    ------------------------------



  • 4.  RE: What is the Post API call to clear cache for a particular cda file queries only - Pentaho CTools

    Posted 04-22-2022 10:09

    Hi Ramya,

    not sure that there is a way to know which cache implementation is being used, (like looking at the log). Debugging is always a possibility.


    However, I think it should suffice to see CDA's plugin.spring.xml file, in the pentaho-solutions/system/cda folder, and look at the class of the cda.IQueryCache bean.

    Regarding CDC (Community Data Cache), unless you have the folder pentaho-solutions/system/cdc please disregard it.

    And so, are you specifying the cdaSettingsId as a form/body parameter?

    Cheers



    ------------------------------
    Duarte Cunha Leao
    Software Development Engineer - Specialist
    Hitachi Vantara
    ------------------------------



  • 5.  RE: What is the Post API call to clear cache for a particular cda file queries only - Pentaho CTools

    Posted 04-22-2022 10:20
    Got it. Using pt.webdetails.cda.cache.EHCacheQueryCache implementation. Specifying the cdaSettingsId as a parameter.

    Is there an API to build/prime CDA cache for a particular cda file or a particular dataAccessId in a cda file? That can also help solve the issue we are facing.


    ------------------------------
    Ramya Nadig
    Account Representative
    Randstad USA
    ------------------------------



  • 6.  RE: What is the Post API call to clear cache for a particular cda file queries only - Pentaho CTools

    Posted 04-22-2022 10:40

    Hi Ramya,

    I'm sorry to insist, but, as far as I can tell, you did not answer my question. Parameters can be sent as form/body parameters or query string parameters. The latter will not work. You only say you are sending a parameter.

    Regarding managing the cache.

    If you need to call the APIs directly, please look at the /cda/api/cacheController/change endpoint.

    Alternatively, you can cache/schedule CDA queries by Open'ing the CDA file in PUC, selecting the specific data access id and then pressing the "Cache this" button:

    That will take you to the CDA Cache Manager, at the URL /pentaho/plugin/cda/api/manageCache.

    You can enable a menu entry in the Tools menu which takes you to the CDA Cache Manager. It's disabled by default, in Pentaho Server EE. Uncomment the two commented out entries in the pentaho-solutions/system/cda/plugin.xml and restart the server.

    From here, you can delete schedules or cached entries. Looking at the browser's Network Panel, for all of these operations, will reveal the corresponding endpoints and how they can be called.



    ------------------------------
    Duarte Cunha Leao
    Software Development Engineer - Specialist
    Hitachi Vantara
    ------------------------------



  • 7.  RE: What is the Post API call to clear cache for a particular cda file queries only - Pentaho CTools

    Posted 04-22-2022 10:50
    Apologies for not being clear. I am calling the API through a rest client (POST method) in PDI and passing the parameter there.

    I did look into scheduled queries under cache manager. It does not work unless I give a value to all the parameters used. Week is a parameter and it will not help if I hardcode a week value since week keeps changing as we move on from week to week.


    ------------------------------
    Ramya Nadig
    Account Representative
    Randstad USA
    ------------------------------



  • 8.  RE: What is the Post API call to clear cache for a particular cda file queries only - Pentaho CTools

    Posted 04-22-2022 11:11

    Hi Ramya,

    regarding the REST client, besides choosing the POST method, you might have to also select the "Application type" to be "FORM URLENCODED" to ensure the parameters go as body/form parameters.

    https://help.hitachivantara.com/Documentation/Pentaho/9.2/Products/REST_Client



    ------------------------------
    Duarte Cunha Leao
    Software Development Engineer - Specialist
    Hitachi Vantara
    ------------------------------



  • 9.  RE: What is the Post API call to clear cache for a particular cda file queries only - Pentaho CTools

    Posted 04-22-2022 11:45
    Thank you for your suggestion. I did update the rest client accordingly but no luck. It is still clearing ALL the cached queries not not just from the cda file mentioned in the parameter.



    ------------------------------
    Ramya Nadig
    Account Representative
    Randstad USA
    ------------------------------



  • 10.  RE: What is the Post API call to clear cache for a particular cda file queries only - Pentaho CTools

    Posted 04-22-2022 12:32

    Hi Ramya,

    you should not have cdaSettingsId as the value of the Body field option.

    Instead:

    1. Clear the Body field option
    2. Set HTTP method to POST (just like it is in your latest picture)
    3. Set Application type to FORM URLENCODED (just like it is in your latest picture)
    4. In the Parameters tab, add one parameter named cdaSettingsId receiving the field (with the same name) cdaSettingsId

    I think this will do the trick.

    Cheers



    ------------------------------
    Duarte Cunha Leao
    Software Development Engineer - Specialist
    Hitachi Vantara
    ------------------------------



  • 11.  RE: What is the Post API call to clear cache for a particular cda file queries only - Pentaho CTools

    Posted 04-25-2022 09:52
    Hi Duarte,

    I followed your steps but I am now getting an error. It is not clear what that error is-






    ------------------------------
    Ramya Nadig
    Account Representative
    Randstad USA
    ------------------------------



  • 12.  RE: What is the Post API call to clear cache for a particular cda file queries only - Pentaho CTools

    Posted 04-26-2022 09:16

    Hi Ramya,

    it appears I have misled you in how to create an HTTP POST request with parameters in the body using the "REST Client" step. The help documentation is quite to blame, here, imo, but, anyway.

    By looking at the code, the Parameters tab actually defines parameters to be added to the query string... which is not what is needed.

    You'll need to go back to using the Body field option, albeit in a different way.

    You'll need to build the HTTP body string in a "Modified JavaScript value" step, with code such as the following:

    var removeAllBody = "cdaSettingsId=" + encodeURIComponent(cdaSettingsId);

    where removeAllBody is defined as an output String field.


    Then, on the REST Client step:

    1. Set the Body field to the new removeAllBody field
    2. Set HTTP method to POST
    3. Set Application type to FORM URLENCODED
    4. Clear entries in the Parameters tab

    Cheers



    ------------------------------
    Duarte Cunha Leao
    Software Development Engineer - Specialist
    Hitachi Vantara
    ------------------------------



  • 13.  RE: What is the Post API call to clear cache for a particular cda file queries only - Pentaho CTools

    Posted 04-26-2022 11:48
    Thank you very much! That worked like a charm! Really appreciate it.

    ------------------------------
    Ramya Nadig
    Account Representative
    Randstad USA
    ------------------------------