Job to delete records in cache table older than one day
Write a query that will work against some database configured in Grouper (or one which can be reached over DB link). Note, you dont need a commit
delete from ngss_wsproxy_cache where the_timestamp < systimestamp-1
Write a GSH script that works
GrouperStartup.startup(); int records = new edu.internet2.middleware.grouperClient.jdbc.GcDbAccess().connectionName("pennCommunity").sql("delete from ngss_wsproxy_cache where the_timestamp < systimestamp-6").executeSql(); int total = new edu.internet2.middleware.grouperClient.jdbc.GcDbAccess().connectionName("pennCommunity").sql("select count(1) from ngss_wsproxy_cache").select(int.class);
Add in the data to go to logs
GrouperStartup.startup(); int records = new edu.internet2.middleware.grouperClient.jdbc.GcDbAccess().connectionName("pennCommunity").sql("delete from ngss_wsproxy_cache where the_timestamp < systimestamp-6").executeSql(); OtherJobScript.retrieveFromThreadLocal().getOtherJobInput().getHib3GrouperLoaderLog().addDeleteCount(records); int total = new edu.internet2.middleware.grouperClient.jdbc.GcDbAccess().connectionName("pennCommunity").sql("select count(1) from ngss_wsproxy_cache").select(int.class); OtherJobScript.retrieveFromThreadLocal().getOtherJobInput().getHib3GrouperLoaderLog().setTotalCount(total);
Change the newlines to $newline$ and make an other job script config
otherJob.deleteNgssWsProxyCache.class = edu.internet2.middleware.grouper.app.loader.OtherJobScript otherJob.deleteNgssWsProxyCache.quartzCron = 11 11 * * * ? otherJob.deleteNgssWsProxyCache.scriptType = gsh otherJob.deleteNgssWsProxyCache.scriptSource = GrouperStartup.startup();$newline$int records = new edu.internet2.middleware.grouperClient.jdbc.GcDbAccess().connectionName("pennCommunity").sql("delete from ngss_wsproxy_cache where the_timestamp < systimestamp-1").executeSql();$newline$OtherJobScript.retrieveFromThreadLocal().getOtherJobInput().getHib3GrouperLoaderLog().addDeleteCount(records);$newline$int total = new edu.internet2.middleware.grouperClient.jdbc.GcDbAccess().connectionName("pennCommunity").sql("select count(1) from ngss_wsproxy_cache").select(int.class);$newline$OtherJobScript.retrieveFromThreadLocal().getOtherJobInput().getHib3GrouperLoaderLog().setTotalCount(total);
- Inject that into the UI configuration screen, named as grouper-loader.properties
- Schedule jobs
- Run the job and check results