Created
January 29, 2012 13:52
-
-
Save tamirko/1698923 to your computer and use it in GitHub Desktop.
Retrieving the mongos service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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