Use 'everyChange' as default strategy for JDBC persistence (#8841)

Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
This commit is contained in:
Christoph Weitkamp 2020-10-24 22:43:39 +02:00 committed by GitHub
parent 7312890d44
commit ab011242ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 11 deletions

View File

@ -60,7 +60,7 @@ This service can be configured in the file `services/jdbc.cfg`.
| tableUseRealItemNames | `false` | No | table name prefix generation. When set to `true`, real item names are used for table names and `tableNamePrefix` is ignored. When set to `false`, the `tableNamePrefix` is used to generate table names with sequential numbers. |
| tableIdDigitCount | 4 | No | when `tableUseRealItemNames` is `false` and thus table names are generated sequentially, this controls how many zero-padded digits are used in the table name. With the default of 4, the first table name will end with `0001`. For migration from the MySQL persistence service, set this to 0. |
| rebuildTableNames | false | No | rename existing tables using `tableUseRealItemNames` and `tableIdDigitCount`. USE WITH CARE! Deactivate after Renaming is done! |
| jdbc.maximumPoolSize | configured per database in package `org.openhab.persistence.jdbc.db.*` | No | Some embeded databases can handle only one connection. See [this link](https://github.com/brettwooldridge/HikariCP/issues/256) for more information |
| jdbc.maximumPoolSize | configured per database in package `org.openhab.persistence.jdbc.db.*` | No | Some embedded databases can handle only one connection. See [this link](https://github.com/brettwooldridge/HikariCP/issues/256) for more information |
| jdbc.minimumIdle | see above | No | see above |
| enableLogTime | `false` | No | timekeeping |
@ -171,4 +171,3 @@ then
}
end
```

View File

@ -12,8 +12,6 @@
*/
package org.openhab.persistence.jdbc.internal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@ -156,7 +154,7 @@ public class JdbcPersistenceService extends JdbcMapper implements QueryablePersi
public Iterable<HistoricItem> query(FilterCriteria filter) {
if (!checkDBAccessability()) {
logger.warn("JDBC::query: database not connected, query aborted for item '{}'", filter.getItemName());
return Collections.emptyList();
return List.of();
}
// Get the item name from the filter
@ -168,7 +166,7 @@ public class JdbcPersistenceService extends JdbcMapper implements QueryablePersi
item = itemRegistry.getItem(itemName);
} catch (ItemNotFoundException e1) {
logger.error("JDBC::query: unable to get item for itemName: '{}'. Ignore and give up!", itemName);
return Collections.emptyList();
return List.of();
}
if (item instanceof GroupItem) {
@ -177,11 +175,11 @@ public class JdbcPersistenceService extends JdbcMapper implements QueryablePersi
logger.debug("JDBC::query: item is instanceof GroupItem '{}'", itemName);
if (item == null) {
logger.debug("JDBC::query: BaseItem of GroupItem is null. Ignore and give up!");
return Collections.emptyList();
return List.of();
}
if (item instanceof GroupItem) {
logger.debug("JDBC::query: BaseItem of GroupItem is a GroupItem too. Ignore and give up!");
return Collections.emptyList();
return List.of();
}
}
@ -196,8 +194,7 @@ public class JdbcPersistenceService extends JdbcMapper implements QueryablePersi
}
long timerStart = System.currentTimeMillis();
List<HistoricItem> items = new ArrayList<>();
items = getHistItemFilterQuery(filter, conf.getNumberDecimalcount(), table, item);
List<HistoricItem> items = getHistItemFilterQuery(filter, conf.getNumberDecimalcount(), table, item);
logger.debug("JDBC::query: query for {} returned {} rows in {} ms", item.getName(), items.size(),
System.currentTimeMillis() - timerStart);
@ -224,6 +221,6 @@ public class JdbcPersistenceService extends JdbcMapper implements QueryablePersi
@Override
public List<PersistenceStrategy> getDefaultStrategies() {
return Collections.emptyList();
return List.of(PersistenceStrategy.Globals.CHANGE);
}
}

View File

@ -14,6 +14,7 @@ package org.openhab.persistence.jdbc.model;
import java.time.ZonedDateTime;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.persistence.HistoricItem;
import org.openhab.core.types.State;
@ -22,6 +23,7 @@ import org.openhab.core.types.State;
*
* @author Helmut Lehmeyer - Initial contribution
*/
@NonNullByDefault
public class JdbcHistoricItem implements HistoricItem {
private final String name;