use of org.pentaho.platform.api.engine.ICacheManager in project pentaho-platform by pentaho.
the class NonPooledDatasourceSystemListener method startup.
public boolean startup(final IPentahoSession session) {
try {
// $NON-NLS-1$
Logger.debug(this, "DatasourceSystemListener: called for startup ...");
ICacheManager cacheManager = addCacheRegions();
List<IDatabaseConnection> databaseConnections = getListOfDatabaseConnections(session);
String dsName = "";
DataSource ds = null;
for (IDatabaseConnection databaseConnection : databaseConnections) {
if (databaseConnection != null) {
// $NON-NLS-1$
Logger.debug(this, " Setting up datasource - " + databaseConnection);
dsName = databaseConnection.getName();
// http://jira.pentaho.com/browse/BISERVER-12244
if (!databaseConnection.getAccessType().equals(DatabaseAccessType.JNDI)) {
// if connection's port used by server there is no sense to get DataSource for this
ds = isPortUsedByServer(databaseConnection) ? null : setupDataSourceForConnection(databaseConnection);
} else {
Logger.debug(this, // $NON-NLS-1$
"(Datasource \"" + IDBDatasourceService.JDBC_DATASOURCE + dsName + // $NON-NLS-1$
"\" not cached)");
continue;
}
cacheManager.putInRegionCache(IDBDatasourceService.JDBC_DATASOURCE, dsName, ds);
Logger.debug(this, // $NON-NLS-1$
"(Storing datasource under key \"" + IDBDatasourceService.JDBC_DATASOURCE + dsName + // $NON-NLS-1$
"\")");
}
}
// $NON-NLS-1$
Logger.debug(this, "DatasourceSystemListener: Completed startup.");
return true;
} catch (ObjectFactoryException objface) {
Logger.error(this, Messages.getInstance().getErrorString("DatasourceSystemListener.ERROR_0001_UNABLE_TO_INSTANTIATE_OBJECT"), // $NON-NLS-1$
objface);
return false;
} catch (DatasourceMgmtServiceException dmse) {
Logger.error(this, Messages.getInstance().getErrorString("DatasourceSystemListener.ERROR_0002_UNABLE_TO_GET_DATASOURCE"), // $NON-NLS-1$
dmse);
return false;
}
}
use of org.pentaho.platform.api.engine.ICacheManager in project pentaho-platform by pentaho.
the class NonPooledDatasourceSystemListener method shutdown.
public void shutdown() {
ICacheManager cacheManager = PentahoSystem.getCacheManager(null);
// $NON-NLS-1$
Logger.debug(this, "DatasourceSystemListener: Called for shutdown ...");
cacheManager.removeRegionCache(IDBDatasourceService.JDBC_DATASOURCE);
// $NON-NLS-1$
Logger.debug(this, "DatasourceSystemListener: Completed shutdown.");
}
use of org.pentaho.platform.api.engine.ICacheManager in project pentaho-platform by pentaho.
the class NonPooledDatasourceSystemListener method addCacheRegions.
protected ICacheManager addCacheRegions() {
ICacheManager cacheManager = PentahoSystem.getCacheManager(null);
// $NON-NLS-1$
Logger.debug(this, "Adding caching regions ...");
if (!cacheManager.cacheEnabled(IDBDatasourceService.JDBC_DATASOURCE)) {
cacheManager.addCacheRegion(IDBDatasourceService.JDBC_DATASOURCE);
}
return cacheManager;
}
use of org.pentaho.platform.api.engine.ICacheManager in project pentaho-platform by pentaho.
the class SystemRefreshResource method purgeReportingDataCache.
/**
* @deprecated use org.pentaho.reporting.platform.plugin.CacheManagerEndpoint instead
*/
@Deprecated
@GET
@Path("/reportingDataCache")
@Produces({ MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON })
@Facet(name = "Unsupported")
public Response purgeReportingDataCache() {
if (canAdminister()) {
ICacheManager cacheManager = PentahoSystem.get(ICacheManager.class);
cacheManager.clearRegionCache("report-dataset-cache");
cacheManager.clearRegionCache("report-output-handlers");
Runnable clearCacheAction = PentahoSystem.get(Runnable.class, "_ClearCacheAction", PentahoSessionHolder.getSession());
if (clearCacheAction != null) {
clearCacheAction.run();
}
return Response.ok().type(MediaType.TEXT_PLAIN).build();
} else {
return Response.status(UNAUTHORIZED).build();
}
}
use of org.pentaho.platform.api.engine.ICacheManager in project pentaho-platform by pentaho.
the class PentahoWebContextFilterTest method testWebContextCachedWaitSecondVariable.
@Test
public void testWebContextCachedWaitSecondVariable() throws Exception {
ICacheManager cacheManager = Mockito.mock(ICacheManager.class);
when(cacheManager.getFromGlobalCache(PentahoSystem.WAIT_SECONDS)).thenReturn(null).thenReturn(30);
PentahoWebContextFilter filter = new PentahoWebContextFilter();
PentahoWebContextFilter.cache = cacheManager;
filter.getRequireWaitTime();
filter.getRequireWaitTime();
verify(cacheManager, times(2)).getFromGlobalCache(eq(PentahoSystem.WAIT_SECONDS));
verify(cacheManager, times(1)).putInGlobalCache(eq(PentahoSystem.WAIT_SECONDS), anyObject());
}
Aggregations