1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-29 18:50:08 +03:00

F #4809: Add replicated log index information on server zones

This commit is contained in:
Ruben S. Montero 2017-06-23 00:13:27 +02:00
parent 8e19b5666d
commit cc6cc46099
4 changed files with 45 additions and 7 deletions

View File

@ -146,6 +146,14 @@ public:
return frm_thread;
};
/**
* Return the last index of the fed log
*/
int get_last_index() const
{
return last_index;
}
private:
friend void * frm_loop(void *arg);

View File

@ -147,14 +147,34 @@ class OneZoneHelper < OpenNebulaHelper::OneHelper
when "3" then "leader"
else "-"
end
s["TERM"] = xml_doc.root.at_xpath("TERM").text
s["TERM"] = xml_doc.root.at_xpath("TERM").text
s["VOTEDFOR"] = xml_doc.root.at_xpath("VOTEDFOR").text
s["COMMIT"] = xml_doc.root.at_xpath("COMMIT").text
s["LOG_INDEX"] = xml_doc.root.at_xpath("LOG_INDEX").text
s["LOG_INDEX"] = xml_doc.root.at_xpath("LOG_INDEX").text
s["FEDLOG_INDEX"] = xml_doc.root.at_xpath("FEDLOG_INDEX").text
}
puts
CLIHelper.print_header(str_h1 % "SERVERS",false)
CLIHelper.print_header(str_h1 % "ZONE SERVERS",false)
CLIHelper::ShowTable.new(nil, self) do
column :"ID", "", :size=>2 do |d|
d["ID"] if !d.nil?
end
column :"NAME", "", :left, :size=>15 do |d|
d["NAME"] if !d.nil?
end
column :"ENDPOINT", "", :left, :size=>63 do |d|
d["ENDPOINT"] if !d.nil?
end
end.show([zone_hash['ZONE']['SERVER_POOL']['SERVER']].flatten, {})
puts
CLIHelper.print_header(str_h1 % "RAFT & FEDERATION SYNC STATUS",false)
CLIHelper::ShowTable.new(nil, self) do
@ -186,9 +206,10 @@ class OneZoneHelper < OpenNebulaHelper::OneHelper
d["VOTEDFOR"] if !d.nil?
end
column :"ENDPOINT", "", :left, :size=>18 do |d|
d["ENDPOINT"] if !d.nil?
column :"FED_INDEX", "", :left, :size=>10 do |d|
d["FEDLOG_INDEX"] if !d.nil?
end
end.show([zone_hash['ZONE']['SERVER_POOL']['SERVER']].flatten, {})
end

View File

@ -361,8 +361,6 @@ HostPool::HostVM * HostPool::get_host_vm(int oid)
void HostPool::delete_host_vm(int oid)
{
HostVM * hvm;
map<int, HostVM *>::iterator it = host_vms.find(oid);
if ( it != host_vms.end() )

View File

@ -1176,6 +1176,8 @@ std::string& RaftManager::to_xml(std::string& raft_xml)
Nebula& nd = Nebula::instance();
LogDB * logdb = nd.get_logdb();
FedReplicaManager * frm = nd.get_frm();
unsigned int lindex, lterm;
std::ostringstream oss;
@ -1202,6 +1204,15 @@ std::string& RaftManager::to_xml(std::string& raft_xml)
<< "<LOG_TERM>" << lterm << "</LOG_TERM>";
}
if ( nd.is_federation_enabled() )
{
oss << "<FEDLOG_INDEX>" << frm->get_last_index() << "</FEDLOG_INDEX>";
}
else
{
oss << "<FEDLOG_INDEX>-1</FEDLOG_INDEX>";
}
oss << "</RAFT>";
pthread_mutex_unlock(&mutex);