You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@trafficserver.apache.org by "SolidWallOfCode (via GitHub)" <gi...@apache.org> on 2023/03/02 21:20:35 UTC

[GitHub] [trafficserver] SolidWallOfCode commented on a diff in pull request #9323: Support config reloading using plugin msg for STEK Share Plugin

SolidWallOfCode commented on code in PR #9323:
URL: https://github.com/apache/trafficserver/pull/9323#discussion_r1123714332


##########
plugins/experimental/stek_share/stek_share.h:
##########
@@ -21,103 +21,139 @@ limitations under the License.
 
 #include <deque>
 #include <mutex>
+#include <shared_mutex>
 #include <time.h>
 
 #include <libnuraft/nuraft.hxx>
 
 #include "stek_utils.h"
 
-class STEKShareServer
+class PluginConfig
 {
 public:
-  STEKShareServer() : server_id_(1), addr_("localhost"), port_(25000), sm_(nullptr), smgr_(nullptr), raft_instance_(nullptr)
+  PluginConfig()
   {
-    last_updated_    = 0;
-    current_log_idx_ = 0;
-
     // Default ASIO thread pool size: 4.
-    asio_thread_pool_size_ = 4;
+    asio_thread_pool_size = 4;
 
     // Default heart beat interval: 100 ms.
-    heart_beat_interval_ = 100;
+    heart_beat_interval = 100;
 
     // Default election timeout: 200~400 ms.
-    election_timeout_lower_bound_ = 200;
-    election_timeout_upper_bound_ = 400;
+    election_timeout_lower_bound = 200;
+    election_timeout_upper_bound = 400;
 
     // Up to 5 logs will be preserved ahead the last snapshot.
-    reserved_log_items_ = 5;
+    reserved_log_items = 5;
 
     // Snapshot will be created for every 5 log appends.
-    snapshot_distance_ = 5;
+    snapshot_distance = 5;
 
     // Client timeout: 3000 ms.
-    client_req_timeout_ = 3000;
-
-    std::memset(ticket_keys_, 0, SSL_TICKET_KEY_SIZE * 2);
-  }
-
-  void
-  reset()
-  {
-    sm_.reset();
-    smgr_.reset();
-    raft_instance_.reset();
+    client_req_timeout = 3000;
   }
 
   // Server ID.
-  int server_id_;
+  int server_id;
 
   // Server address.
-  std::string addr_;
+  std::string address;
 
   // Server port.
-  int port_;
+  int port;
 
-  // Endpoint: "<addr>:<port>".
-  std::string endpoint_;
+  // Endpoint: "<address>:<port>".
+  std::string endpoint;

Review Comment:
   I would strongly consider `swoc::IPSrv` or `swoc::IPEndPoint` instead.



##########
plugins/experimental/stek_share/stek_share.h:
##########
@@ -21,103 +21,139 @@ limitations under the License.
 
 #include <deque>
 #include <mutex>
+#include <shared_mutex>
 #include <time.h>
 
 #include <libnuraft/nuraft.hxx>
 
 #include "stek_utils.h"
 
-class STEKShareServer
+class PluginConfig
 {
 public:
-  STEKShareServer() : server_id_(1), addr_("localhost"), port_(25000), sm_(nullptr), smgr_(nullptr), raft_instance_(nullptr)
+  PluginConfig()
   {
-    last_updated_    = 0;
-    current_log_idx_ = 0;
-
     // Default ASIO thread pool size: 4.
-    asio_thread_pool_size_ = 4;
+    asio_thread_pool_size = 4;
 
     // Default heart beat interval: 100 ms.
-    heart_beat_interval_ = 100;
+    heart_beat_interval = 100;
 
     // Default election timeout: 200~400 ms.
-    election_timeout_lower_bound_ = 200;
-    election_timeout_upper_bound_ = 400;
+    election_timeout_lower_bound = 200;
+    election_timeout_upper_bound = 400;
 
     // Up to 5 logs will be preserved ahead the last snapshot.
-    reserved_log_items_ = 5;
+    reserved_log_items = 5;
 
     // Snapshot will be created for every 5 log appends.
-    snapshot_distance_ = 5;
+    snapshot_distance = 5;
 
     // Client timeout: 3000 ms.
-    client_req_timeout_ = 3000;
-
-    std::memset(ticket_keys_, 0, SSL_TICKET_KEY_SIZE * 2);
-  }
-
-  void
-  reset()
-  {
-    sm_.reset();
-    smgr_.reset();
-    raft_instance_.reset();
+    client_req_timeout = 3000;
   }
 
   // Server ID.
-  int server_id_;
+  int server_id;
 
   // Server address.
-  std::string addr_;
+  std::string address;
 
   // Server port.
-  int port_;
+  int port;
 
-  // Endpoint: "<addr>:<port>".
-  std::string endpoint_;
+  // Endpoint: "<address>:<port>".
+  std::string endpoint;
 
-  // State machine.
-  nuraft::ptr<nuraft::state_machine> sm_;
+  size_t asio_thread_pool_size;
 
-  // State manager.
-  nuraft::ptr<nuraft::state_mgr> smgr_;
+  int heart_beat_interval;
 
-  // Raft launcher.
-  nuraft::raft_launcher launcher_;
+  int election_timeout_lower_bound;
+  int election_timeout_upper_bound;
 
-  // Raft server instance.
-  nuraft::ptr<nuraft::raft_server> raft_instance_;
+  int reserved_log_items;
 
-  // List of servers to auto add.
-  std::map<int, std::string> server_list_;
+  int snapshot_distance;
+
+  int client_req_timeout;
 
   // STEK update interval.
-  int key_update_interval_;
+  int key_update_interval;
 
-  // When was STEK last updated.
-  time_t last_updated_;
+  // List of servers to auto add.
+  std::map<int, std::string> server_list;
 
-  uint64_t current_log_idx_;
+  // TLS related stuff.
+  std::string root_cert_file;
+  std::string server_cert_file;
+  std::string server_key_file;
+  std::string cert_verify_str;
+};
 
-  size_t asio_thread_pool_size_;
+class STEKShareServer
+{
+public:
+  STEKShareServer() : sm_instance(nullptr), smgr_instance(nullptr), raft_instance(nullptr)

Review Comment:
   Move these initialization values to inline.



##########
plugins/experimental/stek_share/stek_share.h:
##########
@@ -21,103 +21,139 @@ limitations under the License.
 
 #include <deque>
 #include <mutex>
+#include <shared_mutex>
 #include <time.h>
 
 #include <libnuraft/nuraft.hxx>
 
 #include "stek_utils.h"
 
-class STEKShareServer
+class PluginConfig
 {
 public:
-  STEKShareServer() : server_id_(1), addr_("localhost"), port_(25000), sm_(nullptr), smgr_(nullptr), raft_instance_(nullptr)
+  PluginConfig()
   {
-    last_updated_    = 0;
-    current_log_idx_ = 0;
-
     // Default ASIO thread pool size: 4.
-    asio_thread_pool_size_ = 4;
+    asio_thread_pool_size = 4;
 
     // Default heart beat interval: 100 ms.
-    heart_beat_interval_ = 100;
+    heart_beat_interval = 100;
 
     // Default election timeout: 200~400 ms.
-    election_timeout_lower_bound_ = 200;
-    election_timeout_upper_bound_ = 400;
+    election_timeout_lower_bound = 200;
+    election_timeout_upper_bound = 400;
 
     // Up to 5 logs will be preserved ahead the last snapshot.
-    reserved_log_items_ = 5;
+    reserved_log_items = 5;
 
     // Snapshot will be created for every 5 log appends.
-    snapshot_distance_ = 5;
+    snapshot_distance = 5;
 
     // Client timeout: 3000 ms.
-    client_req_timeout_ = 3000;
-
-    std::memset(ticket_keys_, 0, SSL_TICKET_KEY_SIZE * 2);
-  }
-
-  void
-  reset()
-  {
-    sm_.reset();
-    smgr_.reset();
-    raft_instance_.reset();
+    client_req_timeout = 3000;
   }
 
   // Server ID.
-  int server_id_;
+  int server_id;
 
   // Server address.
-  std::string addr_;
+  std::string address;
 
   // Server port.
-  int port_;
+  int port;
 
-  // Endpoint: "<addr>:<port>".
-  std::string endpoint_;
+  // Endpoint: "<address>:<port>".
+  std::string endpoint;
 
-  // State machine.
-  nuraft::ptr<nuraft::state_machine> sm_;
+  size_t asio_thread_pool_size;
 
-  // State manager.
-  nuraft::ptr<nuraft::state_mgr> smgr_;
+  int heart_beat_interval;
 
-  // Raft launcher.
-  nuraft::raft_launcher launcher_;
+  int election_timeout_lower_bound;
+  int election_timeout_upper_bound;
 
-  // Raft server instance.
-  nuraft::ptr<nuraft::raft_server> raft_instance_;
+  int reserved_log_items;
 
-  // List of servers to auto add.
-  std::map<int, std::string> server_list_;
+  int snapshot_distance;
+
+  int client_req_timeout;
 
   // STEK update interval.
-  int key_update_interval_;
+  int key_update_interval;

Review Comment:
   Use `std::chrono` for time.



##########
plugins/experimental/stek_share/stek_share.h:
##########
@@ -21,103 +21,139 @@ limitations under the License.
 
 #include <deque>
 #include <mutex>
+#include <shared_mutex>
 #include <time.h>
 
 #include <libnuraft/nuraft.hxx>
 
 #include "stek_utils.h"
 
-class STEKShareServer
+class PluginConfig
 {
 public:
-  STEKShareServer() : server_id_(1), addr_("localhost"), port_(25000), sm_(nullptr), smgr_(nullptr), raft_instance_(nullptr)
+  PluginConfig()
   {
-    last_updated_    = 0;
-    current_log_idx_ = 0;
-
     // Default ASIO thread pool size: 4.
-    asio_thread_pool_size_ = 4;
+    asio_thread_pool_size = 4;

Review Comment:
   All of these should be inlined, not done in the constructor.



##########
plugins/experimental/stek_share/stek_share.h:
##########
@@ -21,103 +21,139 @@ limitations under the License.
 
 #include <deque>
 #include <mutex>
+#include <shared_mutex>
 #include <time.h>
 
 #include <libnuraft/nuraft.hxx>
 
 #include "stek_utils.h"
 
-class STEKShareServer
+class PluginConfig
 {
 public:
-  STEKShareServer() : server_id_(1), addr_("localhost"), port_(25000), sm_(nullptr), smgr_(nullptr), raft_instance_(nullptr)
+  PluginConfig()
   {
-    last_updated_    = 0;
-    current_log_idx_ = 0;
-
     // Default ASIO thread pool size: 4.
-    asio_thread_pool_size_ = 4;
+    asio_thread_pool_size = 4;
 
     // Default heart beat interval: 100 ms.
-    heart_beat_interval_ = 100;
+    heart_beat_interval = 100;
 
     // Default election timeout: 200~400 ms.
-    election_timeout_lower_bound_ = 200;
-    election_timeout_upper_bound_ = 400;
+    election_timeout_lower_bound = 200;
+    election_timeout_upper_bound = 400;
 
     // Up to 5 logs will be preserved ahead the last snapshot.
-    reserved_log_items_ = 5;
+    reserved_log_items = 5;
 
     // Snapshot will be created for every 5 log appends.
-    snapshot_distance_ = 5;
+    snapshot_distance = 5;
 
     // Client timeout: 3000 ms.
-    client_req_timeout_ = 3000;
-
-    std::memset(ticket_keys_, 0, SSL_TICKET_KEY_SIZE * 2);
-  }
-
-  void
-  reset()
-  {
-    sm_.reset();
-    smgr_.reset();
-    raft_instance_.reset();
+    client_req_timeout = 3000;
   }
 
   // Server ID.
-  int server_id_;
+  int server_id;
 
   // Server address.
-  std::string addr_;
+  std::string address;
 
   // Server port.
-  int port_;
+  int port;
 
-  // Endpoint: "<addr>:<port>".
-  std::string endpoint_;
+  // Endpoint: "<address>:<port>".
+  std::string endpoint;
 
-  // State machine.
-  nuraft::ptr<nuraft::state_machine> sm_;
+  size_t asio_thread_pool_size;
 
-  // State manager.
-  nuraft::ptr<nuraft::state_mgr> smgr_;
+  int heart_beat_interval;
 
-  // Raft launcher.
-  nuraft::raft_launcher launcher_;
+  int election_timeout_lower_bound;
+  int election_timeout_upper_bound;
 
-  // Raft server instance.
-  nuraft::ptr<nuraft::raft_server> raft_instance_;
+  int reserved_log_items;
 
-  // List of servers to auto add.
-  std::map<int, std::string> server_list_;
+  int snapshot_distance;
+
+  int client_req_timeout;

Review Comment:
   Use `std::chrono` for time.



##########
plugins/experimental/stek_share/stek_share.h:
##########
@@ -21,103 +21,139 @@ limitations under the License.
 
 #include <deque>
 #include <mutex>
+#include <shared_mutex>
 #include <time.h>
 
 #include <libnuraft/nuraft.hxx>
 
 #include "stek_utils.h"
 
-class STEKShareServer
+class PluginConfig
 {
 public:
-  STEKShareServer() : server_id_(1), addr_("localhost"), port_(25000), sm_(nullptr), smgr_(nullptr), raft_instance_(nullptr)
+  PluginConfig()
   {
-    last_updated_    = 0;
-    current_log_idx_ = 0;
-
     // Default ASIO thread pool size: 4.
-    asio_thread_pool_size_ = 4;
+    asio_thread_pool_size = 4;
 
     // Default heart beat interval: 100 ms.
-    heart_beat_interval_ = 100;
+    heart_beat_interval = 100;
 
     // Default election timeout: 200~400 ms.
-    election_timeout_lower_bound_ = 200;
-    election_timeout_upper_bound_ = 400;
+    election_timeout_lower_bound = 200;
+    election_timeout_upper_bound = 400;
 
     // Up to 5 logs will be preserved ahead the last snapshot.
-    reserved_log_items_ = 5;
+    reserved_log_items = 5;
 
     // Snapshot will be created for every 5 log appends.
-    snapshot_distance_ = 5;
+    snapshot_distance = 5;
 
     // Client timeout: 3000 ms.
-    client_req_timeout_ = 3000;
-
-    std::memset(ticket_keys_, 0, SSL_TICKET_KEY_SIZE * 2);
-  }
-
-  void
-  reset()
-  {
-    sm_.reset();
-    smgr_.reset();
-    raft_instance_.reset();
+    client_req_timeout = 3000;
   }
 
   // Server ID.
-  int server_id_;
+  int server_id;

Review Comment:
   This was previously initialized in the constructor, now it's not initialized at all.



##########
plugins/experimental/stek_share/stek_share.h:
##########
@@ -21,103 +21,139 @@ limitations under the License.
 
 #include <deque>
 #include <mutex>
+#include <shared_mutex>
 #include <time.h>
 
 #include <libnuraft/nuraft.hxx>
 
 #include "stek_utils.h"
 
-class STEKShareServer
+class PluginConfig
 {
 public:
-  STEKShareServer() : server_id_(1), addr_("localhost"), port_(25000), sm_(nullptr), smgr_(nullptr), raft_instance_(nullptr)
+  PluginConfig()
   {
-    last_updated_    = 0;
-    current_log_idx_ = 0;
-
     // Default ASIO thread pool size: 4.
-    asio_thread_pool_size_ = 4;
+    asio_thread_pool_size = 4;
 
     // Default heart beat interval: 100 ms.
-    heart_beat_interval_ = 100;
+    heart_beat_interval = 100;
 
     // Default election timeout: 200~400 ms.
-    election_timeout_lower_bound_ = 200;
-    election_timeout_upper_bound_ = 400;
+    election_timeout_lower_bound = 200;
+    election_timeout_upper_bound = 400;
 
     // Up to 5 logs will be preserved ahead the last snapshot.
-    reserved_log_items_ = 5;
+    reserved_log_items = 5;
 
     // Snapshot will be created for every 5 log appends.
-    snapshot_distance_ = 5;
+    snapshot_distance = 5;
 
     // Client timeout: 3000 ms.
-    client_req_timeout_ = 3000;
-
-    std::memset(ticket_keys_, 0, SSL_TICKET_KEY_SIZE * 2);
-  }
-
-  void
-  reset()
-  {
-    sm_.reset();
-    smgr_.reset();
-    raft_instance_.reset();
+    client_req_timeout = 3000;
   }
 
   // Server ID.
-  int server_id_;
+  int server_id;
 
   // Server address.
-  std::string addr_;
+  std::string address;
 
   // Server port.
-  int port_;
+  int port;
 
-  // Endpoint: "<addr>:<port>".
-  std::string endpoint_;
+  // Endpoint: "<address>:<port>".
+  std::string endpoint;
 
-  // State machine.
-  nuraft::ptr<nuraft::state_machine> sm_;
+  size_t asio_thread_pool_size;
 
-  // State manager.
-  nuraft::ptr<nuraft::state_mgr> smgr_;
+  int heart_beat_interval;

Review Comment:
   Use `std::chrono` for time.



##########
plugins/experimental/stek_share/stek_share.h:
##########
@@ -21,103 +21,139 @@ limitations under the License.
 
 #include <deque>
 #include <mutex>
+#include <shared_mutex>
 #include <time.h>
 
 #include <libnuraft/nuraft.hxx>
 
 #include "stek_utils.h"
 
-class STEKShareServer
+class PluginConfig
 {
 public:
-  STEKShareServer() : server_id_(1), addr_("localhost"), port_(25000), sm_(nullptr), smgr_(nullptr), raft_instance_(nullptr)
+  PluginConfig()
   {
-    last_updated_    = 0;
-    current_log_idx_ = 0;
-
     // Default ASIO thread pool size: 4.
-    asio_thread_pool_size_ = 4;
+    asio_thread_pool_size = 4;
 
     // Default heart beat interval: 100 ms.
-    heart_beat_interval_ = 100;
+    heart_beat_interval = 100;
 
     // Default election timeout: 200~400 ms.
-    election_timeout_lower_bound_ = 200;
-    election_timeout_upper_bound_ = 400;
+    election_timeout_lower_bound = 200;
+    election_timeout_upper_bound = 400;
 
     // Up to 5 logs will be preserved ahead the last snapshot.
-    reserved_log_items_ = 5;
+    reserved_log_items = 5;
 
     // Snapshot will be created for every 5 log appends.
-    snapshot_distance_ = 5;
+    snapshot_distance = 5;
 
     // Client timeout: 3000 ms.
-    client_req_timeout_ = 3000;
-
-    std::memset(ticket_keys_, 0, SSL_TICKET_KEY_SIZE * 2);
-  }
-
-  void
-  reset()
-  {
-    sm_.reset();
-    smgr_.reset();
-    raft_instance_.reset();
+    client_req_timeout = 3000;
   }
 
   // Server ID.
-  int server_id_;
+  int server_id;
 
   // Server address.
-  std::string addr_;
+  std::string address;
 
   // Server port.
-  int port_;
+  int port;
 
-  // Endpoint: "<addr>:<port>".
-  std::string endpoint_;
+  // Endpoint: "<address>:<port>".
+  std::string endpoint;
 
-  // State machine.
-  nuraft::ptr<nuraft::state_machine> sm_;
+  size_t asio_thread_pool_size;
 
-  // State manager.
-  nuraft::ptr<nuraft::state_mgr> smgr_;
+  int heart_beat_interval;
 
-  // Raft launcher.
-  nuraft::raft_launcher launcher_;
+  int election_timeout_lower_bound;
+  int election_timeout_upper_bound;
 
-  // Raft server instance.
-  nuraft::ptr<nuraft::raft_server> raft_instance_;
+  int reserved_log_items;
 
-  // List of servers to auto add.
-  std::map<int, std::string> server_list_;
+  int snapshot_distance;
+
+  int client_req_timeout;
 
   // STEK update interval.
-  int key_update_interval_;
+  int key_update_interval;
 
-  // When was STEK last updated.
-  time_t last_updated_;
+  // List of servers to auto add.
+  std::map<int, std::string> server_list;
 
-  uint64_t current_log_idx_;
+  // TLS related stuff.
+  std::string root_cert_file;
+  std::string server_cert_file;
+  std::string server_key_file;
+  std::string cert_verify_str;
+};
 
-  size_t asio_thread_pool_size_;
+class STEKShareServer
+{
+public:
+  STEKShareServer() : sm_instance(nullptr), smgr_instance(nullptr), raft_instance(nullptr)
+  {
+    last_updated     = 0;
+    current_log_idx  = 0;
+    config_reloading = false;
 
-  int heart_beat_interval_;
+    std::memset(ticket_keys, 0, SSL_TICKET_KEY_SIZE * 2);
+  }
 
-  int election_timeout_lower_bound_;
-  int election_timeout_upper_bound_;
+  void
+  reset()
+  {
+    {
+      std::unique_lock lock(sm_mutex);
+      sm_instance.reset();

Review Comment:
   Don't these two lines do exactly the same thing?



##########
plugins/experimental/stek_share/stek_share.h:
##########
@@ -21,103 +21,139 @@ limitations under the License.
 
 #include <deque>
 #include <mutex>
+#include <shared_mutex>
 #include <time.h>
 
 #include <libnuraft/nuraft.hxx>
 
 #include "stek_utils.h"
 
-class STEKShareServer
+class PluginConfig
 {
 public:
-  STEKShareServer() : server_id_(1), addr_("localhost"), port_(25000), sm_(nullptr), smgr_(nullptr), raft_instance_(nullptr)
+  PluginConfig()
   {
-    last_updated_    = 0;
-    current_log_idx_ = 0;
-
     // Default ASIO thread pool size: 4.
-    asio_thread_pool_size_ = 4;
+    asio_thread_pool_size = 4;
 
     // Default heart beat interval: 100 ms.
-    heart_beat_interval_ = 100;
+    heart_beat_interval = 100;
 
     // Default election timeout: 200~400 ms.
-    election_timeout_lower_bound_ = 200;
-    election_timeout_upper_bound_ = 400;
+    election_timeout_lower_bound = 200;
+    election_timeout_upper_bound = 400;
 
     // Up to 5 logs will be preserved ahead the last snapshot.
-    reserved_log_items_ = 5;
+    reserved_log_items = 5;
 
     // Snapshot will be created for every 5 log appends.
-    snapshot_distance_ = 5;
+    snapshot_distance = 5;
 
     // Client timeout: 3000 ms.
-    client_req_timeout_ = 3000;
-
-    std::memset(ticket_keys_, 0, SSL_TICKET_KEY_SIZE * 2);
-  }
-
-  void
-  reset()
-  {
-    sm_.reset();
-    smgr_.reset();
-    raft_instance_.reset();
+    client_req_timeout = 3000;
   }
 
   // Server ID.
-  int server_id_;
+  int server_id;
 
   // Server address.
-  std::string addr_;
+  std::string address;
 
   // Server port.
-  int port_;
+  int port;
 
-  // Endpoint: "<addr>:<port>".
-  std::string endpoint_;
+  // Endpoint: "<address>:<port>".
+  std::string endpoint;
 
-  // State machine.
-  nuraft::ptr<nuraft::state_machine> sm_;
+  size_t asio_thread_pool_size;
 
-  // State manager.
-  nuraft::ptr<nuraft::state_mgr> smgr_;
+  int heart_beat_interval;
 
-  // Raft launcher.
-  nuraft::raft_launcher launcher_;
+  int election_timeout_lower_bound;
+  int election_timeout_upper_bound;
 
-  // Raft server instance.
-  nuraft::ptr<nuraft::raft_server> raft_instance_;
+  int reserved_log_items;
 
-  // List of servers to auto add.
-  std::map<int, std::string> server_list_;
+  int snapshot_distance;
+
+  int client_req_timeout;
 
   // STEK update interval.
-  int key_update_interval_;
+  int key_update_interval;
 
-  // When was STEK last updated.
-  time_t last_updated_;
+  // List of servers to auto add.
+  std::map<int, std::string> server_list;
 
-  uint64_t current_log_idx_;
+  // TLS related stuff.
+  std::string root_cert_file;
+  std::string server_cert_file;
+  std::string server_key_file;
+  std::string cert_verify_str;
+};
 
-  size_t asio_thread_pool_size_;
+class STEKShareServer
+{
+public:
+  STEKShareServer() : sm_instance(nullptr), smgr_instance(nullptr), raft_instance(nullptr)
+  {
+    last_updated     = 0;
+    current_log_idx  = 0;
+    config_reloading = false;
 
-  int heart_beat_interval_;
+    std::memset(ticket_keys, 0, SSL_TICKET_KEY_SIZE * 2);
+  }
 
-  int election_timeout_lower_bound_;
-  int election_timeout_upper_bound_;
+  void
+  reset()
+  {
+    {
+      std::unique_lock lock(sm_mutex);
+      sm_instance.reset();
+      sm_instance = nullptr;
+    }
+
+    {
+      std::unique_lock lock(smgr_mutex);
+      smgr_instance.reset();
+      smgr_instance = nullptr;
+    }
+
+    {
+      std::unique_lock lock(raft_mutex);
+      raft_instance.reset();
+      raft_instance = nullptr;
+    }
+  }
 
-  int reserved_log_items_;
+  // Server ID.
+  int server_id;

Review Comment:
   Isn't this in `PluginConfig`?



##########
plugins/experimental/stek_share/stek_share.h:
##########
@@ -21,103 +21,139 @@ limitations under the License.
 
 #include <deque>
 #include <mutex>
+#include <shared_mutex>
 #include <time.h>
 
 #include <libnuraft/nuraft.hxx>
 
 #include "stek_utils.h"
 
-class STEKShareServer
+class PluginConfig
 {
 public:
-  STEKShareServer() : server_id_(1), addr_("localhost"), port_(25000), sm_(nullptr), smgr_(nullptr), raft_instance_(nullptr)
+  PluginConfig()
   {
-    last_updated_    = 0;
-    current_log_idx_ = 0;
-
     // Default ASIO thread pool size: 4.
-    asio_thread_pool_size_ = 4;
+    asio_thread_pool_size = 4;
 
     // Default heart beat interval: 100 ms.
-    heart_beat_interval_ = 100;
+    heart_beat_interval = 100;
 
     // Default election timeout: 200~400 ms.
-    election_timeout_lower_bound_ = 200;
-    election_timeout_upper_bound_ = 400;
+    election_timeout_lower_bound = 200;
+    election_timeout_upper_bound = 400;
 
     // Up to 5 logs will be preserved ahead the last snapshot.
-    reserved_log_items_ = 5;
+    reserved_log_items = 5;
 
     // Snapshot will be created for every 5 log appends.
-    snapshot_distance_ = 5;
+    snapshot_distance = 5;
 
     // Client timeout: 3000 ms.
-    client_req_timeout_ = 3000;
-
-    std::memset(ticket_keys_, 0, SSL_TICKET_KEY_SIZE * 2);
-  }
-
-  void
-  reset()
-  {
-    sm_.reset();
-    smgr_.reset();
-    raft_instance_.reset();
+    client_req_timeout = 3000;
   }
 
   // Server ID.
-  int server_id_;
+  int server_id;
 
   // Server address.
-  std::string addr_;
+  std::string address;
 
   // Server port.
-  int port_;
+  int port;
 
-  // Endpoint: "<addr>:<port>".
-  std::string endpoint_;
+  // Endpoint: "<address>:<port>".
+  std::string endpoint;
 
-  // State machine.
-  nuraft::ptr<nuraft::state_machine> sm_;
+  size_t asio_thread_pool_size;
 
-  // State manager.
-  nuraft::ptr<nuraft::state_mgr> smgr_;
+  int heart_beat_interval;
 
-  // Raft launcher.
-  nuraft::raft_launcher launcher_;
+  int election_timeout_lower_bound;
+  int election_timeout_upper_bound;
 
-  // Raft server instance.
-  nuraft::ptr<nuraft::raft_server> raft_instance_;
+  int reserved_log_items;
 
-  // List of servers to auto add.
-  std::map<int, std::string> server_list_;
+  int snapshot_distance;
+
+  int client_req_timeout;
 
   // STEK update interval.
-  int key_update_interval_;
+  int key_update_interval;
 
-  // When was STEK last updated.
-  time_t last_updated_;
+  // List of servers to auto add.
+  std::map<int, std::string> server_list;
 
-  uint64_t current_log_idx_;
+  // TLS related stuff.
+  std::string root_cert_file;
+  std::string server_cert_file;
+  std::string server_key_file;
+  std::string cert_verify_str;
+};
 
-  size_t asio_thread_pool_size_;
+class STEKShareServer
+{
+public:
+  STEKShareServer() : sm_instance(nullptr), smgr_instance(nullptr), raft_instance(nullptr)
+  {
+    last_updated     = 0;

Review Comment:
   Move this initialization to inline.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org