int getClusterGroups(cluster_t *pcluster) { HCLUSTER hClust; HCLUSENUM hClusEnum; DWORD dwIndex; DWORD dwType; LPWSTR lpszName; DWORD cchName; hClust = OpenCluster(NULL); if (hClust == NULL) { warnError(L"Error 0x%x executing OpenCluster entry point.", GetLastError()); return I_FALSE; } if ((hClusEnum = ClusterOpenEnum(hClust, CLUSTER_ENUM_GROUP)) == NULL) { warnError(L"Error 0x%x executing OpenCluster entry point.", GetLastError()); CloseCluster(hClust); return I_FALSE; } if ((lpszName = LocalAlloc(LPTR, BUFFER_SIZE * sizeof(TCHAR))) == NULL) fatalError(L"Fatal Error 0x%x executing LocalAlloc entry point.", GetLastError()); cchName = BUFFER_SIZE; for (dwIndex = 0; ClusterEnum(hClusEnum, dwIndex, &dwType, lpszName, &cchName) == ERROR_SUCCESS; dwIndex++) { getGroupState(pcluster, hClust, lpszName); cchName = BUFFER_SIZE; } LocalFree(lpszName); ClusterCloseEnum(hClusEnum); CloseCluster(hClust); return I_TRUE; }
// // Check cluster state status // int checkClusterState() { HCLUSTER hClust; DWORD pdwClusterState; if (GetNodeClusterState(NULL, &pdwClusterState) != ERROR_SUCCESS) { warnError(L"Error 0x%x executing GetClusterInformation entry point.", GetLastError()); return I_FALSE; } switch (pdwClusterState) { case ClusterStateNotInstalled : warnError(L"Windows Clustering is not installed."); return I_FALSE; case ClusterStateNotConfigured : warnError(L"Windows Clustering is not configured."); return I_FALSE; case ClusterStateNotRunning : case ClusterStateRunning : break ; } hClust = OpenCluster(NULL); if (hClust == NULL) { warnError(L"Error 0x%x executing OpenCluster entry point.", GetLastError()); return I_FALSE; } CloseCluster(hClust); return I_TRUE; }
UINT __stdcall ingres_cluster_unregister_service(MSIHANDLE hInstall) { HCLUSTER hCluster; HRESOURCE hResource; WCHAR wszResourceName[256]; char szResourceName[256]; char szInstallCode[3]; DWORD dwSize; INSTALLSTATE iInstalled, iAction; char szBuf[256]; MsiGetFeatureState(hInstall, "IngresDBMS", &iInstalled, &iAction); if(iAction != INSTALLSTATE_ABSENT) return ERROR_SUCCESS; dwSize=sizeof(szBuf); *szBuf=0; if (!MsiGetProperty(hInstall, "INGRES_CLUSTER_RESOURCE_INUSE", szBuf, &dwSize) && !strcmp(szBuf, "1")) return ERROR_SUCCESS; dwSize=sizeof(szResourceName); *szResourceName=0; MsiGetProperty(hInstall, "INGRES_CLUSTER_RESOURCE", szResourceName, &dwSize); mbstowcs(wszResourceName, szResourceName, sizeof(szResourceName)); dwSize=sizeof(szInstallCode); *szInstallCode=0; MsiGetProperty(hInstall, "II_INSTALLATION", szInstallCode, &dwSize); hCluster = OpenCluster(NULL); if(hCluster) { hResource = OpenClusterResource(hCluster, wszResourceName); if(hResource) { if (!DeleteClusterResource(hResource)) SetupRegistryKeys(hResource, szInstallCode, FALSE); CloseClusterResource(hResource); } CloseCluster(hCluster); } return ERROR_SUCCESS; }