---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# MIDServerCluster - Global

# MIDServerCluster - Global {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 1 minute to read

The MIDServerCluster script include provides methods to find MID Server clusters for a given MID Server and reassigns the jobs if necessary.

If 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.

Use in server scripts to get MID Server cluster information.

## MIDServerCluster - MIDServerCluster(GlideRecord agent) {#ariaid-title2}

Brief description of the method.
{#r_MSC-MIDServerCluster_GR__table_zvy_2wk_zt__entry__3}

| Name | Type | Description |
|-|-|-|
| agent | GlideRecord | The MID server agent |
[Table 1. Parameters]

{#r_MSC-MIDServerCluster_GR__table_zvy_2wk_zt} {#r_MSC-MIDServerCluster_GR__table_awy_2wk_zt__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 2. Returns]

{#r_MSC-MIDServerCluster_GR__table_awy_2wk_zt}

## MIDServerCluster - clusterExists() {#ariaid-title3}

Determines if a cluster exists.
{#r_MSC-clusterExists__table_j3r_nwk_zt__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 3. Parameters]

{#r_MSC-clusterExists__table_j3r_nwk_zt} {#r_MSC-clusterExists__table_k3r_nwk_zt__entry__2}

| Type | Description |
|-|-|
| Boolean | True if a cluster exists; otherwise, false. |
[Table 4. Returns]

{#r_MSC-clusterExists__table_k3r_nwk_zt}  

    var midgr = new GlideRecord("ecc_agent");
    midgr.addQuery("name", "al1winmid");
    midgr.query();
    midgr.next();
     
    var mscl = new MIDServerCluster(midgr);
    gs.print(mscl.clusterExists());

Output: true

## MIDServerCluster - getClusterAgent() {#ariaid-title4}

Gets the cluster agent.
{#r_MSC-getClusterAgent__table_kfv_bxk_zt__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 5. Parameters]

{#r_MSC-getClusterAgent__table_kfv_bxk_zt} {#r_MSC-getClusterAgent__table_lfv_bxk_zt__entry__2}

| Type | Description |
|-|-|
| String | The agent name |
[Table 6. Returns]

{#r_MSC-getClusterAgent__table_lfv_bxk_zt}  

    // Assuming "mid1" and "mid2" are in a cluster
    var midgr = new GlideRecord("ecc_agent");
    midgr.addQuery("name", "mid1");
    midgr.query();
    midgr.next();
     
    var mscl = new MIDServerCluster(midgr);
    gs.print(mscl.getClusterAgent());

Output: mid2

