Source code of Windows XP (NT5)
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.

168 lines
4.0 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. holdrpc.c
  5. Abstract:
  6. utility to test hold intracluster RPC feature
  7. Author:
  8. Charlie Wickham (charlwi) 22-Jul-1999
  9. Environment:
  10. User mode
  11. Revision History:
  12. --*/
  13. #define UNICODE 1
  14. #define _UNICODE 1
  15. #define CMDWINDOW
  16. #include "cluster.h"
  17. #include "api_rpc.h"
  18. int __cdecl
  19. wmain(
  20. int argc,
  21. WCHAR *argv[]
  22. )
  23. /*++
  24. Routine Description:
  25. main routine for utility. first arg is sleep time in seconds. 2nd through
  26. Nth arg are node names of cluster nodes
  27. Arguments:
  28. standard command line args
  29. Return Value:
  30. 0 if it worked successfully
  31. --*/
  32. {
  33. DWORD status;
  34. PWCHAR lpszClusterName;
  35. WCHAR *strBinding = NULL;
  36. RPC_BINDING_HANDLE rpcHandle[10];
  37. DWORD numNodes;
  38. DWORD sleepTime;
  39. DWORD i;
  40. sleepTime = _wtoi( argv[1] );
  41. argc -= 2;
  42. numNodes = 0;
  43. while ( argc-- ) {
  44. lpszClusterName = argv[2 + numNodes];
  45. printf("Contacting node %ws\n", lpszClusterName );
  46. //
  47. // Determine which node we should connect to. If someone has
  48. // passed in NULL, we know we can connect to the cluster service
  49. // over LPC. Otherwise, use RPC.
  50. //
  51. if ((lpszClusterName == NULL) ||
  52. (lpszClusterName[0] == '\0')) {
  53. status = RpcStringBindingComposeW(L"b97db8b2-4c63-11cf-bff6-08002be23f2f",
  54. L"ncalrpc",
  55. NULL,
  56. L"clusapi",
  57. NULL,
  58. &strBinding);
  59. if (status != RPC_S_OK) {
  60. goto error_exit;
  61. }
  62. status = RpcBindingFromStringBindingW(strBinding, &rpcHandle[numNodes]);
  63. RpcStringFreeW(&strBinding);
  64. if (status != RPC_S_OK) {
  65. goto error_exit;
  66. }
  67. } else {
  68. //
  69. // Try to connect directly to the cluster.
  70. //
  71. status = RpcStringBindingComposeW(L"b97db8b2-4c63-11cf-bff6-08002be23f2f",
  72. L"ncadg_ip_udp",
  73. (LPWSTR)lpszClusterName,
  74. NULL,
  75. NULL,
  76. &strBinding);
  77. if (status != RPC_S_OK) {
  78. goto error_exit;
  79. }
  80. status = RpcBindingFromStringBindingW(strBinding, &rpcHandle[numNodes]);
  81. RpcStringFreeW(&strBinding);
  82. if (status != RPC_S_OK) {
  83. goto error_exit;
  84. }
  85. //
  86. // Resolve the binding handle endpoint
  87. //
  88. status = RpcEpResolveBinding(rpcHandle[numNodes],
  89. clusapi_v2_0_c_ifspec);
  90. if (status != RPC_S_OK) {
  91. goto error_exit;
  92. }
  93. }
  94. status = RpcBindingSetAuthInfoW(rpcHandle[numNodes],
  95. NULL,
  96. RPC_C_AUTHN_LEVEL_CONNECT,
  97. RPC_C_AUTHN_WINNT,
  98. NULL,
  99. RPC_C_AUTHZ_NAME);
  100. if (status != RPC_S_OK) {
  101. goto error_exit;
  102. }
  103. ++numNodes;
  104. }
  105. //
  106. // issue hold
  107. //
  108. for( i = 0; i < numNodes; ++i ) {
  109. status = ApiHoldRpcCalls(rpcHandle[i]);
  110. printf("Hold status for node %u = %u\n", i, status );
  111. }
  112. Sleep( sleepTime * 1000 );
  113. //
  114. // issue release
  115. //
  116. for( i = 0; i < numNodes; ++i ) {
  117. status = ApiReleaseRpcCalls(rpcHandle[i]);
  118. printf("Release status for node %u = %u\n", i, status );
  119. }
  120. for( i = 0; i < numNodes; ++i ) {
  121. RpcBindingFree( &rpcHandle[i] );
  122. }
  123. return 0;
  124. error_exit:
  125. printf("died: status = %u\n", status );
  126. return status;
  127. } // wmain
  128. /* end holdrpc.c */