Skip to content

Commit

Permalink
MONDRIAN Prevent the dynamic datasource servlet from reading the file…
Browse files Browse the repository at this point in the history
… at every servlet request. Now does it at every X time interval instead.

[git-p4: depot-paths = "//open/mondrian-release/3.2/": change = 13904]
  • Loading branch information
lucboudreau committed Nov 11, 2010
1 parent 5676624 commit 4597d04
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion src/main/mondrian/xmla/impl/DynamicDatasourceXmlaServlet.java
Expand Up @@ -33,12 +33,39 @@ public class DynamicDatasourceXmlaServlet extends DefaultXmlaServlet {
protected URL dataSourcesConfigUrl;
protected String lastDataSourcesConfigString;

public final static String SCHEMA_UPDATE_DELAY = "SCHEMA_UPDATE_DELAY";
/**
* Contains the last timestamp in milis when the
* schema was checked for updates.
*/
protected long lastUpdate = System.currentTimeMillis();

/**
* Interval, in miliseconds, at which to check for
* an updated schema. This is actually a TTL value checked
* at each post request. There are no background tasks running.
*/
protected long updateDelay = 3000;

@Override
public void init() throws ServletException {
super.init();
if (getInitParameter(SCHEMA_UPDATE_DELAY) != null) {
updateDelay = Long.valueOf(
getInitParameter(SCHEMA_UPDATE_DELAY));
}
}

protected void doPost(
HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{
reloadDataSources();
// Check if an update is necessary
if (lastUpdate + updateDelay >= System.currentTimeMillis()) {
lastUpdate = System.currentTimeMillis();
reloadDataSources();
}
super.doPost(request, response);
}

Expand Down

0 comments on commit 4597d04

Please sign in to comment.