summaryrefslogtreecommitdiffstats
path: root/storageapi
diff options
context:
space:
mode:
authorTor Brede Vekterli <vekterli@verizonmedia.com>2019-03-13 16:00:04 +0000
committerTor Brede Vekterli <vekterli@verizonmedia.com>2019-03-14 14:44:29 +0000
commitc5d95cd19e86f2d3c337122226efd946f47d752e (patch)
treef6d5ab49215e41d67a8208248c58267f32617d25 /storageapi
parent4a18ca637cff723bcc45acc425689a69bcf4db66 (diff)
Basic handling of activate_cluster_state_version RPC in backend
Diffstat (limited to 'storageapi')
-rw-r--r--storageapi/src/vespa/storageapi/message/state.cpp36
-rw-r--r--storageapi/src/vespa/storageapi/message/state.h24
-rw-r--r--storageapi/src/vespa/storageapi/messageapi/messagehandler.h8
-rw-r--r--storageapi/src/vespa/storageapi/messageapi/storagemessage.cpp2
-rw-r--r--storageapi/src/vespa/storageapi/messageapi/storagemessage.h4
5 files changed, 74 insertions, 0 deletions
diff --git a/storageapi/src/vespa/storageapi/message/state.cpp b/storageapi/src/vespa/storageapi/message/state.cpp
index efa9a45764f..071dba16b91 100644
--- a/storageapi/src/vespa/storageapi/message/state.cpp
+++ b/storageapi/src/vespa/storageapi/message/state.cpp
@@ -12,6 +12,8 @@ IMPLEMENT_COMMAND(GetNodeStateCommand, GetNodeStateReply)
IMPLEMENT_REPLY(GetNodeStateReply)
IMPLEMENT_COMMAND(SetSystemStateCommand, SetSystemStateReply)
IMPLEMENT_REPLY(SetSystemStateReply)
+IMPLEMENT_COMMAND(ActivateClusterStateVersionCommand, ActivateClusterStateVersionReply)
+IMPLEMENT_REPLY(ActivateClusterStateVersionReply)
GetNodeStateCommand::GetNodeStateCommand(lib::NodeState::UP expectedState)
: StorageCommand(MessageType::GETNODESTATE),
@@ -102,5 +104,39 @@ SetSystemStateReply::print(std::ostream& out, bool verbose,
}
}
+ActivateClusterStateVersionCommand::ActivateClusterStateVersionCommand(uint32_t version)
+ : StorageCommand(MessageType::ACTIVATE_CLUSTER_STATE_VERSION),
+ _version(version)
+{
+}
+
+void ActivateClusterStateVersionCommand::print(std::ostream& out, bool verbose,
+ const std::string& indent) const
+{
+ out << "ActivateClusterStateVersionCommand(" << _version << ")";
+ if (verbose) {
+ out << " : ";
+ StorageCommand::print(out, verbose, indent);
+ }
+}
+
+ActivateClusterStateVersionReply::ActivateClusterStateVersionReply(const ActivateClusterStateVersionCommand& cmd)
+ : StorageReply(cmd),
+ _activateVersion(cmd.version()),
+ _actualVersion(0) // Must be set explicitly
+{
+}
+
+void ActivateClusterStateVersionReply::print(std::ostream& out, bool verbose,
+ const std::string& indent) const
+{
+ out << "ActivateClusterStateVersionReply(activate " << _activateVersion
+ << ", actual " << _actualVersion << ")";
+ if (verbose) {
+ out << " : ";
+ StorageReply::print(out, verbose, indent);
+ }
+}
+
} // api
} // storage
diff --git a/storageapi/src/vespa/storageapi/message/state.h b/storageapi/src/vespa/storageapi/message/state.h
index 4e5ad92b259..e48dce76fbb 100644
--- a/storageapi/src/vespa/storageapi/message/state.h
+++ b/storageapi/src/vespa/storageapi/message/state.h
@@ -93,4 +93,28 @@ public:
DECLARE_STORAGEREPLY(SetSystemStateReply, onSetSystemStateReply)
};
+class ActivateClusterStateVersionCommand : public StorageCommand {
+ uint32_t _version;
+public:
+ explicit ActivateClusterStateVersionCommand(uint32_t version);
+ uint32_t version() const noexcept { return _version; }
+ void print(std::ostream& out, bool verbose, const std::string& indent) const override;
+
+ DECLARE_STORAGECOMMAND(ActivateClusterStateVersionCommand, onActivateClusterStateVersion);
+
+};
+
+class ActivateClusterStateVersionReply : public StorageReply {
+ uint32_t _activateVersion;
+ uint32_t _actualVersion;
+public:
+ explicit ActivateClusterStateVersionReply(const ActivateClusterStateVersionCommand&);
+ uint32_t activateVersion() const noexcept { return _activateVersion; }
+ void setActualVersion(uint32_t version) noexcept { _actualVersion = version; }
+ uint32_t actualVersion() const noexcept { return _actualVersion; }
+ void print(std::ostream& out, bool verbose, const std::string& indent) const override;
+
+ DECLARE_STORAGEREPLY(ActivateClusterStateVersionReply, onActivateClusterStateVersionReply);
+};
+
}
diff --git a/storageapi/src/vespa/storageapi/messageapi/messagehandler.h b/storageapi/src/vespa/storageapi/messageapi/messagehandler.h
index a9c1dfb8f26..27ee509e859 100644
--- a/storageapi/src/vespa/storageapi/messageapi/messagehandler.h
+++ b/storageapi/src/vespa/storageapi/messageapi/messagehandler.h
@@ -50,6 +50,8 @@ class NotifyBucketChangeCommand;
class SetNodeStateCommand;
class GetNodeStateCommand;
class SetSystemStateCommand;
+class ActivateClusterStateVersionCommand;
+class ActivateClusterStateVersionReply;
class GetSystemStateCommand;
class GetBucketNodesCommand;
class BucketsAddedCommand;
@@ -276,6 +278,12 @@ public:
virtual bool onSetSystemStateReply(
const std::shared_ptr<api::SetSystemStateReply>&)
{ return false; }
+ virtual bool onActivateClusterStateVersion(
+ const std::shared_ptr<api::ActivateClusterStateVersionCommand>&)
+ { return false; }
+ virtual bool onActivateClusterStateVersionReply(
+ const std::shared_ptr<api::ActivateClusterStateVersionReply>&)
+ { return false; }
virtual bool onGetSystemState(
const std::shared_ptr<api::GetSystemStateCommand>&)
{ return false; }
diff --git a/storageapi/src/vespa/storageapi/messageapi/storagemessage.cpp b/storageapi/src/vespa/storageapi/messageapi/storagemessage.cpp
index bab475eea32..40422ce06c4 100644
--- a/storageapi/src/vespa/storageapi/messageapi/storagemessage.cpp
+++ b/storageapi/src/vespa/storageapi/messageapi/storagemessage.cpp
@@ -77,6 +77,8 @@ const MessageType MessageType::SETSYSTEMSTATE("Set system state", SETSYSTEMSTATE
const MessageType MessageType::SETSYSTEMSTATE_REPLY("Set system state reply", SETSYSTEMSTATE_REPLY_ID, &MessageType::SETSYSTEMSTATE);
const MessageType MessageType::GETSYSTEMSTATE("Get system state", GETSYSTEMSTATE_ID);
const MessageType MessageType::GETSYSTEMSTATE_REPLY("get system state reply", GETSYSTEMSTATE_REPLY_ID, &MessageType::GETSYSTEMSTATE);
+const MessageType MessageType::ACTIVATE_CLUSTER_STATE_VERSION("Activate cluster state version", ACTIVATE_CLUSTER_STATE_VERSION_ID);
+const MessageType MessageType::ACTIVATE_CLUSTER_STATE_VERSION_REPLY("Activate cluster state version reply", ACTIVATE_CLUSTER_STATE_VERSION_REPLY_ID, &MessageType::ACTIVATE_CLUSTER_STATE_VERSION);
const MessageType MessageType::GETBUCKETDIFF("GetBucketDiff", GETBUCKETDIFF_ID);
const MessageType MessageType::GETBUCKETDIFF_REPLY("GetBucketDiff reply", GETBUCKETDIFF_REPLY_ID, &MessageType::GETBUCKETDIFF);
const MessageType MessageType::APPLYBUCKETDIFF("ApplyBucketDiff", APPLYBUCKETDIFF_ID);
diff --git a/storageapi/src/vespa/storageapi/messageapi/storagemessage.h b/storageapi/src/vespa/storageapi/messageapi/storagemessage.h
index c9f6e737a47..8c2338a020c 100644
--- a/storageapi/src/vespa/storageapi/messageapi/storagemessage.h
+++ b/storageapi/src/vespa/storageapi/messageapi/storagemessage.h
@@ -149,6 +149,8 @@ public:
QUERYRESULT_REPLY_ID = 89,
SETBUCKETSTATE_ID = 94,
SETBUCKETSTATE_REPLY_ID = 95,
+ ACTIVATE_CLUSTER_STATE_VERSION_ID = 96,
+ ACTIVATE_CLUSTER_STATE_VERSION_REPLY_ID = 97,
MESSAGETYPE_MAX_ID
};
@@ -195,6 +197,8 @@ public:
static const MessageType SETSYSTEMSTATE_REPLY;
static const MessageType GETSYSTEMSTATE;
static const MessageType GETSYSTEMSTATE_REPLY;
+ static const MessageType ACTIVATE_CLUSTER_STATE_VERSION;
+ static const MessageType ACTIVATE_CLUSTER_STATE_VERSION_REPLY;
static const MessageType BUCKETSADDED;
static const MessageType BUCKETSADDED_REPLY;
static const MessageType BUCKETSREMOVED;