teletraan
teletraan copied to clipboard
Implement selective update for HostAgentBean and add unit tests
This pull request includes several changes to the deploy-service module, focusing on updating the HostAgentBean class and related components to support partial updates. The most important changes include adding a new method to generate a set clause for changed fields, modifying the HostAgentDAO and DBHostAgentDAOImpl classes to use this new method, and updating the PingHandler class to utilize these changes. Additionally, a new test class for HostAgentBean has been added.
Enhancements to HostAgentBean:
-
deploy-service/common/src/main/java/com/pinterest/deployservice/bean/HostAgentBean.java: AddedtoBuilder = trueto the@Builderannotation and introduced thegenChangedSetClausemethod to generate a set clause for only the changed fields. Also added theaddChangedColumnhelper method. [1] [2]
Updates to DAO classes:
-
deploy-service/common/src/main/java/com/pinterest/deployservice/dao/HostAgentDAO.java: Added theupdateChangedmethod to update only the non-null changed fields of aHostAgentBean. -
deploy-service/common/src/main/java/com/pinterest/deployservice/db/DBHostAgentDAOImpl.java: Modified theupdatemethod to use the newgenChangedSetClausemethod and renamed it toupdateChangedto reflect the new functionality.
Changes to PingHandler:
-
deploy-service/common/src/main/java/com/pinterest/deployservice/handler/PingHandler.java: Removed unused DAO fields and updated theupdateHostStatusmethod to use the newupdateChangedmethod inHostAgentDAO. [1] [2] [3] [4] [5] [6]
New test class:
-
deploy-service/common/src/test/java/com/pinterest/deployservice/bean/HostAgentBeanTest.java: Added a new test class to verify the functionality of thegenChangedSetClausemethod.
These changes improve the efficiency of updates to HostAgentBean by ensuring that only the modified fields are updated in the database.