Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

348 lines
5.1 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. node.c
  5. Abstract:
  6. Public interfaces for managing the nodes of a cluster
  7. Author:
  8. John Vert (jvert) 11-Jan-1996
  9. Revision History:
  10. --*/
  11. #include "apip.h"
  12. HNODE_RPC
  13. s_ApiOpenNode(
  14. IN handle_t IDL_handle,
  15. IN LPCWSTR lpszNodeName,
  16. OUT error_status_t *Status
  17. )
  18. /*++
  19. Routine Description:
  20. Opens a handle to an existing node object.
  21. Arguments:
  22. IDL_handle - RPC binding handle, not used.
  23. lpszNodeName - Supplies the name of the node to open.
  24. Status - Returns any error
  25. Return Value:
  26. A context handle to a node object if successful
  27. NULL otherwise.
  28. --*/
  29. {
  30. HNODE_RPC Node;
  31. PAPI_HANDLE Handle;
  32. if (ApiState != ApiStateOnline) {
  33. *Status = ERROR_SHARING_PAUSED;
  34. return(NULL);
  35. }
  36. Handle = LocalAlloc(LMEM_FIXED, sizeof(API_HANDLE));
  37. if (Handle == NULL) {
  38. *Status = ERROR_NOT_ENOUGH_MEMORY;
  39. return(NULL);
  40. }
  41. Node = OmReferenceObjectByName(ObjectTypeNode, lpszNodeName);
  42. if (Node != NULL) {
  43. *Status = ERROR_SUCCESS;
  44. } else {
  45. *Status = ERROR_CLUSTER_NODE_NOT_FOUND;
  46. LocalFree(Handle);
  47. return(NULL);
  48. }
  49. Handle->Type = API_NODE_HANDLE;
  50. Handle->Node = Node;
  51. Handle->Flags = 0;
  52. InitializeListHead(&Handle->NotifyList);
  53. return(Handle);
  54. }
  55. error_status_t
  56. s_ApiGetNodeId(
  57. IN HNODE_RPC hNode,
  58. OUT LPWSTR *pGuid
  59. )
  60. /*++
  61. Routine Description:
  62. Returns the unique identifier for a node.
  63. Arguments:
  64. hNode - Supplies the node whose identifer is to be returned
  65. pGuid - Returns the unique identifier. This memory must be freed on the
  66. client side.
  67. Return Value:
  68. ERROR_SUCCESS if successful
  69. Win32 error code otherwise.
  70. --*/
  71. {
  72. PNM_NODE Node;
  73. DWORD IdLen;
  74. LPCWSTR Id;
  75. API_ASSERT_INIT();
  76. VALIDATE_NODE(Node, hNode);
  77. Id = OmObjectId(Node);
  78. CL_ASSERT(Id != NULL);
  79. IdLen = (lstrlenW(Id)+1)*sizeof(WCHAR);
  80. *pGuid = MIDL_user_allocate(IdLen);
  81. if (*pGuid == NULL) {
  82. return(ERROR_NOT_ENOUGH_MEMORY);
  83. }
  84. CopyMemory(*pGuid, Id, IdLen);
  85. return(ERROR_SUCCESS);
  86. }
  87. error_status_t
  88. s_ApiCloseNode(
  89. IN OUT HNODE_RPC *phNode
  90. )
  91. /*++
  92. Routine Description:
  93. Closes an open node context handle.
  94. Arguments:
  95. Node - Supplies a pointer to the HNODE_RPC to be closed.
  96. Returns NULL
  97. Return Value:
  98. None.
  99. --*/
  100. {
  101. PNM_NODE Node;
  102. PAPI_HANDLE Handle;
  103. API_ASSERT_INIT();
  104. VALIDATE_NODE(Node, *phNode);
  105. Handle = (PAPI_HANDLE)*phNode;
  106. ApipRundownNotify(Handle);
  107. OmDereferenceObject(Node);
  108. LocalFree(*phNode);
  109. *phNode = NULL;
  110. return(ERROR_SUCCESS);
  111. }
  112. VOID
  113. HNODE_RPC_rundown(
  114. IN HNODE_RPC Node
  115. )
  116. /*++
  117. Routine Description:
  118. RPC rundown procedure for a HNODE_RPC. Just closes the handle.
  119. Arguments:
  120. Node - supplies the HNODE_RPC that is to be rundown.
  121. Return Value:
  122. None.
  123. --*/
  124. {
  125. s_ApiCloseNode(&Node);
  126. }
  127. error_status_t
  128. s_ApiGetNodeState(
  129. IN HNODE_RPC hNode,
  130. OUT DWORD *lpState
  131. )
  132. /*++
  133. Routine Description:
  134. Returns the current state of the specified node.
  135. Arguments:
  136. hNode - Supplies the node whose state is to be returned.
  137. lpState - Returns the current state of the node
  138. Return Value:
  139. ERROR_SUCCESS if successful
  140. Win32 error code otherwise
  141. --*/
  142. {
  143. PNM_NODE Node;
  144. API_ASSERT_INIT();
  145. VALIDATE_NODE(Node, hNode);
  146. // *lpState = NmGetNodeState( Node );
  147. *lpState = NmGetExtendedNodeState( Node );
  148. return( ERROR_SUCCESS );
  149. }
  150. error_status_t
  151. s_ApiPauseNode(
  152. IN HNODE_RPC hNode
  153. )
  154. /*++
  155. Routine Description:
  156. Pauses a node in the cluster
  157. Arguments:
  158. hNode - Supplies the node to be paused.
  159. Return Value:
  160. ERROR_SUCCESS if successful
  161. Win32 error code otherwise
  162. --*/
  163. {
  164. DWORD Status;
  165. PNM_NODE Node;
  166. API_ASSERT_INIT();
  167. VALIDATE_NODE(Node, hNode);
  168. Status = NmPauseNode( Node );
  169. return( Status );
  170. }
  171. error_status_t
  172. s_ApiResumeNode(
  173. IN HNODE_RPC hNode
  174. )
  175. /*++
  176. Routine Description:
  177. Resumes a node in the cluster
  178. Arguments:
  179. hNode - Supplies the node to be resumed.
  180. Return Value:
  181. ERROR_SUCCESS if successful
  182. Win32 error code otherwise
  183. --*/
  184. {
  185. DWORD Status;
  186. PNM_NODE Node;
  187. API_ASSERT_INIT();
  188. VALIDATE_NODE(Node, hNode);
  189. Status = NmResumeNode( Node );
  190. return( Status );
  191. }
  192. error_status_t
  193. s_ApiEvictNode(
  194. IN HNODE_RPC hNode
  195. )
  196. /*++
  197. Routine Description:
  198. Pauses a node in the cluster
  199. Arguments:
  200. hNode - Supplies the node to be evicted.
  201. Return Value:
  202. ERROR_SUCCESS if successful
  203. Win32 error code otherwise
  204. --*/
  205. {
  206. DWORD Status;
  207. PNM_NODE Node;
  208. API_ASSERT_INIT();
  209. VALIDATE_NODE(Node, hNode);
  210. Status = NmEvictNode( Node );
  211. return( Status );
  212. }