Skip to content
This repository
Browse code

[Database] Allow configuration of polling interval

Reduces database polling interval, and allows
configuration on a per-user basis. This addresses
both perceived and actual issues with object
modification:

* nasa/mct#54 notes that object deletion seems
  to take a long time. Root cause is that the
  Browse area is refreshed by database polling,
  which takes place at a longer interval (3s).
  Decreasing this interval means that the user
  sees the consequences of their action sooner.
* nasa/mct#132 occurs when the user switches
  back and forth between objects faster than
  the poll interval. This can cause an object
  to be flagged as stale because changes from
  one save have not made their way back to
  the Browse area. While this still may occur
  with a shorter polling interval, the odds
  of the user observing this decrease
  significantly.
* nasa/mct#111 describes latency issues, some
  of which may be related to the poll
  interval. (It is unlikely, however, that
  menu item latency is related to this.)
  • Loading branch information...
commit b57f7b4df682c2abe38c072aab27b519dde51f9f 1 parent 8b346bc
VWoeltjen VWoeltjen authored
16 databasePersistence/src/main/java/gov/nasa/arc/mct/dbpersistence/service/PersistenceServiceImpl.java
@@ -131,9 +131,21 @@ public void setEntityManagerProperties(Properties p) {
131 131 }
132 132
133 133 public void activate(ComponentContext context) throws IOException {
134   - setEntityManagerProperties(getPersistenceProperties());
  134 + Properties persistenceProperties = getPersistenceProperties();
  135 + setEntityManagerProperties(persistenceProperties);
135 136 new InternalDBPersistenceAccess().setPersistenceService(this);
136 137 checkDatabaseVersion();
  138 +
  139 + // Check for configuration of the polling interval (default is 3s)
  140 + long pollingInterval = 3000;
  141 + try {
  142 + String intervalString = persistenceProperties.getProperty("mct.database_pollInterval");
  143 + if (intervalString != null) {
  144 + pollingInterval = Long.parseLong(intervalString);
  145 + }
  146 + } catch (NumberFormatException nfe) {
  147 + // Stick with the default
  148 + }
137 149
138 150 Timer databasePollingTimer = new Timer();
139 151 databasePollingTimer.schedule(new TimerTask() {
@@ -143,7 +155,7 @@ public void run() {
143 155 InternalDBPersistenceAccess.getService().updateComponentsFromDatabase();
144 156 }
145 157
146   - }, Calendar.getInstance().getTime(), 3000);
  158 + }, Calendar.getInstance().getTime(), pollingInterval);
147 159
148 160 }
149 161
3  platform-assembly/src/main/resources/properties/mysql.properties
@@ -45,6 +45,9 @@ mct.database_userName=root
45 45 # script.
46 46 mct.database_password=root
47 47
  48 +# Configure the polling interval for retrieving new component versions from
  49 +# the database. This value is in milliseconds.
  50 +mct.database_pollInterval=500
48 51
49 52 # The properties below this line are passed directly into the JPA persistence manager
50 53 hibernate.show_sql=false
6 platform-assembly/src/main/resources/properties/persistence.properties
@@ -26,6 +26,12 @@
26 26 javax.persistence.jdbc.url=jdbc:derby:testdb;create=true
27 27 hibernate.hbm2ddl.auto=update
28 28
  29 +# Configure the polling interval for retrieving new component versions from
  30 +# the database. This value is in milliseconds.
  31 +# Using a low value with Derby should not pose problems, as there will not
  32 +# be multi-user load on the database.
  33 +mct.database_pollInterval=250
  34 +
29 35 # The properties below this line are passed directly into the JPA persistence manager
30 36 hibernate.show_sql=false
31 37 hibernate.format_sql=true

0 comments on commit b57f7b4

Please sign in to comment.
Something went wrong with that request. Please try again.