{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":1061,"path":"api-reference/server-api-reference/c_MIDServerClusterAPI.md","title":"MIDServerCluster - Global","bundle":null,"doc_type":null,"release":"australia","body":"\n# MIDServerCluster- Global\n\nThe MIDServerCluster script include provides methods to find MID Server clusters for a given MID Server and reassigns the jobs if necessary.\n\nIf the MID Server agent is up, this class gathers all MID Servers \\(including the original agent\\) in the load balance clusters that the original agent is part of. If the MID Server agent is down and the cluster is load balanced, the class gathers the other agents. If the server agent is down, and the cluster is failover, it gathers the next failover agent. The class then randomly returns the MID Server in the final list of MID Servers.\n\nUse in server scripts to get MID Server cluster information.\n\n**Parent Topic:**[Server API reference](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/api-server.md)\n\n## MIDServerCluster - MIDServerCluster\\(GlideRecord agent\\)\n\nBrief description of the method.\n\n|Name|Type|Description|\n|----|----|-----------|\n|agent|GlideRecord|The MID server agent|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n## MIDServerCluster - clusterExists\\(\\)\n\nDetermines if a cluster exists.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|Boolean|True if a cluster exists; otherwise, false.|\n\n```\nvar midgr = new GlideRecord(\"ecc_agent\");\nmidgr.addQuery(\"name\", \"al1winmid\");\nmidgr.query();\nmidgr.next();\n \nvar mscl = new MIDServerCluster(midgr);\ngs.print(mscl.clusterExists());\n```\n\nOutput: true\n\n## MIDServerCluster - getClusterAgent\\(\\)\n\nGets the cluster agent.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|The agent name|\n\n```\n// Assuming \"mid1\" and \"mid2\" are in a cluster\nvar midgr = new GlideRecord(\"ecc_agent\");\nmidgr.addQuery(\"name\", \"mid1\");\nmidgr.query();\nmidgr.next();\n \nvar mscl = new MIDServerCluster(midgr);\ngs.print(mscl.getClusterAgent());\n```\n\nOutput: mid2\n\n"}}