Use 'everyChange' as default strategy for JDBC persistence (#8841)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
This commit is contained in:
parent
7312890d44
commit
ab011242ad
@ -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. |
|
| 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. |
|
| 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! |
|
| 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 |
|
| jdbc.minimumIdle | see above | No | see above |
|
||||||
| enableLogTime | `false` | No | timekeeping |
|
| enableLogTime | `false` | No | timekeeping |
|
||||||
|
|
||||||
@ -171,4 +171,3 @@ then
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@ -12,8 +12,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.persistence.jdbc.internal;
|
package org.openhab.persistence.jdbc.internal;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -156,7 +154,7 @@ public class JdbcPersistenceService extends JdbcMapper implements QueryablePersi
|
|||||||
public Iterable<HistoricItem> query(FilterCriteria filter) {
|
public Iterable<HistoricItem> query(FilterCriteria filter) {
|
||||||
if (!checkDBAccessability()) {
|
if (!checkDBAccessability()) {
|
||||||
logger.warn("JDBC::query: database not connected, query aborted for item '{}'", filter.getItemName());
|
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
|
// Get the item name from the filter
|
||||||
@ -168,7 +166,7 @@ public class JdbcPersistenceService extends JdbcMapper implements QueryablePersi
|
|||||||
item = itemRegistry.getItem(itemName);
|
item = itemRegistry.getItem(itemName);
|
||||||
} catch (ItemNotFoundException e1) {
|
} catch (ItemNotFoundException e1) {
|
||||||
logger.error("JDBC::query: unable to get item for itemName: '{}'. Ignore and give up!", itemName);
|
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) {
|
if (item instanceof GroupItem) {
|
||||||
@ -177,11 +175,11 @@ public class JdbcPersistenceService extends JdbcMapper implements QueryablePersi
|
|||||||
logger.debug("JDBC::query: item is instanceof GroupItem '{}'", itemName);
|
logger.debug("JDBC::query: item is instanceof GroupItem '{}'", itemName);
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
logger.debug("JDBC::query: BaseItem of GroupItem is null. Ignore and give up!");
|
logger.debug("JDBC::query: BaseItem of GroupItem is null. Ignore and give up!");
|
||||||
return Collections.emptyList();
|
return List.of();
|
||||||
}
|
}
|
||||||
if (item instanceof GroupItem) {
|
if (item instanceof GroupItem) {
|
||||||
logger.debug("JDBC::query: BaseItem of GroupItem is a GroupItem too. Ignore and give up!");
|
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();
|
long timerStart = System.currentTimeMillis();
|
||||||
List<HistoricItem> items = new ArrayList<>();
|
List<HistoricItem> items = getHistItemFilterQuery(filter, conf.getNumberDecimalcount(), table, item);
|
||||||
items = getHistItemFilterQuery(filter, conf.getNumberDecimalcount(), table, item);
|
|
||||||
|
|
||||||
logger.debug("JDBC::query: query for {} returned {} rows in {} ms", item.getName(), items.size(),
|
logger.debug("JDBC::query: query for {} returned {} rows in {} ms", item.getName(), items.size(),
|
||||||
System.currentTimeMillis() - timerStart);
|
System.currentTimeMillis() - timerStart);
|
||||||
@ -224,6 +221,6 @@ public class JdbcPersistenceService extends JdbcMapper implements QueryablePersi
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<PersistenceStrategy> getDefaultStrategies() {
|
public List<PersistenceStrategy> getDefaultStrategies() {
|
||||||
return Collections.emptyList();
|
return List.of(PersistenceStrategy.Globals.CHANGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,6 +14,7 @@ package org.openhab.persistence.jdbc.model;
|
|||||||
|
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
|
|
||||||
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.openhab.core.persistence.HistoricItem;
|
import org.openhab.core.persistence.HistoricItem;
|
||||||
import org.openhab.core.types.State;
|
import org.openhab.core.types.State;
|
||||||
|
|
||||||
@ -22,6 +23,7 @@ import org.openhab.core.types.State;
|
|||||||
*
|
*
|
||||||
* @author Helmut Lehmeyer - Initial contribution
|
* @author Helmut Lehmeyer - Initial contribution
|
||||||
*/
|
*/
|
||||||
|
@NonNullByDefault
|
||||||
public class JdbcHistoricItem implements HistoricItem {
|
public class JdbcHistoricItem implements HistoricItem {
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user