4.2 Moving a Group
The following example illustrates how a protocol client ensures that a specific group is owned by a specific node, moving the group to that node if necessary. Assume that in this example, the client is managing a group that has the well-known name "Application Group". Assume that there are three nodes in the cluster that have the names "NodeA", "NodeB", and "NodeC", and all nodes are currently active. The client needs the group to be owned by NodeB.
The following diagram depicts the message flow.
Figure 7: Message flow: Moving a group
The client next opens a context handle to the group by calling ApiOpenGroup (section 22.214.171.124.42 for protocol version 2, or 126.96.36.199.42 for protocol version 3) with the lpszGroupName parameter set to the null-terminated Unicode string "Application Group".
The client then determines which node currently owns the group by calling ApiGetGroupState (section 188.8.131.52.46 for protocol version 2, or 184.108.40.206.46 for protocol version 3). During this call the client passes the HGROUP_RPC context handle that was just obtained from ApiOpenGroup. Assume for this example that, in response to the ApiGetGroupState method, the server returns a current node name of "NodeA". Because the client needs the group to be owned by NodeB, the client now needs to move the group.
The client obtains an HNODE_RPC context handle for NodeB by calling ApiOpenNode (section 220.127.116.11.67 for protocol version 2, or 18.104.22.168.67 for protocol version 3) and setting the lpszNodeName parameter to the null-terminated Unicode string "NodeB". Then the client calls ApiMoveGroupToNode (section 22.214.171.124.53 for protocol version 2, or 126.96.36.199.53 for protocol version 3) indicating the group that is identified by the HGROUP_RPC and the destination node indicated by the HNODE_RPC.
Assume that the server returns status 0x000003E5 (ERROR_IO_PENDING), but the client is waiting until the move is complete. So the client polls by calling ApiGetGroupState every five seconds until the group is no longer in state ClusterGroupPending. Assuming that the group is now in state ClusterGroupOnline, the move is complete. If the group were in ClusterGroupFailed, the client could expect recovery action to be attempted to bring all resources in the group to their persistent states.