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.

142 lines
4.3 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1999-2000 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // TestEvict.cpp
  7. //
  8. // Description:
  9. // Main file for the test harness executable.
  10. // Initializes tracing, parses command line and actually call the
  11. // IClusCfgEvictCleanup functions.
  12. //
  13. // Documentation:
  14. // No documention for the test harness.
  15. //
  16. // Maintained By:
  17. // Vij Vasu (Vvasu) 04-AUG-2000
  18. //
  19. //////////////////////////////////////////////////////////////////////////////
  20. //////////////////////////////////////////////////////////////////////////////
  21. // Include Files
  22. //////////////////////////////////////////////////////////////////////////////
  23. #include "pch.h"
  24. #include <stdio.h>
  25. #include <objbase.h>
  26. #include <limits.h>
  27. #include <ClusCfgGuids.h>
  28. // Show help for this executable.
  29. void ShowUsage()
  30. {
  31. wprintf( L"The syntax of this command is:\n" );
  32. wprintf( L"\nTestEvict.exe [computer-name]\n" );
  33. }
  34. // The main function for this program.
  35. int __cdecl wmain( int argc, WCHAR *argv[] )
  36. {
  37. HRESULT hr = S_OK;
  38. // Initialize COM
  39. CoInitializeEx( 0, COINIT_MULTITHREADED );
  40. wprintf( L"\nInitiates evict processing on a computer.\n" );
  41. wprintf( L"Note: This computer must have Whistler (and the cluster binaries) for this command to work.\n" );
  42. do
  43. {
  44. CSmartIfacePtr< IClusCfgEvictCleanup > spEvict;
  45. if ( ( argc < 1 ) || ( argc > 2 ) )
  46. {
  47. ShowUsage();
  48. break;
  49. }
  50. {
  51. IClusCfgEvictCleanup * cceTemp = NULL;
  52. hr = CoCreateInstance(
  53. CLSID_ClusCfgEvictCleanup
  54. , NULL
  55. , CLSCTX_LOCAL_SERVER
  56. , __uuidof( IClusCfgEvictCleanup )
  57. , reinterpret_cast< void ** >( &cceTemp )
  58. );
  59. if ( FAILED( hr ) )
  60. {
  61. wprintf( L"Error %#x occurred trying to create the ClusCfgEvict component on the local machine.\n", hr );
  62. break;
  63. }
  64. // Store the retrieved pointer in a smart pointer for safe release.
  65. spEvict.Attach( cceTemp );
  66. }
  67. // Check if a computer name is specified.
  68. if ( argc == 2 )
  69. {
  70. CSmartIfacePtr< ICallFactory > spCallFactory;
  71. CSmartIfacePtr< AsyncIClusCfgEvictCleanup > spAsyncEvict;
  72. wprintf( L"Attempting to asynchronously initiate evict cleanup on computer '%s'.\n", argv[1] );
  73. hr = spCallFactory.HrQueryAndAssign( spEvict.PUnk() );
  74. if ( FAILED( hr ) )
  75. {
  76. wprintf( L"Error %#x occurred trying to create a call factory.\n", hr );
  77. break;
  78. }
  79. {
  80. AsyncIClusCfgEvictCleanup * paicceAsyncEvict = NULL;
  81. hr = spCallFactory->CreateCall(
  82. __uuidof( paicceAsyncEvict )
  83. , NULL
  84. , __uuidof( paicceAsyncEvict )
  85. , reinterpret_cast< IUnknown ** >( &paicceAsyncEvict )
  86. );
  87. if ( FAILED( hr ) )
  88. {
  89. wprintf( L"Error %#x occurred trying to get a pointer to the asynchronous evict interface.\n", hr );
  90. break;
  91. }
  92. spAsyncEvict.Attach( paicceAsyncEvict );
  93. }
  94. hr = spAsyncEvict->Begin_CleanupRemote( argv[ 1 ] );
  95. if ( FAILED( hr ) )
  96. {
  97. wprintf( L"Error %#x occurred trying to initiate asynchronous cleanup on remote computer.\n", hr );
  98. break;
  99. }
  100. }
  101. else
  102. {
  103. wprintf( L"Attempting evict cleanup on this computer.\n" );
  104. hr = spEvict->CleanupLocal( FALSE );
  105. }
  106. if ( FAILED( hr ) )
  107. {
  108. wprintf( L"Error %#x occurred trying to initiate evict processing.\n", hr );
  109. break;
  110. }
  111. wprintf( L"Evict processing successfully initiated.\n", hr );
  112. }
  113. while( false ); // dummy do-while loop to avoid gotos.
  114. CoUninitialize();
  115. return hr;
  116. }