iad_instance.h 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. /*
  2. * ********************************************
  3. *
  4. * Licensed Materials - Property of IBM and/or HCL
  5. *
  6. * IBM Informix Dynamic Server
  7. * Copyright IBM Corporation 2009, 2016
  8. * (c) Copyright HCL Technologies Ltd. 2017. All Rights Reserved.
  9. *
  10. * ********************************************
  11. */
  12. #ifndef IAD_INSTANCE_H
  13. #define IAD_INSTANCE_H
  14. #include "API.h"
  15. /* Server Type definitions */
  16. #define DR 0x0
  17. #define ON 0x40
  18. #define OL 0x80
  19. #define SE 0xC0
  20. #define GRP 0x100
  21. /* Connection Type definitions */
  22. #define IPC 0x0
  23. #define SOC 0x10
  24. #define SQL 0x20
  25. #define TLI 0x30
  26. /* Network Type definitions */
  27. #define IMC 0x0
  28. #define MUX 0x2
  29. #define NMP 0x4
  30. #define SHM 0x6
  31. #define SPX 0x8
  32. #define SSL 0xA
  33. #define STR 0xC
  34. #define TCP 0xE
  35. /* Define maximum length of server connection protocol */
  36. #define PROTOCOL_LEN 8
  37. /* enumeration type for different types of data spaces */
  38. enum space_type
  39. {
  40. IAD_DBSPACE = 100,
  41. IAD_TEMPDBSPACE,
  42. IAD_SBSPACE,
  43. IAD_TEMPSBSPACE,
  44. /* TODO - extspace creation currently not supported */
  45. /* IAD_EXTSPACE, */
  46. IAD_BLOBSPACE
  47. };
  48. /* enumeration type for mirror status */
  49. enum mirror_status
  50. {
  51. IAD_MIRROR_OFF,
  52. IAD_MIRROR_ON
  53. };
  54. /* enumeration type for tempspace status */
  55. enum tmp_space_status
  56. {
  57. IAD_TEMPSPACE_OFF,
  58. IAD_TEMPSPACE_ON
  59. };
  60. /* enumeration type for log type */
  61. enum log_type
  62. {
  63. IAD_PHYSLOG = 0,
  64. IAD_LOGICALLOG
  65. };
  66. /* Instance Configuration API */
  67. /* Gets server environment information from memory. If environment
  68. information had not been written using iadSetEnvironment, value
  69. can't be retrieved
  70. Returns:
  71. IAD_E_NOERROR - success
  72. IAD_E_STRUCTURE_NOT_INITIALIZED - install structure is not initialized
  73. IAD_E_NULLPOINTER - current instance is null
  74. */
  75. EXPORT int STDCALL iadGetEnvironment(install_t *inst, const char *variable, char **value);
  76. /* Writes server environment into memory so that it
  77. can be later deployed
  78. Returns:
  79. IAD_E_NOERROR - success
  80. IAD_E_STRUCTURE_NOT_INITIALIZED - install structure is not initialized
  81. IAD_E_MEMORY_ALLOCATION_FAILURE - could not allocate memory
  82. */
  83. EXPORT int STDCALL iadSetEnvironment(install_t *inst, const char *variable, const char *value);
  84. /* Writes instance config file based on INFORMIXSERVER name
  85. * Creates .csh, .ksh for Unix
  86. * Creates .cmd file for Windows
  87. */
  88. EXPORT int STDCALL iadWriteEnv(install_t *inst);
  89. /* ENUM Connection {TCP PIPE SHM ...}
  90. * populates the connection_list for inst!
  91. */
  92. /* Support list of protocols
  93. Unix Windows
  94. onipcshm
  95. onipcstr
  96. onipcnmp
  97. ontlitcp
  98. onsoctcp onsoctcp
  99. onsocssl onsocssl
  100. ontlispx
  101. onsocimc
  102. ontliimc
  103. onsqlmux onsqlmux
  104. drsocssl drsocssl
  105. drsoctcp drsoctcp
  106. drtlitcp drtlitcp
  107. */
  108. enum conn_dbtype
  109. {
  110. on = 1,
  111. ol = 1,
  112. dr
  113. };
  114. enum conn_interface
  115. {
  116. ipc = 1,
  117. tli = 2,
  118. soc = 2,
  119. sql = 3
  120. };
  121. enum conn_network
  122. {
  123. shm = 1,
  124. str = 2,
  125. nmp = 3,
  126. spx = 4,
  127. imc = 5,
  128. ssl = 6,
  129. tcp = 7,
  130. mux = 8
  131. };
  132. /*
  133. retrieves a connection with the specified name/alias for the current instance
  134. servername: name/alias to look up
  135. line: pointer to the connection structure that was looked up. may be null if you do not want the pointer. not changed if alias is not found
  136. returns IAD_E_FAIL if no connections matched the specified name/alias
  137. returns IAD_E_NULLPOINTER if an instance has not been made current
  138. returns IAD_E_INVALID_PARAMETER if servername is null
  139. */
  140. EXPORT int STDCALL iadGetConnection(install_t *inst, const char *servername, const connection_t **line);
  141. EXPORT int STDCALL iadAddConnection(install_t *inst, const char * alias, CPROTOCOL connection_type, const char *hostname, unsigned short port, const char *service_name, const char *options);
  142. /* Update services file (if failed, write port number when creating sqlhosts)
  143. * Create sqlhosts
  144. * unix,
  145. * Dump file to $INFORMIXSQLHOSTS or $INFORMIXDIR/etc/sqlhosts as specified
  146. * in the environment
  147. * windows
  148. * write sqlhosts to registery.
  149. */
  150. EXPORT int STDCALL iadWriteConnection(install_t *inst);
  151. /* Read a sqlhosts file into the connection_list
  152. */
  153. EXPORT int STDCALL iadReadConnections(install_t *inst, const char *file);
  154. #ifdef WIN32
  155. /*
  156. * sqlhost can be "\\machine" for remote registery NULL for local registery
  157. * and a file name for file
  158. */
  159. EXPORT int STDCALL iadWindowsReadConnections(install_t *is, const char *sqlhost);
  160. /*
  161. * reghost can be "\\machine" for remote registery NULL for local registery
  162. */
  163. EXPORT int STDCALL iadReadConnectionsRegistery(install_t *is, const char *reghost);
  164. #endif /* WIN32 */
  165. /* Converts a protocol flag into a corresponding protocol string
  166. For example:
  167. iadMapProtocol(ON|SOC|TCP) returns "onsoctcp"
  168. */
  169. EXPORT char * STDCALL iadMapProtocol(CPROTOCOL);
  170. /* Converts a string into a corresponding protocol flag that can
  171. be tested. For example:
  172. iadMapStringToProtocol("onsoctcp") returns (ON|SOC|TCP)
  173. */
  174. EXPORT CPROTOCOL STDCALL iadMapStringtoProtocol(char *proto);
  175. /* Changes a config pramater, */
  176. EXPORT int STDCALL iadSetConfig(install_t *inst, const char *label, const char *value, const char *comment);
  177. /* adds a config pramater, for use with pramaters that can be specified twice */
  178. EXPORT int STDCALL iadAddConfig(install_t *inst, const char *label, const char *value, const char *comment);
  179. /* Dump file to $INFORMIXDIR/etc/$ONCONFIG specified in the environment */
  180. EXPORT int STDCALL iadWriteConfig(install_t *inst);
  181. EXPORT int STDCALL iadReadConfig(install_t *inst, const char *file);
  182. /* Reads server configuration information from the configLines
  183. structure. This function reads information added to the configLines
  184. structure using iadSetConfig() or iadAddConfig() */
  185. EXPORT int STDCALL iadGetConfig(install_t *inst, const char *label, char **value, configLines_t **cfg_out);
  186. /* Instance Control API */
  187. /* State could be quiescient, multi-user, single-user, blocked, unblocked */
  188. /* Options could be verbose mode or other supported feature */
  189. EXPORT int STDCALL iadInitInstance(install_t *inst, int options);
  190. EXPORT int STDCALL iadStartInstance(install_t *inst, int options);
  191. /*
  192. StopInstance()
  193. Stops the instances
  194. input:
  195. nstall_t *installStructure,
  196. char *InstanceName,
  197. return codes:
  198. IAD_E_NOERROR when there are no errors.
  199. IAD_E_FAIL when function fails
  200. */
  201. EXPORT int STDCALL iadStopInstance(install_t *is, const char *instance);
  202. /*
  203. iadRemoveInstance()
  204. Removes the chunk files, environment files, message logs
  205. Input: install_t *installStructure
  206. char *InstanceName
  207. return codes:
  208. IAD_E_NOERROR when there are no errors.
  209. IAD_E_FAIL when the function fails.
  210. */
  211. EXPORT int STDCALL iadRemoveInstance(install_t *inst, const char *instance);
  212. /*
  213. iadRemoveInstallationInstances()
  214. Removes all of the instances from a given installation location
  215. Input: install_t *installStructure,
  216. char *infxDir - path to remove instances from
  217. return codes:
  218. IAD_E_NOERROR when there are no errors.
  219. IAD_E_FAIL when the function fails
  220. */
  221. EXPORT int STDCALL iadRemoveInstallationInstances(install_t *is, const char *infxDir);
  222. EXPORT int STDCALL iadChangeMode(install_t *inst, int state, int options);
  223. EXPORT int STDCALL iadGetInstanceStatus (install_t *inst);
  224. /* Space Provisioning API */
  225. EXPORT int STDCALL iadCreateDBSpace(
  226. install_t *inst,
  227. const char *name,
  228. const char *path,
  229. const char *size,
  230. const char *offset,
  231. const char *pagesize,
  232. const char *mirrorpath,
  233. const char *mirroroffset,
  234. const char *f_extsize,
  235. const char *n_extsize,
  236. int tmp_dbs_flg
  237. );
  238. /*if tmp_dbs_flg is set, DBSPACETEMP config param must*/
  239. /*be set to the temp dbspace name*/
  240. /*This must be done before the server is started*/
  241. EXPORT int STDCALL iadCreateSBSpace(
  242. install_t *is,
  243. const char *name,
  244. const char *path,
  245. const char *size,
  246. const char *offset,
  247. const char *mirrorpath,
  248. const char *mirroroffset,
  249. const char *metadataoffset,
  250. const char *metadatasize,
  251. int tmp_sbs_flg,
  252. const char *def_specs
  253. );
  254. /* update ONCONFIG sbspace, syssbspace with first sbspace created */
  255. /* TODO - currently not supported by IDS Admin API */
  256. /*
  257. EXPORT int STDCALL iadCreateEXTSpace(
  258. install_t *is,
  259. const char *name,
  260. const char *path,
  261. const char *size,
  262. const char *offset
  263. );
  264. */
  265. EXPORT int STDCALL iadCreateBLOBSpace(
  266. install_t *is,
  267. const char *name,
  268. const char *path,
  269. const char *size,
  270. const char *offset,
  271. unsigned int pageunit,
  272. const char *mirrorpath,
  273. const char *mirroroffset
  274. );
  275. EXPORT int STDCALL iadCreateSpace(
  276. install_t *is,
  277. int type,
  278. const char *name,
  279. const char *path,
  280. const char *size,
  281. const char *offset
  282. );
  283. /* create dbspace files, change permissions.
  284. * create links to dbspace files under $INFORMIXDIR/...
  285. * create admin api sql
  286. */
  287. EXPORT int STDCALL iadCreateMirrorSpace(
  288. install_t *is,
  289. const char *name,
  290. const char *mirrorpath,
  291. const char *mirroroffset
  292. );
  293. EXPORT int STDCALL iadDeploySpaces(install_t *inst);
  294. EXPORT int STDCALL iadDeployDemoInstance(install_t *inst);
  295. char *randomString(char *dst, int size);
  296. /* Move logical logs from rootdbs to named dbspace
  297. * Move Physical log to named dbspace from any dbspace.
  298. * If no logs are left in the root dbspace add new Logs. */
  299. EXPORT int STDCALL iadCreateLog(
  300. install_t *inst,
  301. int logtype,
  302. const char *targetspace,
  303. unsigned int number,
  304. const char *size
  305. );
  306. /* Deploy logs using information in log struct */
  307. EXPORT int STDCALL iadDeployLogs(install_t *inst);
  308. char *map_protocol(CPROTOCOL proto);
  309. EXPORT int STDCALL iadInitInstanceStruct(install_t *inst);
  310. EXPORT int STDCALL iadDeployJsonListenerFile(install_t *is);
  311. EXPORT int STDCALL iadOpenSysadminInDeploy(install_t *is);
  312. EXPORT int STDCALL iadCloseSysadminInDeploy(install_t *is);
  313. EXPORT int STDCALL iadGrantDBAonLocalInstance(install_t *is);
  314. #endif /* IAD_INSTANCE_H */