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.

1386 lines
31 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2001-2002 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // CUnknownQuorum.cpp
  7. //
  8. // Description:
  9. // This file contains the definition of the CUnknownQuorum class.
  10. //
  11. // The class CUnknownQuorum represents a cluster quorum
  12. // device. It implements the IClusCfgManagedResourceInfo interface.
  13. //
  14. // Maintained By:
  15. // Galen Barbee (GalenB) 18-DEC-2000
  16. //
  17. //////////////////////////////////////////////////////////////////////////////
  18. //////////////////////////////////////////////////////////////////////////////
  19. // Include Files
  20. //////////////////////////////////////////////////////////////////////////////
  21. #include "Pch.h"
  22. #include "CUnknownQuorum.h"
  23. //////////////////////////////////////////////////////////////////////////////
  24. // Constant Definitions
  25. //////////////////////////////////////////////////////////////////////////////
  26. DEFINE_THISCLASS( "CUnknownQuorum" );
  27. //*************************************************************************//
  28. /////////////////////////////////////////////////////////////////////////////
  29. // CUnknownQuorum class
  30. /////////////////////////////////////////////////////////////////////////////
  31. //////////////////////////////////////////////////////////////////////////////
  32. //++
  33. //
  34. // CUnknownQuorum::S_HrCreateInstance
  35. //
  36. // Description:
  37. // Create a CUnknownQuorum instance.
  38. //
  39. // Arguments:
  40. // None.
  41. //
  42. // Return Values:
  43. // Pointer to CUnknownQuorum instance.
  44. //
  45. //--
  46. //////////////////////////////////////////////////////////////////////////////
  47. HRESULT
  48. CUnknownQuorum::S_HrCreateInstance( IUnknown ** ppunkOut )
  49. {
  50. TraceFunc( "" );
  51. HRESULT hr = S_OK;
  52. CUnknownQuorum * puq = NULL;
  53. if ( ppunkOut == NULL )
  54. {
  55. hr = THR( E_POINTER );
  56. goto Cleanup;
  57. } // if:
  58. puq = new CUnknownQuorum();
  59. if ( puq == NULL )
  60. {
  61. hr = THR( E_OUTOFMEMORY );
  62. goto Cleanup;
  63. } // if: error allocating object
  64. hr = THR( puq->HrInit( NULL ) );
  65. if ( FAILED( hr ) )
  66. {
  67. goto Cleanup;
  68. } // if: HrInit() failed
  69. hr = THR( puq->TypeSafeQI( IUnknown, ppunkOut ) );
  70. if ( FAILED( hr ) )
  71. {
  72. goto Cleanup;
  73. } // if: QI failed
  74. Cleanup:
  75. if ( FAILED( hr ) )
  76. {
  77. LogMsg( L"[SRV] CUnknownQuorum::S_HrCreateInstance() failed. (hr = %#08x)", hr );
  78. } // if:
  79. if ( puq != NULL )
  80. {
  81. puq->Release();
  82. } // if:
  83. HRETURN( hr );
  84. } //*** CUnknownQuorum::S_HrCreateInstance
  85. //////////////////////////////////////////////////////////////////////////////
  86. //++
  87. //
  88. // CUnknownQuorum::S_HrCreateInstance
  89. //
  90. // Description:
  91. // Create a CUnknownQuorum instance.
  92. //
  93. // Arguments:
  94. // None.
  95. //
  96. // Return Values:
  97. // Pointer to CUnknownQuorum instance.
  98. //
  99. //--
  100. //////////////////////////////////////////////////////////////////////////////
  101. HRESULT
  102. CUnknownQuorum::S_HrCreateInstance(
  103. LPCWSTR pcszNameIn
  104. , BOOL fMakeQuorumIn
  105. , IUnknown ** ppunkOut
  106. )
  107. {
  108. TraceFunc( "" );
  109. HRESULT hr = S_OK;
  110. CUnknownQuorum * puq = NULL;
  111. if ( ppunkOut == NULL )
  112. {
  113. hr = THR( E_POINTER );
  114. goto Cleanup;
  115. } // if:
  116. puq = new CUnknownQuorum();
  117. if ( puq == NULL )
  118. {
  119. hr = THR( E_OUTOFMEMORY );
  120. goto Cleanup;
  121. } // if: error allocating object
  122. hr = THR( puq->HrInit( pcszNameIn, fMakeQuorumIn ) );
  123. if ( FAILED( hr ) )
  124. {
  125. goto Cleanup;
  126. } // if: HrInit() failed
  127. hr = THR( puq->TypeSafeQI( IUnknown, ppunkOut ) );
  128. if ( FAILED( hr ) )
  129. {
  130. goto Cleanup;
  131. } // if: QI failed
  132. Cleanup:
  133. if ( FAILED( hr ) )
  134. {
  135. LogMsg( L"[SRV] CUnknownQuorum::S_HrCreateInstance() failed. (hr = %#08x)", hr );
  136. } // if:
  137. if ( puq != NULL )
  138. {
  139. puq->Release();
  140. } // if:
  141. HRETURN( hr );
  142. } //*** CUnknownQuorum::S_HrCreateInstance
  143. //*************************************************************************//
  144. /////////////////////////////////////////////////////////////////////////////
  145. // CUnknownQuorum class -- Private Methods.
  146. /////////////////////////////////////////////////////////////////////////////
  147. //////////////////////////////////////////////////////////////////////////////
  148. //++
  149. //
  150. // CUnknownQuorum::CUnknownQuorum
  151. //
  152. // Description:
  153. // Constructor of the CUnknownQuorum class. This initializes
  154. // the m_cRef variable to 1 instead of 0 to account of possible
  155. // QueryInterface failure in DllGetClassObject.
  156. //
  157. // Arguments:
  158. // None.
  159. //
  160. // Return Value:
  161. // None.
  162. //
  163. // Remarks:
  164. // None.
  165. //
  166. //--
  167. //////////////////////////////////////////////////////////////////////////////
  168. CUnknownQuorum::CUnknownQuorum( void )
  169. : m_cRef( 1 )
  170. {
  171. TraceFunc( "" );
  172. // Increment the count of components in memory so the DLL hosting this
  173. // object cannot be unloaded.
  174. InterlockedIncrement( &g_cObjects );
  175. Assert( m_lcid == 0 );
  176. Assert( m_picccCallback == NULL );
  177. Assert( m_fIsQuorum == FALSE );
  178. Assert( m_fIsQuorumCapable == FALSE );
  179. Assert( m_fIsMultiNodeCapable == FALSE );
  180. Assert( m_fIsManaged == FALSE );
  181. Assert( m_fIsManagedByDefault == FALSE );
  182. Assert( m_bstrName == NULL );
  183. TraceFuncExit();
  184. } //*** CUnknownQuorum::CUnknownQuorum
  185. //////////////////////////////////////////////////////////////////////////////
  186. //++
  187. //
  188. // CUnknownQuorum::~CUnknownQuorum
  189. //
  190. // Description:
  191. // Desstructor of the CUnknownQuorum class.
  192. //
  193. // Arguments:
  194. // None.
  195. //
  196. // Return Value:
  197. // None.
  198. //
  199. // Remarks:
  200. // None.
  201. //
  202. //--
  203. //////////////////////////////////////////////////////////////////////////////
  204. CUnknownQuorum::~CUnknownQuorum( void )
  205. {
  206. TraceFunc( "" );
  207. if ( m_picccCallback != NULL )
  208. {
  209. m_picccCallback->Release();
  210. } // if:
  211. TraceSysFreeString( m_bstrName );
  212. // There's going to be one less component in memory. Decrement component count.
  213. InterlockedDecrement( &g_cObjects );
  214. TraceFuncExit();
  215. } //*** CUnknownQuorum::~CUnknownQuorum
  216. //////////////////////////////////////////////////////////////////////////////
  217. //++
  218. //
  219. // CUnknownQuorum::HrInit
  220. //
  221. // Description:
  222. // Initialize this component.
  223. //
  224. // Arguments:
  225. // None.
  226. //
  227. // Return Value:
  228. //
  229. //
  230. // Remarks:
  231. // None.
  232. //
  233. //--
  234. //////////////////////////////////////////////////////////////////////////////
  235. HRESULT
  236. CUnknownQuorum::HrInit(
  237. LPCWSTR pcszNameIn
  238. , BOOL fMakeQuorumIn //= FALSE
  239. )
  240. {
  241. TraceFunc( "" );
  242. HRESULT hr = S_OK;
  243. // IUnknown
  244. Assert( m_cRef == 1 );
  245. //
  246. // If we are proxying for the quorum ( fMakeQuorumIn == TRUE ) then we are:
  247. // The quorum.
  248. // Manageable.
  249. // Managed.
  250. // Since we know nothing about the unknown quorum's multi-node capbility
  251. // then we will assume it is multi-node capable since most quorum
  252. // resources are.
  253. //
  254. // Since this is a quorum resourc we will always be Quorum capable by
  255. // default.
  256. //
  257. m_fIsQuorum = fMakeQuorumIn;
  258. m_fIsManagedByDefault = fMakeQuorumIn;
  259. m_fIsManaged = fMakeQuorumIn;
  260. m_fIsMultiNodeCapable = fMakeQuorumIn;
  261. m_fIsQuorumCapable = TRUE;
  262. //
  263. // If we were handed a name then use it -- if we are proxying for an
  264. // unknown quorum resource. If we are just a dummy resource then don't
  265. // accept the passed in name.
  266. //
  267. if ( ( pcszNameIn != NULL ) && ( m_fIsQuorum == TRUE ) )
  268. {
  269. m_bstrName = TraceSysAllocString( pcszNameIn );
  270. if ( m_bstrName == NULL )
  271. {
  272. hr = THR( E_OUTOFMEMORY );
  273. } // if:
  274. LogMsg( L"[SRV] Initializing the name of the UnKnown Quorum to %ws.", m_bstrName );
  275. } // if:
  276. else
  277. {
  278. hr = THR( HrLoadStringIntoBSTR( g_hInstance, IDS_UNKNOWN_QUORUM, &m_bstrName ) );
  279. } // else:
  280. HRETURN( hr );
  281. } //*** CUnknownQuorum::HrInit
  282. //*************************************************************************//
  283. /////////////////////////////////////////////////////////////////////////////
  284. // CUnknownQuorum -- IUknkown interface.
  285. /////////////////////////////////////////////////////////////////////////////
  286. //////////////////////////////////////////////////////////////////////////////
  287. //++
  288. //
  289. // CUnknownQuorum::AddRef
  290. //
  291. // Description:
  292. // Increment the reference count of this object by one.
  293. //
  294. // Arguments:
  295. // None.
  296. //
  297. // Return Value:
  298. // The new reference count.
  299. //
  300. // Remarks:
  301. // None.
  302. //
  303. //--
  304. //////////////////////////////////////////////////////////////////////////////
  305. STDMETHODIMP_( ULONG )
  306. CUnknownQuorum::AddRef( void )
  307. {
  308. TraceFunc( "[IUnknown]" );
  309. InterlockedIncrement( &m_cRef );
  310. CRETURN( m_cRef );
  311. } //*** CUnknownQuorum::AddRef
  312. //////////////////////////////////////////////////////////////////////////////
  313. //++
  314. //
  315. // CUnknownQuorum::Release
  316. //
  317. // Description:
  318. // Decrement the reference count of this object by one.
  319. //
  320. // Arguments:
  321. // None.
  322. //
  323. // Return Value:
  324. // The new reference count.
  325. //
  326. // Remarks:
  327. // None.
  328. //
  329. //--
  330. //////////////////////////////////////////////////////////////////////////////
  331. STDMETHODIMP_( ULONG )
  332. CUnknownQuorum::Release( void )
  333. {
  334. TraceFunc( "[IUnknown]" );
  335. LONG cRef;
  336. cRef = InterlockedDecrement( &m_cRef );
  337. if ( cRef == 0 )
  338. {
  339. TraceDo( delete this );
  340. } // if: reference count equal to zero
  341. CRETURN( cRef );
  342. } //*** CUnknownQuorum::Release
  343. //////////////////////////////////////////////////////////////////////////////
  344. //++
  345. //
  346. // CUnknownQuorum::QueryInterface
  347. //
  348. // Description:
  349. // Query this object for the passed in interface.
  350. //
  351. // Arguments:
  352. // riidIn
  353. // Id of interface requested.
  354. //
  355. // ppvOut
  356. // Pointer to the requested interface.
  357. //
  358. // Return Value:
  359. // S_OK
  360. // If the interface is available on this object.
  361. //
  362. // E_NOINTERFACE
  363. // If the interface is not available.
  364. //
  365. // E_POINTER
  366. // ppvOut was NULL.
  367. //
  368. // Remarks:
  369. // None.
  370. //
  371. //--
  372. //////////////////////////////////////////////////////////////////////////////
  373. STDMETHODIMP
  374. CUnknownQuorum::QueryInterface(
  375. REFIID riidIn
  376. , void ** ppvOut
  377. )
  378. {
  379. TraceQIFunc( riidIn, ppvOut );
  380. HRESULT hr = S_OK;
  381. //
  382. // Validate arguments.
  383. //
  384. Assert( ppvOut != NULL );
  385. if ( ppvOut == NULL )
  386. {
  387. hr = THR( E_POINTER );
  388. goto Cleanup;
  389. }
  390. //
  391. // Handle known interfaces.
  392. //
  393. if ( IsEqualIID( riidIn, IID_IUnknown ) )
  394. {
  395. *ppvOut = static_cast< IClusCfgManagedResourceInfo * >( this );
  396. } // if: IUnknown
  397. else if ( IsEqualIID( riidIn, IID_IClusCfgManagedResourceInfo ) )
  398. {
  399. *ppvOut = TraceInterface( __THISCLASS__, IClusCfgManagedResourceInfo, this, 0 );
  400. } // else if: IClusCfgManagedResourceInfo
  401. else if ( IsEqualIID( riidIn, IID_IClusCfgInitialize ) )
  402. {
  403. *ppvOut = TraceInterface( __THISCLASS__, IClusCfgInitialize, this, 0 );
  404. } // else if: IClusCfgInitialize
  405. else if ( IsEqualIID( riidIn, IID_IClusCfgManagedResourceCfg ) )
  406. {
  407. *ppvOut = TraceInterface( __THISCLASS__, IClusCfgManagedResourceCfg, this, 0 );
  408. } // else if: IClusCfgManagedResourceCfg
  409. else if ( IsEqualIID( riidIn, IID_IClusCfgVerifyQuorum ) )
  410. {
  411. *ppvOut = TraceInterface( __THISCLASS__, IClusCfgVerifyQuorum, this, 0 );
  412. } // else if: IClusCfgVerifyQuorum
  413. else
  414. {
  415. *ppvOut = NULL;
  416. hr = E_NOINTERFACE;
  417. }
  418. //
  419. // Add a reference to the interface if successful.
  420. //
  421. if ( SUCCEEDED( hr ) )
  422. {
  423. ((IUnknown *) *ppvOut)->AddRef();
  424. } // if: success
  425. Cleanup:
  426. QIRETURN_IGNORESTDMARSHALLING2(
  427. hr
  428. , riidIn
  429. , IID_IEnumClusCfgPartitions
  430. , IID_IClusCfgManagedResourceData
  431. );
  432. } //*** CUnknownQuorum::QueryInterface
  433. //*************************************************************************//
  434. /////////////////////////////////////////////////////////////////////////////
  435. // CUnknownQuorum -- IClusCfgInitialize interface.
  436. /////////////////////////////////////////////////////////////////////////////
  437. //////////////////////////////////////////////////////////////////////////////
  438. //++
  439. //
  440. // CUnknownQuorum::Initialize
  441. //
  442. // Description:
  443. // Initialize this component.
  444. //
  445. // Arguments:
  446. // IN IUknown * punkCallbackIn
  447. //
  448. // IN LCID lcidIn
  449. //
  450. // Return Value:
  451. // S_OK
  452. // Success
  453. //
  454. // Remarks:
  455. // None.
  456. //
  457. //--
  458. //////////////////////////////////////////////////////////////////////////////
  459. STDMETHODIMP
  460. CUnknownQuorum::Initialize(
  461. IUnknown * punkCallbackIn,
  462. LCID lcidIn
  463. )
  464. {
  465. TraceFunc( "[IClusCfgInitialize]" );
  466. Assert( m_picccCallback == NULL );
  467. HRESULT hr = S_OK;
  468. m_lcid = lcidIn;
  469. if ( punkCallbackIn == NULL )
  470. {
  471. hr = THR( E_POINTER );
  472. goto Cleanup;
  473. } // if:
  474. hr = THR( punkCallbackIn->TypeSafeQI( IClusCfgCallback, &m_picccCallback ) );
  475. Cleanup:
  476. HRETURN( hr );
  477. } //*** CUnknownQuorum::Initialize
  478. //*************************************************************************//
  479. /////////////////////////////////////////////////////////////////////////////
  480. // CUnknownQuorum -- IClusCfgManagedResourceInfo interface.
  481. /////////////////////////////////////////////////////////////////////////////
  482. //////////////////////////////////////////////////////////////////////////////
  483. //++
  484. //
  485. // CUnknownQuorum::GetUID
  486. //
  487. // Description:
  488. //
  489. // Arguments:
  490. //
  491. // Return Value:
  492. //
  493. // Remarks:
  494. // None.
  495. //
  496. //--
  497. //////////////////////////////////////////////////////////////////////////////
  498. STDMETHODIMP
  499. CUnknownQuorum::GetUID( BSTR * pbstrUIDOut )
  500. {
  501. TraceFunc( "[IClusCfgManagedResourceInfo]" );
  502. HRESULT hr = S_OK;
  503. if ( pbstrUIDOut == NULL )
  504. {
  505. hr = THR( E_POINTER );
  506. STATUS_REPORT_REF( TASKID_Major_Find_Devices, TASKID_Minor_UnknownQuorum_GetUID_Pointer, IDS_ERROR_NULL_POINTER, IDS_ERROR_NULL_POINTER_REF, hr );
  507. goto Cleanup;
  508. } // if:
  509. *pbstrUIDOut = SysAllocString( g_szUnknownQuorumUID );
  510. if ( *pbstrUIDOut == NULL )
  511. {
  512. hr = THR( E_OUTOFMEMORY );
  513. STATUS_REPORT_REF( TASKID_Major_Find_Devices, TASKID_Minor_UnknownQuorum_GetUID_Memory, IDS_ERROR_OUTOFMEMORY, IDS_ERROR_OUTOFMEMORY_REF, hr );
  514. } // if:
  515. Cleanup:
  516. HRETURN( hr );
  517. } //*** CUnknownQuorum::GetUID
  518. //////////////////////////////////////////////////////////////////////////////
  519. //++
  520. //
  521. // CUnknownQuorum::GetName
  522. //
  523. // Description:
  524. //
  525. // Arguments:
  526. //
  527. // Return Value:
  528. //
  529. // Remarks:
  530. // None.
  531. //
  532. //--
  533. //////////////////////////////////////////////////////////////////////////////
  534. STDMETHODIMP
  535. CUnknownQuorum::GetName( BSTR * pbstrNameOut )
  536. {
  537. TraceFunc( "[IClusCfgManagedResourceInfo]" );
  538. HRESULT hr = S_OK;
  539. if ( pbstrNameOut == NULL )
  540. {
  541. hr = THR( E_POINTER );
  542. STATUS_REPORT_REF( TASKID_Major_Find_Devices, TASKID_Minor_UnknownQuorum_GetName_Pointer, IDS_ERROR_NULL_POINTER, IDS_ERROR_NULL_POINTER_REF, hr );
  543. goto Cleanup;
  544. } // if:
  545. *pbstrNameOut = SysAllocString( m_bstrName );
  546. if ( *pbstrNameOut == NULL )
  547. {
  548. hr = THR( E_OUTOFMEMORY );
  549. STATUS_REPORT_REF( TASKID_Major_Find_Devices, TASKID_Minor_UnknownQuorum_GetName_Memory, IDS_ERROR_OUTOFMEMORY, IDS_ERROR_OUTOFMEMORY_REF, hr );
  550. } // if:
  551. Cleanup:
  552. HRETURN( hr );
  553. } //*** CUnknownQuorum::GetName
  554. //////////////////////////////////////////////////////////////////////////////
  555. //++
  556. //
  557. // CUnknownQuorum::SetName
  558. //
  559. // Description:
  560. //
  561. // Arguments:
  562. //
  563. // Return Value:
  564. //
  565. // Remarks:
  566. // None.
  567. //
  568. //--
  569. //////////////////////////////////////////////////////////////////////////////
  570. STDMETHODIMP
  571. CUnknownQuorum::SetName( LPCWSTR pcszNameIn )
  572. {
  573. TraceFunc1( "[IClusCfgManagedResourceInfo] pcszNameIn = '%ls'", pcszNameIn == NULL ? L"<null>" : pcszNameIn );
  574. HRESULT hr = S_OK;
  575. BSTR bstr = NULL;
  576. if ( pcszNameIn == NULL )
  577. {
  578. hr = THR( E_INVALIDARG );
  579. goto Cleanup;
  580. } // if:
  581. bstr = TraceSysAllocString( pcszNameIn );
  582. if ( bstr == NULL )
  583. {
  584. hr = THR( E_OUTOFMEMORY );
  585. goto Cleanup;
  586. } // if:
  587. TraceSysFreeString( m_bstrName );
  588. m_bstrName = bstr;
  589. LogMsg( L"[SRV] Setting the name of the UnKnown Quorum to %ws.", m_bstrName );
  590. Cleanup:
  591. HRETURN( hr );
  592. } //*** CUnknownQuorum::SetName
  593. //////////////////////////////////////////////////////////////////////////////
  594. //++
  595. //
  596. // CUnknownQuorum::IsManaged
  597. //
  598. // Description:
  599. //
  600. // Arguments:
  601. //
  602. // Return Value:
  603. // S_OK
  604. // The device is managed.
  605. //
  606. // S_FALSE
  607. // The device is not managed.
  608. //
  609. // Win32 error as HRESULT when an error occurs.
  610. //
  611. // Remarks:
  612. // None.
  613. //
  614. //--
  615. //////////////////////////////////////////////////////////////////////////////
  616. STDMETHODIMP
  617. CUnknownQuorum::IsManaged( void )
  618. {
  619. TraceFunc( "[IClusCfgManagedResourceInfo]" );
  620. HRESULT hr = S_FALSE;
  621. if ( m_fIsManaged )
  622. {
  623. hr = S_OK;
  624. } // if:
  625. HRETURN( hr );
  626. } //*** CUnknownQuorum::IsManaged
  627. //////////////////////////////////////////////////////////////////////////////
  628. //++
  629. //
  630. // CUnknownQuorum::SetManaged
  631. //
  632. // Description:
  633. //
  634. // Arguments:
  635. //
  636. // Return Value:
  637. //
  638. // Remarks:
  639. // None.
  640. //
  641. //--
  642. //////////////////////////////////////////////////////////////////////////////
  643. STDMETHODIMP
  644. CUnknownQuorum::SetManaged(
  645. BOOL fIsManagedIn
  646. )
  647. {
  648. TraceFunc( "[IClusCfgManagedResourceInfo]" );
  649. m_fIsManaged = fIsManagedIn;
  650. HRETURN( S_OK );
  651. } //*** CUnknownQuorum::SetManaged
  652. //////////////////////////////////////////////////////////////////////////////
  653. //++
  654. //
  655. // CUnknownQuorum::IsQuorumResource
  656. //
  657. // Description:
  658. //
  659. // Arguments:
  660. //
  661. // Return Value:
  662. // S_OK
  663. // The device is the quorum device.
  664. //
  665. // S_FALSE
  666. // The device is not the quorum device.
  667. //
  668. // Win32 error as HRESULT when an error occurs.
  669. //
  670. // Remarks:
  671. // None.
  672. //
  673. //--
  674. //////////////////////////////////////////////////////////////////////////////
  675. STDMETHODIMP
  676. CUnknownQuorum::IsQuorumResource( void )
  677. {
  678. TraceFunc( "[IClusCfgManagedResourceInfo]" );
  679. HRESULT hr = S_FALSE;
  680. if ( m_fIsQuorum )
  681. {
  682. hr = S_OK;
  683. } // if:
  684. LOG_STATUS_REPORT_STRING(
  685. L"Unknown quorum '%1!ws!' the quorum device."
  686. , m_fIsQuorum ? L"is" : L"is not"
  687. , hr
  688. );
  689. HRETURN( hr );
  690. } //*** CUnknownQuorum::IsQuorumResource
  691. //////////////////////////////////////////////////////////////////////////////
  692. //++
  693. //
  694. // CUnknownQuorum::SetQuorumResource
  695. //
  696. // Description:
  697. //
  698. // Arguments:
  699. //
  700. // Return Value:
  701. //
  702. // Remarks:
  703. // None.
  704. //
  705. //--
  706. //////////////////////////////////////////////////////////////////////////////
  707. STDMETHODIMP
  708. CUnknownQuorum::SetQuorumResource( BOOL fIsQuorumResourceIn )
  709. {
  710. TraceFunc( "[IClusCfgManagedResourceInfo]" );
  711. HRESULT hr = S_OK;
  712. //
  713. // If we are not quorum capable then we should not allow ourself to be
  714. // made the quorum resource.
  715. //
  716. if ( ( fIsQuorumResourceIn ) && ( m_fIsQuorumCapable == FALSE ) )
  717. {
  718. hr = HRESULT_FROM_WIN32( ERROR_NOT_QUORUM_CAPABLE );
  719. goto Cleanup;
  720. } // if:
  721. m_fIsQuorum = fIsQuorumResourceIn;
  722. Cleanup:
  723. LOG_STATUS_REPORT_STRING(
  724. L"Setting unknown quorum '%1!ws!' the quorum device."
  725. , m_fIsQuorum ? L"to be" : L"to not be"
  726. , hr
  727. );
  728. HRETURN( hr );
  729. } //*** CUnknownQuorum::SetQuorumResource
  730. //////////////////////////////////////////////////////////////////////////////
  731. //++
  732. //
  733. // CUnknownQuorum::IsQuorumCapable
  734. //
  735. // Description:
  736. //
  737. // Arguments:
  738. //
  739. // Return Value:
  740. // S_OK
  741. // The device is a quorum capable device.
  742. //
  743. // S_FALSE
  744. // The device is not a quorum capable device.
  745. //
  746. // Win32 error as HRESULT when an error occurs.
  747. //
  748. // Remarks:
  749. // None.
  750. //
  751. //--
  752. //////////////////////////////////////////////////////////////////////////////
  753. STDMETHODIMP
  754. CUnknownQuorum::IsQuorumCapable( void )
  755. {
  756. TraceFunc( "[IClusCfgManagedResourceInfo]" );
  757. HRESULT hr = S_FALSE;
  758. if ( m_fIsQuorumCapable )
  759. {
  760. hr = S_OK;
  761. } // if:
  762. HRETURN( hr );
  763. } //*** CUnknownQuorum::IsQuorumCapable
  764. //////////////////////////////////////////////////////////////////////////
  765. //
  766. // CUnknownQuorum::SetQuorumCapable
  767. //
  768. // Description:
  769. // Call this to set whether the resource is capable to be the quorum
  770. // resource or not.
  771. //
  772. // Parameter:
  773. // fIsQuorumCapableIn - If TRUE, the resource will be marked as quorum capable.
  774. //
  775. // Return Values:
  776. // S_OK
  777. // Call succeeded.
  778. //
  779. //////////////////////////////////////////////////////////////////////////
  780. STDMETHODIMP
  781. CUnknownQuorum::SetQuorumCapable(
  782. BOOL fIsQuorumCapableIn
  783. )
  784. {
  785. TraceFunc( "[IClusCfgManagedResourceInfo]" );
  786. HRESULT hr = S_OK;
  787. m_fIsQuorumCapable = fIsQuorumCapableIn;
  788. HRETURN( hr );
  789. } //*** CUnknownQuorum::SetQuorumCapable
  790. //////////////////////////////////////////////////////////////////////////////
  791. //++
  792. //
  793. // CUnknownQuorum::GetDriveLetterMappings
  794. //
  795. // Description:
  796. //
  797. // Arguments:
  798. //
  799. // Return Value:
  800. // S_FALSE
  801. // There are not drive letters on this device.
  802. //
  803. // Remarks:
  804. // None.
  805. //
  806. //--
  807. //////////////////////////////////////////////////////////////////////////////
  808. STDMETHODIMP
  809. CUnknownQuorum::GetDriveLetterMappings(
  810. SDriveLetterMapping * pdlmDriveLetterMappingOut
  811. )
  812. {
  813. TraceFunc( "[IClusCfgManagedResourceInfo]" );
  814. HRETURN( S_FALSE );
  815. } //*** CUnknownQuorum::GetDriveLetterMappings
  816. //////////////////////////////////////////////////////////////////////////////
  817. //++
  818. //
  819. // CUnknownQuorum::SetDriveLetterMappings
  820. //
  821. // Description:
  822. //
  823. // Arguments:
  824. //
  825. // Return Value:
  826. //
  827. // Remarks:
  828. // None.
  829. //
  830. //--
  831. //////////////////////////////////////////////////////////////////////////////
  832. STDMETHODIMP
  833. CUnknownQuorum::SetDriveLetterMappings(
  834. SDriveLetterMapping dlmDriveLetterMappingIn
  835. )
  836. {
  837. TraceFunc( "[IClusCfgManagedResourceInfo]" );
  838. HRETURN( THR( E_NOTIMPL ) );
  839. } //*** CUnknownQuorum::SetDriveLetterMappings
  840. //////////////////////////////////////////////////////////////////////////////
  841. //++
  842. //
  843. // CUnknownQuorum::IsManagedByDefault
  844. //
  845. // Description:
  846. // Should this resource be managed by the cluster by default?
  847. //
  848. // Arguments:
  849. // None.
  850. //
  851. // Return Value:
  852. // S_OK
  853. // The device is managed by default.
  854. //
  855. // S_FALSE
  856. // The device is not managed by default.
  857. //
  858. //
  859. // Win32 error as HRESULT when an error occurs.
  860. //
  861. // Remarks:
  862. // None.
  863. //
  864. //--
  865. //////////////////////////////////////////////////////////////////////////////
  866. STDMETHODIMP
  867. CUnknownQuorum::IsManagedByDefault( void )
  868. {
  869. TraceFunc( "[IClusCfgManagedResourceInfo]" );
  870. HRESULT hr = S_FALSE;
  871. if ( m_fIsManagedByDefault )
  872. {
  873. hr = S_OK;
  874. } // if:
  875. HRETURN( hr );
  876. } //*** CUnknownQuorum::IsManagedByDefault
  877. //////////////////////////////////////////////////////////////////////////////
  878. //++
  879. //
  880. // CUnknownQuorum::SetManagedByDefault
  881. //
  882. // Description:
  883. //
  884. // Arguments:
  885. //
  886. // Return Value:
  887. //
  888. // Remarks:
  889. // None.
  890. //
  891. //--
  892. //////////////////////////////////////////////////////////////////////////////
  893. STDMETHODIMP
  894. CUnknownQuorum::SetManagedByDefault(
  895. BOOL fIsManagedByDefaultIn
  896. )
  897. {
  898. TraceFunc( "[IClusCfgManagedResourceInfo]" );
  899. m_fIsManagedByDefault = fIsManagedByDefaultIn;
  900. HRETURN( S_OK );
  901. } //*** CUnknownQuorum::SetManagedByDefault
  902. //*************************************************************************//
  903. /////////////////////////////////////////////////////////////////////////////
  904. // CUnknownQuorum class -- IClusCfgManagedResourceCfg interface.
  905. /////////////////////////////////////////////////////////////////////////////
  906. //////////////////////////////////////////////////////////////////////////////
  907. //++
  908. //
  909. // CUnknownQuorum::PreCreate
  910. //
  911. // Description:
  912. //
  913. // Arguments:
  914. //
  915. // Return Value:
  916. // S_OK
  917. // Success
  918. //
  919. // Win32 error as HRESULT when an error occurs.
  920. //
  921. // Remarks:
  922. // This functions should do nothing but return S_OK.
  923. //
  924. //--
  925. //////////////////////////////////////////////////////////////////////////////
  926. STDMETHODIMP
  927. CUnknownQuorum::PreCreate( IUnknown * punkServicesIn )
  928. {
  929. TraceFunc( "[IClusCfgManagedResourceCfg]" );
  930. HRETURN( S_OK );
  931. } //*** CUnknownQuorum::PreCreate
  932. //////////////////////////////////////////////////////////////////////////////
  933. //++
  934. //
  935. // CUnknownQuorum::Create
  936. //
  937. // Description:
  938. //
  939. // Arguments:
  940. //
  941. // Return Value:
  942. // S_OK
  943. // Success
  944. //
  945. // Win32 error as HRESULT when an error occurs.
  946. //
  947. // Remarks:
  948. // This functions should do nothing but return S_OK.
  949. //
  950. //--
  951. //////////////////////////////////////////////////////////////////////////////
  952. STDMETHODIMP
  953. CUnknownQuorum::Create( IUnknown * punkServicesIn )
  954. {
  955. TraceFunc( "[IClusCfgManagedResourceCfg]" );
  956. HRETURN( S_OK );
  957. } //*** CUnknownQuorum::Create
  958. //////////////////////////////////////////////////////////////////////////////
  959. //++
  960. //
  961. // CUnknownQuorum::PostCreate
  962. //
  963. // Description:
  964. //
  965. // Arguments:
  966. //
  967. // Return Value:
  968. // S_OK
  969. // Success
  970. //
  971. // Remarks:
  972. // This functions should do nothing but return S_OK.
  973. //
  974. //--
  975. //////////////////////////////////////////////////////////////////////////////
  976. STDMETHODIMP
  977. CUnknownQuorum::PostCreate( IUnknown * punkServicesIn )
  978. {
  979. TraceFunc( "[IClusCfgManagedResourceCfg]" );
  980. HRETURN( S_OK );
  981. } //*** CUnknownQuorum::PostCreate
  982. //////////////////////////////////////////////////////////////////////////////
  983. //++
  984. //
  985. // CUnknownQuorum::Evict
  986. //
  987. // Description:
  988. //
  989. // Arguments:
  990. //
  991. // Return Value:
  992. // S_OK
  993. // Success
  994. //
  995. // Win32 error as HRESULT when an error occurs.
  996. //
  997. // Remarks:
  998. // This functions should do nothing but return S_OK.
  999. //
  1000. //--
  1001. //////////////////////////////////////////////////////////////////////////////
  1002. STDMETHODIMP
  1003. CUnknownQuorum::Evict( IUnknown * punkServicesIn )
  1004. {
  1005. TraceFunc( "[IClusCfgManagedResourceCfg]" );
  1006. HRETURN( S_OK );
  1007. } //*** CUnknownQuorum::Evict
  1008. //*************************************************************************//
  1009. /////////////////////////////////////////////////////////////////////////////
  1010. // CUnknownQuorum class -- IClusCfgVerifyQuorum interface.
  1011. /////////////////////////////////////////////////////////////////////////////
  1012. //////////////////////////////////////////////////////////////////////////////
  1013. //++
  1014. //
  1015. // CUnknownQuorum::PrepareToHostQuorumResource
  1016. //
  1017. // Description:
  1018. // Do any configuration necessary in preparation for this node hosting
  1019. // the quorum.
  1020. //
  1021. // In this class we need to ensure that we can connect to the proper
  1022. // disk share. The data about what share to connect to should have
  1023. // already been set using SetResourcePrivateData() above.
  1024. //
  1025. // Arguments:
  1026. // None.
  1027. //
  1028. // Return Value:
  1029. // S_OK
  1030. // Success
  1031. //
  1032. // Win32 error as HRESULT when an error occurs.
  1033. //
  1034. //--
  1035. //////////////////////////////////////////////////////////////////////////////
  1036. STDMETHODIMP
  1037. CUnknownQuorum::PrepareToHostQuorumResource( void )
  1038. {
  1039. TraceFunc( "[IClusCfgVerifyQuorum]" );
  1040. HRESULT hr = S_OK;
  1041. //
  1042. // No yet implemented.
  1043. //
  1044. hr = S_FALSE;
  1045. goto Cleanup;
  1046. Cleanup:
  1047. HRETURN( hr );
  1048. } //*** CUnknownQuorum::PrepareToHostQuorumResource
  1049. //////////////////////////////////////////////////////////////////////////////
  1050. //++
  1051. //
  1052. // CUnknownQuorum::Cleanup
  1053. //
  1054. // Description:
  1055. // Do any necessay cleanup from the PrepareToHostQuorumResource()
  1056. // method.
  1057. //
  1058. // If the cleanup method is anything other than successful completion
  1059. // then the share needs to be torn down.
  1060. //
  1061. // Arguments:
  1062. // cccrReasonIn
  1063. //
  1064. // Return Value:
  1065. // S_OK
  1066. // Success
  1067. //
  1068. // Win32 error as HRESULT when an error occurs.
  1069. //
  1070. //--
  1071. //////////////////////////////////////////////////////////////////////////////
  1072. STDMETHODIMP
  1073. CUnknownQuorum::Cleanup(
  1074. EClusCfgCleanupReason cccrReasonIn
  1075. )
  1076. {
  1077. TraceFunc( "[IClusCfgVerifyQuorum]" );
  1078. HRESULT hr = S_OK;
  1079. //
  1080. // No yet implemented.
  1081. //
  1082. hr = S_FALSE;
  1083. goto Cleanup;
  1084. Cleanup:
  1085. HRETURN( hr );
  1086. } //*** CUnknownQuorum::Cleanup
  1087. //////////////////////////////////////////////////////////////////////////////
  1088. //++
  1089. //
  1090. // CUnknownQuorum::IsMultiNodeCapable
  1091. //
  1092. // Description:
  1093. // Does this quorum resource support multi node clusters?
  1094. //
  1095. // Arguments:
  1096. // None.
  1097. //
  1098. // Return Value:
  1099. // S_OK
  1100. // The resource allows multi node clusters.
  1101. //
  1102. // S_FALSE
  1103. // The resource does not allow multi node clusters.
  1104. //
  1105. //--
  1106. //////////////////////////////////////////////////////////////////////////////
  1107. STDMETHODIMP
  1108. CUnknownQuorum::IsMultiNodeCapable( void )
  1109. {
  1110. TraceFunc( "[IClusCfgVerifyQuorum]" );
  1111. HRESULT hr = S_FALSE;
  1112. if ( m_fIsMultiNodeCapable )
  1113. {
  1114. hr = S_OK;
  1115. } // if:
  1116. HRETURN( hr );
  1117. } //*** CUnknownQuorum::IsMultiNodeCapable
  1118. //////////////////////////////////////////////////////////////////////////////
  1119. //++
  1120. //
  1121. // CUnknownQuorum::SetMultiNodeCapable
  1122. //
  1123. // Description:
  1124. // Sets the multi node capable flag
  1125. //
  1126. // Arguments:
  1127. // fMultiNodeCapableIn
  1128. // The flag telling this instance whether or not it should support
  1129. // Multi node clusters.
  1130. //
  1131. // Return Value:
  1132. // S_OK
  1133. // Success.
  1134. //
  1135. //--
  1136. //////////////////////////////////////////////////////////////////////////////
  1137. STDMETHODIMP
  1138. CUnknownQuorum::SetMultiNodeCapable( BOOL fMultiNodeCapableIn )
  1139. {
  1140. TraceFunc( "[IClusCfgVerifyQuorum]" );
  1141. m_fIsMultiNodeCapable = fMultiNodeCapableIn;
  1142. HRETURN( S_OK );
  1143. } //*** CUnknownQuorum::SetMultiNodeCapable