Skip to content

Instantly share code, notes, and snippets.

@tamirko
Created January 29, 2012 13:52
Show Gist options
  • Save tamirko/1698923 to your computer and use it in GitHub Desktop.
Save tamirko/1698923 to your computer and use it in GitHub Desktop.
Retrieving the mongos service
import com.gigaspaces.cloudify.dsl.context.ServiceContextFactory
// ...
// Getting the tomcat service instance ID
instanceID = serviceContext.getInstanceId()
// Waiting for the mongos service for 20 seconds
mongoService = serviceContext.waitForService(config.mongoService, 20, TimeUnit.SECONDS)
// Waiting for the mongos service instances for 60 seconds (In this case,
// there's only one mongos instance, but we support more).
mongoInstances = mongoService.waitForInstances(mongoService.numberOfPlannedInstances, 60, TimeUnit.SECONDS)
// Retrieving the mongos host address.
// Note that the mongoInstances array is zero based.
def mongoServiceHost = mongoInstances[instanceID-1].hostAddress
// Retrieving the mongos port
// Note that the mongoServiceInstances array is one based.
def mongoServiceInstances=serviceContext.attributes.mongos.instances
mongoServicePort=mongoServiceInstances[instanceID].port
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment