StreamBase C++ API  10.6.1.0
StreamBaseAdminClient.hpp
1 // Copyright (c) 2004-2020 TIBCO Software Inc. All rights reserved.
2 
3 #ifndef STREAMBASE_NMCLIENT_H
4 #define STREAMBASE_NMCLIENT_H
5 
6 #include "StreamBase.hpp"
7 
8 #include "Exceptions.hpp"
9 #include "Schema.hpp"
10 #include "StreamProperties.hpp"
11 #include "StreamBaseURI.hpp"
12 #include "StreamBaseConstants.hpp"
13 #include "ClientSettings.hpp"
14 
15 SB_INTERNAL_FWD(Admin)
16 
17 SB_NAMESPACE_BEGIN;
18 
19 
20 /// The StreamBase Admin Client API. Connects to a StreamBase node over the network,
21 /// via XML/RPC
23 {
24  public:
25  /// Creates a StreamBase client and establishes a connection to a remote
26  /// server.
27  StreamBaseAdminClient(const StreamBaseURI& uri);
28 
29  /// Creates a StreamBase client and establishes a connection to a remote
30  /// server.
31  /// Note: The StreamBaseAdminClient only supports 1 URI in the list.
32  StreamBaseAdminClient(const std::vector<StreamBaseURI>& uris = StreamBaseURI::vectorFromEnvironment());
33 
34  /// Creates a StreamBase client and establishes a connection to a remote
35  /// server.
36  /// Note: The StreamBaseAdminClient only supports 1 URI in the list.
37  StreamBaseAdminClient(const std::vector<StreamBaseURI>& uris, sb::ClientSettings &settings);
38 
39  /// Destroys a session.
40  virtual ~StreamBaseAdminClient();
41 
42  /// Shuts down the application/sbd.
43  std::string shutdown();
44 
45  /// Shuts down a container or a Java Operator
46  std::string shutdown(const std::string &name) ;
47 
48  /// Shuts down Java operators in an application.
49  void shutdownOperators(std::vector<std::string> &operatorNames) ;
50 
51  /// Suspends Java operators in an application.
52  void suspendOperators(std::vector<std::string> &operatorNames) ;
53 
54  /// Restarts one or more Operators in an application.
55  void restartOperators(std::vector<std::string> &operatorNames) ;
56 
57  /// Suspends a container or a Java Operator
58  void suspend(const std::string &name) ;
59 
60  /// Restarts a container
61  void restartContainer(const std::string &name) ;
62 
63  /// Resumes a container or a Java Operator
64  void resume(const std::string &name) ;
65 
66  /// Resumes Java operators in an application.
67  void resumeOperators(std::vector<std::string> &operatorNames) ;
68 
69  /// For the given Operator, return its set of properties and their values.
70  void getOperatorProperties(const std::string &operatorName, std::vector<std::string> &result) ;
71 
72  /// Return the value of the given property on the given Operator.
73  std::string getOperatorProperty(const std::string &operatorName, const std::string &propertyName) ;
74 
75  /// On the given Operator, set the given property to the given value.
76  void setOperatorProperty(const std::string &operatorName, const std::string &propertyName, const std::string &value) ;
77 
78 #ifndef DOXYGEN_SKIP
79  /// Gets a process image dump
80  void getdump() ;
81 
82  /// force an exception
83  void takeException() ;
84 #endif
85 
86  /// Adds an application to the default container
87  ///
88  /// @param application a string containing the text of an application EventFlow, StreamSQL or binary of a sbar file
89  /// @deprecated
90  void modifyApplication(const std::string &application);
91 
92  /// Add an application to the given container
93  ///
94  /// @param containerName the name of the container to add this to
95  /// @param applicationText binary content from a <code>.sbar</code> file, xml from an EventFlow application, or StreamSQL text. The character set is assumed UTF-8.
96  /// @param options a list of options for the added container. Run "sbadmin addContainer --help" for a complete list.
97  /// @return results if any
98  std::vector<std::string> addContainer(const std::string &containerName, const std::string &applicationText, const std::vector<std::string> &options);
99 
100 
101  /// Add a deploy file to the server
102  ///
103  /// @param deployText binary content from a <code>.sbar</code> file, or xml from an <code>.sbdeploy</code> file. The character set is assumed UTF-8.
104  /// @param options a list of options. Currently only supports --verbose as an argument
105  /// @return results if any
106  std::vector<std::string> addDeploy(const std::string &applicationText,
107  const std::vector<std::string> &options = std::vector<std::string>());
108 
109  /// Remove a container
110  ///
111  /// @param containerName the name of the container to add this to
112  /// @param options a list of options. Currently only supports --verbose as an argument
113  /// @return results if any
114  std::vector<std::string> removeContainer(const std::string &containerName,
115  const std::vector<std::string> &options = std::vector<std::string>());
116 
117  ///
118  /// Modify the given container
119  /// @param containerName containerName the container name to modify
120  /// @param options a list of options to modify a container. Run "sbadmin modifyContainer --help" for a complete list.
121  /// @return results if any
122  std::vector<std::string> modifyContainer(const std::string &containerName, const std::vector<std::string> &options);
123 
124  /// Lists all Connections to the StreamBaseServer
125  ///
126  /// @param result the result
127  /// @param option
128  void listConnections(std::vector<std::string>& result, const std::vector<std::string> &option = std::vector<std::string>());
129 
130  /// Kill the connection with the given connectionId
131  ///
132  void killConnection(const std::string &connectionId, std::vector<std::string> &status);
133 
134  /// Kill all connected clients
135  void killAllConnections(std::vector<std::string> &status);
136 
137  /// Manage JDBC connections
138  std::vector<std::string> manageJdbcConnections(const std::vector<std::string> &options);
139 
140 #ifndef DOXYGEN_SKIP
141  ///
142  /// Modify a runtime parameter for one, or all, operators. Changes all
143  /// operators if operatorName is omitted.
144  void setRuntimeParam(const std::string &paramName, const std::string &paramValue,
145  const std::string &operatorName = "");
146 #endif //DOXYGEN_SKIP
147 
148  /// Get the leadership status of the server.
149  /// @throws StreamBaseException
150  LeadershipStatus getLeadershipStatus();
151 
152  /// Set the leadership status of the server.
153  /// @param leadershipStatus
154  /// @throws StreamBaseException
155  void setLeadershipStatus(LeadershipStatus leadershipStatus);
156 
157  /// Drains the application: waits until there are no more tuples at
158  /// all in the application and then shuts the application. Blocks until
159  /// this is complete.
160  /// has no effect if the server is not running
161  void drain(const std::string &containerName) ;
162 
163  ///
164  /// Get the settings for the client
165  ///
167  return _clientSettings;
168  }
169 
170  private:
171  void init();
172  // No copying.
173  StreamBaseAdminClient(const StreamBaseAdminClient&);
174 
175  // No copying.
176  StreamBaseAdminClient& operator = (const StreamBaseAdminClient&);
177 
178  std::vector<StreamBaseURI> _uris;
179  std::shared_ptr<sb_internal::Admin> _admin;
180  sb::ClientSettings _clientSettings;
181 };
182 
183 
184 SB_NAMESPACE_END;
185 #endif