Thank you very much! That worked like a charm! Really appreciate it.
Original Message:
Sent: 04-26-2022 09:15
From: Duarte Cunha Leao
Subject: What is the Post API call to clear cache for a particular cda file queries only - Pentaho CTools
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 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:
- Set the Body field to the new
removeAllBody
field
- Set HTTP method to
POST
- Set Application type to
FORM URLENCODED
- Clear entries in the Parameters tab
Cheers
------------------------------
Duarte Cunha Leao
Software Development Engineer - Specialist
Hitachi Vantara
Original Message:
Sent: 04-25-2022 09:51
From: Ramya Nadig
Subject: What is the Post API call to clear cache for a particular cda file queries only - Pentaho CTools
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
Original Message:
Sent: 04-22-2022 12:32
From: Duarte Cunha Leao
Subject: What is the Post API call to clear cache for a particular cda file queries only - Pentaho CTools
Hi Ramya,
you should not have cdaSettingsId
as the value of the Body field option.
Instead:
- Clear the Body field option
- Set HTTP method to
POST
(just like it is in your latest picture)
- Set Application type to
FORM URLENCODED
(just like it is in your latest picture)
- 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
Original Message:
Sent: 04-22-2022 11:45
From: Ramya Nadig
Subject: What is the Post API call to clear cache for a particular cda file queries only - Pentaho CTools
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
Original Message:
Sent: 04-22-2022 11:10
From: Duarte Cunha Leao
Subject: What is the Post API call to clear cache for a particular cda file queries only - Pentaho CTools
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
Original Message:
Sent: 04-22-2022 10:49
From: Ramya Nadig
Subject: What is the Post API call to clear cache for a particular cda file queries only - Pentaho CTools
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
Original Message:
Sent: 04-22-2022 10:40
From: Duarte Cunha Leao
Subject: What is the Post API call to clear cache for a particular cda file queries only - Pentaho CTools
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
Original Message:
Sent: 04-22-2022 10:20
From: Ramya Nadig
Subject: What is the Post API call to clear cache for a particular cda file queries only - Pentaho CTools
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
Original Message:
Sent: 04-22-2022 10:09
From: Duarte Cunha Leao
Subject: What is the Post API call to clear cache for a particular cda file queries only - Pentaho CTools
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
Original Message:
Sent: 04-22-2022 09:52
From: Ramya Nadig
Subject: What is the Post API call to clear cache for a particular cda file queries only - Pentaho CTools
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
Original Message:
Sent: 04-22-2022 08:51
From: Duarte Cunha Leao
Subject: What is the Post API call to clear cache for a particular cda file queries only - Pentaho CTools
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
Original Message:
Sent: 04-21-2022 14:16
From: Ramya Nadig
Subject: What is the Post API call to clear cache for a particular cda file queries only - Pentaho CTools
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
------------------------------