-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce ChargePointActionStatusUpdateDao API with AsyncJdbcChargePo…
…intActionStatusDao to offload OCPP status updates to dedicated processor thread and not burden OCPP processing with associated DB transaction.
- Loading branch information
Showing
17 changed files
with
1,301 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
...cpp/src/main/java/net/solarnetwork/central/ocpp/dao/ChargePointActionStatusUpdateDao.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* ================================================================== | ||
* ChargePointActionStatusUpdateDao.java - 15/05/2024 7:28:37 am | ||
* | ||
* Copyright 2024 SolarNetwork.net Dev Team | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License as | ||
* published by the Free Software Foundation; either version 2 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | ||
* 02111-1307 USA | ||
* ================================================================== | ||
*/ | ||
|
||
package net.solarnetwork.central.ocpp.dao; | ||
|
||
import java.time.Instant; | ||
import net.solarnetwork.central.ocpp.domain.ChargePointActionStatus; | ||
|
||
/** | ||
* DAO API for updating {@link ChargePointActionStatus} entities. | ||
* | ||
* @author matt | ||
* @version 1.0 | ||
*/ | ||
public interface ChargePointActionStatusUpdateDao { | ||
|
||
/** | ||
* Update the timestamp for a specific charge point action. | ||
* | ||
* <p> | ||
* This method will create a new entity if one does not already exist. | ||
* </p> | ||
* | ||
* @param userId | ||
* the user ID | ||
* @param chargePointIdentifier | ||
* the charge point identifier | ||
* @param connectorId | ||
* the connector ID the message is related to, or {@literal null} or | ||
* {@literal 0} for charger-wide actions | ||
* @param action | ||
* the action name | ||
* @param messageId | ||
* the message ID | ||
* @param date | ||
* the date | ||
* @throws IllegalArgumentException | ||
* if any argument other than {@code connectorId} is {@literal null} | ||
*/ | ||
default void updateActionTimestamp(Long userId, String chargePointIdentifier, Integer connectorId, | ||
String action, String messageId, Instant date) { | ||
updateActionTimestamp(userId, chargePointIdentifier, 0, connectorId, action, messageId, date); | ||
} | ||
|
||
/** | ||
* Update the timestamp for a specific charge point action. | ||
* | ||
* <p> | ||
* This method will create a new entity if one does not already exist. | ||
* </p> | ||
* | ||
* @param userId | ||
* the user ID | ||
* @param chargePointIdentifier | ||
* the charge point identifier | ||
* @param evseId | ||
* the EVSE ID the message is related to, or {@literal null} for | ||
* charger-wide actions | ||
* @param connectorId | ||
* the connector ID the message is related to, or {@literal null} or | ||
* {@literal 0} for EVSE-wide actions | ||
* @param action | ||
* the action name | ||
* @param messageId | ||
* the message ID | ||
* @param date | ||
* the date | ||
* @throws IllegalArgumentException | ||
* if any argument other than {@code connectorId} is {@literal null} | ||
*/ | ||
void updateActionTimestamp(Long userId, String chargePointIdentifier, Integer evseId, | ||
Integer connectorId, String action, String messageId, Instant date); | ||
|
||
} |
67 changes: 67 additions & 0 deletions
67
...in/java/net/solarnetwork/central/ocpp/dao/jdbc/AsyncJdbcChargePointActionStatusCount.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* ================================================================== | ||
* AsyncJdbcChargePointActionStatusCount.java - 11/06/2018 7:43:25 PM | ||
* | ||
* Copyright 2018 SolarNetwork.net Dev Team | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License as | ||
* published by the Free Software Foundation; either version 2 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | ||
* 02111-1307 USA | ||
* ================================================================== | ||
*/ | ||
|
||
package net.solarnetwork.central.ocpp.dao.jdbc; | ||
|
||
import net.solarnetwork.util.StatCounter.Stat; | ||
|
||
/** | ||
* Statistics for asynchronous JDBC charge point action status processing. | ||
* | ||
* @author matt | ||
* @version 1.0 | ||
*/ | ||
public enum AsyncJdbcChargePointActionStatusCount implements Stat { | ||
|
||
ResultsAdded(0, "results added"), | ||
|
||
WriterThreadsStarted(1, "write threads started"), | ||
|
||
WriterThreadsEnded(2, "write threads ended"), | ||
|
||
ConnectionsCreated(3, "JDBC connections created"), | ||
|
||
UpdatesExecuted(4, "SQL updates executed"), | ||
|
||
UpdatesFailed(5, "SQL updates failed"), | ||
|
||
; | ||
|
||
private final int index; | ||
private final String description; | ||
|
||
private AsyncJdbcChargePointActionStatusCount(int index, String description) { | ||
this.index = index; | ||
this.description = description; | ||
} | ||
|
||
@Override | ||
public int getIndex() { | ||
return index; | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
} |
Oops, something went wrong.