OmniSciDB  c07336695a
ContextOperations< CONTEXT_OP_POLICY > Class Template Reference

#include <CommandFunctors.h>

Public Types

using ThriftService = typename CONTEXT_OP_POLICY::ThriftServiceType
 
using ContextType = typename CONTEXT_OP_POLICY::ContextType
 

Static Public Member Functions

static void get_all_roles (ContextType &context)
 
static void get_status (ContextType &context, std::ostream &output_stream=std::cout)
 
static void get_all_roles_for_user (ContextType &context)
 
static void get_dashboards (ContextType &context)
 

Detailed Description

template<typename CONTEXT_OP_POLICY>
class ContextOperations< CONTEXT_OP_POLICY >

Definition at line 29 of file CommandFunctors.h.

Member Typedef Documentation

◆ ContextType

template<typename CONTEXT_OP_POLICY >
using ContextOperations< CONTEXT_OP_POLICY >::ContextType = typename CONTEXT_OP_POLICY::ContextType

Definition at line 32 of file CommandFunctors.h.

◆ ThriftService

template<typename CONTEXT_OP_POLICY >
using ContextOperations< CONTEXT_OP_POLICY >::ThriftService = typename CONTEXT_OP_POLICY::ThriftServiceType

Definition at line 31 of file CommandFunctors.h.

Member Function Documentation

◆ get_all_roles()

template<typename CONTEXT_OP_POLICY >
static void ContextOperations< CONTEXT_OP_POLICY >::get_all_roles ( ContextType context)
inlinestatic

Definition at line 34 of file CommandFunctors.h.

34  {
35  context.role_names.clear();
36  thrift_op<kGET_ROLES>(context, [](ContextType& lambda_context) {
37  for (auto role_name : lambda_context.role_names) {
38  std::cout << role_name << std::endl;
39  }
40  });
41  }
typename CONTEXT_OP_POLICY::ContextType ContextType

◆ get_all_roles_for_user()

template<typename CONTEXT_OP_POLICY >
static void ContextOperations< CONTEXT_OP_POLICY >::get_all_roles_for_user ( ContextType context)
inlinestatic

Definition at line 85 of file CommandFunctors.h.

85  {
86  context.role_names.clear();
87  thrift_op<kGET_ROLES_FOR_USER>(
88  context, context.privs_user_name.c_str(), [](ContextType& lambda_context) {
89  if (lambda_context.role_names.size() == 0) {
90  std::cout << "No roles are granted to "
91  << lambda_context.privs_user_name.c_str() << std::endl;
92  } else {
93  for (auto role_name : lambda_context.role_names) {
94  std::cout << role_name << std::endl;
95  }
96  }
97  });
98  }
typename CONTEXT_OP_POLICY::ContextType ContextType

◆ get_dashboards()

template<typename CONTEXT_OP_POLICY >
static void ContextOperations< CONTEXT_OP_POLICY >::get_dashboards ( ContextType context)
inlinestatic

Definition at line 100 of file CommandFunctors.h.

100  {
101  context.dash_names.clear();
102  thrift_op<kGET_DASHBOARDS>(context, [](ContextType& lambda_context) {
103  if (lambda_context.dash_names.size() == 0) {
104  std::cout << "No dashboards to display." << std::endl;
105  } else {
106  std::cout << "Dashboard ID | Dashboard Name | Owner" << std::endl;
107  for (auto p : lambda_context.dash_names) {
108  std::cout << p.dashboard_id << " | " << p.dashboard_name << " | "
109  << p.dashboard_owner << std::endl;
110  }
111  }
112  });
113  }
typename CONTEXT_OP_POLICY::ContextType ContextType

◆ get_status()

template<typename CONTEXT_OP_POLICY >
static void ContextOperations< CONTEXT_OP_POLICY >::get_status ( ContextType context,
std::ostream &  output_stream = std::cout 
)
inlinestatic

Definition at line 43 of file CommandFunctors.h.

43  {
44  auto success_op = [&output_stream](ContextType& lambda_context) {
45  time_t t = (time_t)lambda_context.cluster_status[0].start_time;
46  std::tm* tm_ptr = gmtime(&t);
47  char buf[12] = {0};
48  strftime(buf, 11, "%F", tm_ptr);
49  std::string server_version = lambda_context.cluster_status[0].version;
50 
51  output_stream << "The Server Version Number : "
52  << lambda_context.cluster_status[0].version << std::endl;
53  output_stream << "The Server Start Time : " << buf << " : " << tm_ptr->tm_hour
54  << ":" << tm_ptr->tm_min << ":" << tm_ptr->tm_sec << std::endl;
55  output_stream << "The Server edition : " << server_version << std::endl;
56 
57  if (lambda_context.cluster_status.size() > 1) {
58  output_stream << "The Number of Leaves : "
59  << lambda_context.cluster_status.size() - 1 << std::endl;
60  for (auto leaf = lambda_context.cluster_status.begin() + 1;
61  leaf != lambda_context.cluster_status.end();
62  ++leaf) {
63  t = (time_t)leaf->start_time;
64  buf[11] = 0;
65  std::tm* tm_ptr = gmtime(&t);
66  strftime(buf, 11, "%F", tm_ptr);
67  output_stream << "--------------------------------------------------"
68  << std::endl;
69  output_stream << "Name of Leaf : " << leaf->host_name
70  << std::endl;
71  if (server_version.compare(leaf->version) != 0) {
72  output_stream << "The Leaf Version Number : " << leaf->version
73  << std::endl;
74  std::cerr << "Version number mismatch!" << std::endl;
75  }
76  output_stream << "The Leaf Start Time : " << buf << " : "
77  << tm_ptr->tm_hour << ":" << tm_ptr->tm_min << ":"
78  << tm_ptr->tm_sec << std::endl;
79  }
80  }
81  };
82  thrift_op<kGET_SERVER_STATUS>(context, success_op);
83  }
typename CONTEXT_OP_POLICY::ContextType ContextType

The documentation for this class was generated from the following file: