Jump to: navigation, search

Difference between revisions of "Trove/Clusters-MongoDB"

(Show Instance)
(List Instances)
Line 258: Line 258:
 
* ip/hostname is not returned in GET /v1.0/<tenant_id>/clusters/<cluster-id>/instances/<instance-id> because in a sharded deployment, a client should never connect directly to the replica-set.
 
* ip/hostname is not returned in GET /v1.0/<tenant_id>/clusters/<cluster-id>/instances/<instance-id> because in a sharded deployment, a client should never connect directly to the replica-set.
 
** Need to determine whether it can be omitted in GET /v1.0/<tenant_id>/instances/<instance-id> (or is it considered a breaking change?) Could consider returning the mongos query router list.
 
** Need to determine whether it can be omitted in GET /v1.0/<tenant_id>/instances/<instance-id> (or is it considered a breaking change?) Could consider returning the mongos query router list.
 +
<br>
 +
==== List Clusters ====
 +
<br>
 +
Request:
 +
 +
<pre>
 +
GET /v1.0/<tenant_id>/clusters
 +
</pre>
 +
 +
Response:
 +
 +
<pre>
 +
{
 +
  "clusters": [
 +
    {
 +
      "status": "ACTIVE",
 +
      "id": "dfbbd9ca-b5e1-4028-adb7-f78643e17998",
 +
      "name": "products",
 +
      "created": "2014-04-25T20:19:23",
 +
      "updated": "2014-04-25T20:19:23",
 +
      "links": [{...}],
 +
      "datastore": {
 +
        "type": "mongodb",
 +
        "version": "2.6"
 +
      },
 +
      "instances": [
 +
        {
 +
          "id": "416b0b16-ba55-4302-bbd3-ff566032e1c1",
 +
          "shard_id": "5415b62f-f301-4e84-ba90-8ab0734d15a7",
 +
          "flavor": {
 +
            "id": "7",
 +
            "links": [{...}]
 +
          },
 +
          "volume": {
 +
            "size": 100
 +
          }
 +
        },
 +
        {
 +
          "id": "965ef811-7c1d-47fc-89f2-a89dfdd23ef2",
 +
          "shard_id": "5415b62f-f301-4e84-ba90-8ab0734d15a7",
 +
          "flavor": {
 +
            "id": "7",
 +
            "links": [{...}]
 +
          },
 +
          "volume": {
 +
            "size": 100
 +
          }
 +
        },
 +
        {
 +
          "id": "3642f41c-e8ad-4164-a089-3891bf7f2d2b",
 +
          "shard_id": "5415b62f-f301-4e84-ba90-8ab0734d15a7",
 +
          "flavor": {
 +
            "id": "7",
 +
            "links": [{...}]
 +
          },
 +
          "volume": {
 +
            "size": 100
 +
          }
 +
        }
 +
      ]
 +
    },
 +
    ...
 +
  ]
 +
}
 +
</pre>
 +
<br>
 +
==== List Instances ====
 +
<br>
 +
Request:
 +
 +
<pre>
 +
GET /v1.0/<tenant_id>/instances
 +
</pre>
 +
 +
Response:
 +
 +
<pre>
 +
{"instances": []}
 +
</pre>
 +
 +
Explanation
 +
* GET /instances prior to clustering returned only standalone instances, and to honor that contract, we will filter out instances that belong to a cluster.
 +
<br>
 +
Request:
 +
 +
<pre>
 +
GET /v1.0/<tenant_id>/instances?include_clustered=false
 +
</pre>
 +
 +
Response:
 +
 +
<pre>
 +
{"instances": []}
 +
</pre>
 +
 +
Request:
 +
 +
<pre>
 +
GET /v1.0/<tenant_id>/instances?include_clustered=true
 +
</pre>
 +
 +
Response:
 +
 +
<pre>
 +
{
 +
  "instances": [
 +
    {
 +
      "status": "ACTIVE",
 +
      "id": "416b0b16-ba55-4302-bbd3-ff566032e1c1",
 +
      "cluster_id": "dfbbd9ca-b5e1-4028-adb7-f78643e17998",
 +
      "shard_id": "5415b62f-f301-4e84-ba90-8ab0734d15a7",
 +
      "name": "products-rs1-1",
 +
      "created": "2014-04-25T20:19:23",
 +
      "updated": "2014-04-25T20:19:23",
 +
      "links": [{...}],
 +
      "datastore": {
 +
        "type": "mongodb",
 +
        "version": "2.6"
 +
      },
 +
      "ip": ["10.0.0.1"],
 +
      "flavor": {
 +
        "id": "7",
 +
        "links": [{...}],
 +
      },
 +
      "volume": {
 +
        "size": 100,
 +
        "used": 0.17
 +
      }
 +
    },
 +
    {
 +
      "status": "ACTIVE",
 +
      "id": "416b0b16-ba55-4302-bbd3-ff566032e1c1",
 +
      "cluster_id": "dfbbd9ca-b5e1-4028-adb7-f78643e17998",
 +
      "shard_id": "5415b62f-f301-4e84-ba90-8ab0734d15a7",
 +
      "name": "products-rs1-2",
 +
      "created": "2014-04-25T20:19:23",
 +
      "updated": "2014-04-25T20:19:23",
 +
      "links": [{...}],
 +
      "datastore": {
 +
        "type": "mongodb",
 +
        "version": "2.6"
 +
      },
 +
      "ip": ["10.0.0.2"],
 +
      "flavor": {
 +
        "id": "7",
 +
        "links": [{...}],
 +
      },
 +
      "volume": {
 +
        "size": 100,
 +
        "used": 0.17
 +
      }
 +
    },
 +
    {
 +
      "status": "ACTIVE",
 +
      "id": "416b0b16-ba55-4302-bbd3-ff566032e1c1",
 +
      "cluster_id": "dfbbd9ca-b5e1-4028-adb7-f78643e17998",
 +
      "shard_id": "5415b62f-f301-4e84-ba90-8ab0734d15a7",
 +
      "name": "products-rs1-3",
 +
      "created": "2014-04-25T20:19:23",
 +
      "updated": "2014-04-25T20:19:23",
 +
      "links": [{...}],
 +
      "datastore": {
 +
        "type": "mongodb",
 +
        "version": "2.6"
 +
      },
 +
      "ip": ["10.0.0.3"],
 +
      "flavor": {
 +
        "id": "7",
 +
        "links": [{...}],
 +
      },
 +
      "volume": {
 +
        "size": 100,
 +
        "used": 0.17
 +
      }
 +
    }
 +
  ]
 +
}
 +
</pre>

Revision as of 00:31, 16 August 2014

Summary


  • Will remain on /v1.0 of the API (aka will not introduce /v2.0, meaning everything remains backwards compatible)
  • Will introduce /clusters resource
  • Previously, an "instance" was defined as a standalone (unclustered) instance of a datastore. Now, an "instance" is either a standalone instance, or an instance that belongs to a cluster. By inference, a cluster is a collection of instances.
  • All MongoDB clusters will be sharded clusters, with shards being three member replica-sets. Upon cluster creation, a single shard is assumed; once the initial cluster is provisioned, additional shards can be added on-demand.
  • Each sharded cluster will have at least one query router (mongos), and at least one mongo config server (mongod --configsvr).
    • Query routers and config servers will not be represented as instances in the API. See more information under the Query Routers and Config Servers section.



Operations


Create Cluster


Request:

POST /v1.0/<tenant_id>/clusters
{
  "cluster": {
    "name": "products",
    "datastore": {
      "type": "mongodb",
      "version": "2.6"
    },
    "instances": [
      {
        "flavorRef": "7",
        "volume": {
          "size": 100
        }
      },
      {
        "flavorRef": "7",
        "volume": {
          "size": 100
        }
      },
      {
        "flavorRef": "7",
        "volume": {
          "size": 100
        }
      }
    ]
  }
}

Response:

{
  "cluster": {
    "status": "BUILD",
    "id": "dfbbd9ca-b5e1-4028-adb7-f78643e17998",
    "name": "products",
    "created": "2014-04-25T20:19:23",
    "updated": "2014-04-25T20:19:23",
    "links": [{...}],
    "datastore": {
      "type": "mongodb",
      "version": "2.6"
    },
    "instances": [
      {
        "id": "416b0b16-ba55-4302-bbd3-ff566032e1c1",
        "shard_id": "5415b62f-f301-4e84-ba90-8ab0734d15a7",
        "flavor": {
          "id": "7",
          "links": [{...}]
        },
        "volume": {
          "size": 100
        }
      },
      {
        "id": "965ef811-7c1d-47fc-89f2-a89dfdd23ef2",
        "shard_id": "5415b62f-f301-4e84-ba90-8ab0734d15a7",
        "flavor": {
          "id": "7",
          "links": [{...}]
        },
        "volume": {
          "size": 100
        }
      },
      {
        "id": "3642f41c-e8ad-4164-a089-3891bf7f2d2b",
        "shard_id": "5415b62f-f301-4e84-ba90-8ab0734d15a7",
        "flavor": {
          "id": "7",
          "links": [{...}]
        },
        "volume": {
          "size": 100
        }
      }
    ]
  }
}

Notes:

  • Creates a sharded cluster, with a single shard (3 member replica-set), each replica-set member with the same flavor (memory + vcpu) and volume-size.
    • Also creates mongos query routers and config-servers (see Query Servers and Config Servers for more information)
  • The replica-set name (replSet) will be automatically generated; it will be the cluster name with a "rs-<num>" suffix.
    • In this example, the first replica-set name will be "product-rs1", the next "product-rs2", etc.
  • The name of each instance will be automatically generated; it will be the <cluster_name>-rs<rs_num>-<instance_num>
    • In this example, the instance names will be "product-rs1-1", "product-rs1-2", and "product-rs1-3".
  • In the first iteration, flavor and volume-size must be identical for all instances in a replica-set.
  • In the first iteration, the number of instances in a replica-set must be 3.


Show Cluster


Request:

GET /v1.0/<tenant_id>/clusters/dfbbd9ca-b5e1-4028-adb7-f78643e17998

Response:

{
  "cluster": {
    "status": "ACTIVE",
    "id": "dfbbd9ca-b5e1-4028-adb7-f78643e17998",
    "name": "products",
    "created": "2014-04-25T20:19:23",
    "updated": "2014-04-25T20:19:23",
    "links": [{...}],
    "datastore": {
      "type": "mongodb",
      "version": "2.6"
    },
    "ip": ["10.0.0.1"],
    "instances": [
      {
        "id": "416b0b16-ba55-4302-bbd3-ff566032e1c1",
        "shard_id": "5415b62f-f301-4e84-ba90-8ab0734d15a7",
        "flavor": {
          "id": "7",
          "links": [{...}]
        },
        "volume": {
          "size": 100
        }
      },
      {
        "id": "965ef811-7c1d-47fc-89f2-a89dfdd23ef2",
        "shard_id": "5415b62f-f301-4e84-ba90-8ab0734d15a7",
        "flavor": {
          "id": "7",
          "links": [{...}]
        },
        "volume": {
          "size": 100
        }
      },
      {
        "id": "3642f41c-e8ad-4164-a089-3891bf7f2d2b",
        "shard_id": "5415b62f-f301-4e84-ba90-8ab0734d15a7",
        "flavor": {
          "id": "7",
          "links": [{...}]
        },
        "volume": {
          "size": 100
        }
      }
    ]
  }
}

Notes:

  • The ip/hostname returned is the list of mongos query routers. See Query Routers and Config-Servers for more information.


Show Instance


Request:

GET /v1.0/<tenant_id>/clusters/dfbbd9ca-b5e1-4028-adb7-f78643e17998/instances/416b0b16-ba55-4302-bbd3-ff566032e1c1

Response:

{
  "instance": {
    "status": "ACTIVE",
    "id": "416b0b16-ba55-4302-bbd3-ff566032e1c1",
    "cluster_id": "dfbbd9ca-b5e1-4028-adb7-f78643e17998",
    "shard_id": "5415b62f-f301-4e84-ba90-8ab0734d15a7",
    "name": "products-rs1-1",
    "created": "2014-04-25T20:19:23",
    "updated": "2014-04-25T20:19:23",
    "links": [{...}],
    "datastore": {
      "type": "mongodb",
      "version": "2.6"
    },
    "flavor": {
      "id": "7",
      "links": [{...}],
    },
    "volume": {
      "size": 100,
      "used": 0.17
    }
  }
}

or alternatively, the existing route can be used:

GET /v1.0/<tenant_id>/instances/416b0b16-ba55-4302-bbd3-ff566032e1c1

Response:

{
  "instance": {
    "status": "ACTIVE",
    "id": "416b0b16-ba55-4302-bbd3-ff566032e1c1",
    "cluster_id": "dfbbd9ca-b5e1-4028-adb7-f78643e17998",
    "shard_id": "5415b62f-f301-4e84-ba90-8ab0734d15a7",
    "name": "products-rs1-1",
    "created": "2014-04-25T20:19:23",
    "updated": "2014-04-25T20:19:23",
    "links": [{...}],
    "datastore": {
      "type": "mongodb",
      "version": "2.6"
    },
    "ip": ["10.0.0.1"],
    "flavor": {
      "id": "7",
      "links": [{...}],
    },
    "volume": {
      "size": 100,
      "used": 0.17
    }
  }
}

Explanation

  • GET /instance/<id> must function as before to avoid introducing a breaking change


Notes

  • cluster_id must be added to GET /instance/<id>, otherwise users will not be able to discover the cluster-id for an instance that is discovered via GET /instances?include_clustered=true
  • ip/hostname is not returned in GET /v1.0/<tenant_id>/clusters/<cluster-id>/instances/<instance-id> because in a sharded deployment, a client should never connect directly to the replica-set.
    • Need to determine whether it can be omitted in GET /v1.0/<tenant_id>/instances/<instance-id> (or is it considered a breaking change?) Could consider returning the mongos query router list.


List Clusters


Request:

GET /v1.0/<tenant_id>/clusters

Response:

{
  "clusters": [
    {
      "status": "ACTIVE",
      "id": "dfbbd9ca-b5e1-4028-adb7-f78643e17998",
      "name": "products",
      "created": "2014-04-25T20:19:23",
      "updated": "2014-04-25T20:19:23",
      "links": [{...}],
      "datastore": {
        "type": "mongodb",
        "version": "2.6"
      },
      "instances": [
        {
          "id": "416b0b16-ba55-4302-bbd3-ff566032e1c1",
          "shard_id": "5415b62f-f301-4e84-ba90-8ab0734d15a7",
          "flavor": {
            "id": "7",
            "links": [{...}]
          },
          "volume": {
            "size": 100
          }
        },
        {
          "id": "965ef811-7c1d-47fc-89f2-a89dfdd23ef2",
          "shard_id": "5415b62f-f301-4e84-ba90-8ab0734d15a7",
          "flavor": {
            "id": "7",
            "links": [{...}]
          },
          "volume": {
            "size": 100
          }
        },
        {
          "id": "3642f41c-e8ad-4164-a089-3891bf7f2d2b",
          "shard_id": "5415b62f-f301-4e84-ba90-8ab0734d15a7",
          "flavor": {
            "id": "7",
            "links": [{...}]
          },
          "volume": {
            "size": 100
          }
        }
      ]
    },
    ...
  ]
}


List Instances


Request:

GET /v1.0/<tenant_id>/instances

Response:

{"instances": []}

Explanation

  • GET /instances prior to clustering returned only standalone instances, and to honor that contract, we will filter out instances that belong to a cluster.


Request:

GET /v1.0/<tenant_id>/instances?include_clustered=false

Response:

{"instances": []}

Request:

GET /v1.0/<tenant_id>/instances?include_clustered=true

Response:

{
  "instances": [
    {
      "status": "ACTIVE",
      "id": "416b0b16-ba55-4302-bbd3-ff566032e1c1",
      "cluster_id": "dfbbd9ca-b5e1-4028-adb7-f78643e17998",
      "shard_id": "5415b62f-f301-4e84-ba90-8ab0734d15a7",
      "name": "products-rs1-1",
      "created": "2014-04-25T20:19:23",
      "updated": "2014-04-25T20:19:23",
      "links": [{...}],
      "datastore": {
        "type": "mongodb",
        "version": "2.6"
      },
      "ip": ["10.0.0.1"],
      "flavor": {
        "id": "7",
        "links": [{...}],
      },
      "volume": {
        "size": 100,
        "used": 0.17
      }
    },
    {
      "status": "ACTIVE",
      "id": "416b0b16-ba55-4302-bbd3-ff566032e1c1",
      "cluster_id": "dfbbd9ca-b5e1-4028-adb7-f78643e17998",
      "shard_id": "5415b62f-f301-4e84-ba90-8ab0734d15a7",
      "name": "products-rs1-2",
      "created": "2014-04-25T20:19:23",
      "updated": "2014-04-25T20:19:23",
      "links": [{...}],
      "datastore": {
        "type": "mongodb",
        "version": "2.6"
      },
      "ip": ["10.0.0.2"],
      "flavor": {
        "id": "7",
        "links": [{...}],
      },
      "volume": {
        "size": 100,
        "used": 0.17
      }
    },
    {
      "status": "ACTIVE",
      "id": "416b0b16-ba55-4302-bbd3-ff566032e1c1",
      "cluster_id": "dfbbd9ca-b5e1-4028-adb7-f78643e17998",
      "shard_id": "5415b62f-f301-4e84-ba90-8ab0734d15a7",
      "name": "products-rs1-3",
      "created": "2014-04-25T20:19:23",
      "updated": "2014-04-25T20:19:23",
      "links": [{...}],
      "datastore": {
        "type": "mongodb",
        "version": "2.6"
      },
      "ip": ["10.0.0.3"],
      "flavor": {
        "id": "7",
        "links": [{...}],
      },
      "volume": {
        "size": 100,
        "used": 0.17
      }
    }
  ]
}