teletraan icon indicating copy to clipboard operation
teletraan copied to clipboard

Implement selective update for HostAgentBean and add unit tests

Open tylerwowen opened this issue 1 year ago • 0 comments

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: Added toBuilder = true to the @Builder annotation and introduced the genChangedSetClause method to generate a set clause for only the changed fields. Also added the addChangedColumn helper method. [1] [2]

Updates to DAO classes:

  • deploy-service/common/src/main/java/com/pinterest/deployservice/dao/HostAgentDAO.java: Added the updateChanged method to update only the non-null changed fields of a HostAgentBean.
  • deploy-service/common/src/main/java/com/pinterest/deployservice/db/DBHostAgentDAOImpl.java: Modified the update method to use the new genChangedSetClause method and renamed it to updateChanged to 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 the updateHostStatus method to use the new updateChanged method in HostAgentDAO. [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 the genChangedSetClause method.

These changes improve the efficiency of updates to HostAgentBean by ensuring that only the modified fields are updated in the database.

tylerwowen avatar Dec 20 '24 18:12 tylerwowen