Search in sources :

Example 1 with FindRestEnabledServersFunction

use of org.apache.geode.internal.cache.execute.util.FindRestEnabledServersFunction in project geode by apache.

the class GemFireCacheImpl method initialize.

/**
   * Perform initialization, solve the early escaped reference problem by putting publishing
   * references to this instance in this method (vs. the constructor).
   */
private void initialize() {
    if (GemFireCacheImpl.instance != null) {
        Assert.assertTrue(GemFireCacheImpl.instance == null, "Cache instance already in place: " + instance);
    }
    GemFireCacheImpl.instance = this;
    GemFireCacheImpl.pdxInstance = this;
    for (CacheLifecycleListener listener : cacheLifecycleListeners) {
        listener.cacheCreated(this);
    }
    ClassPathLoader.setLatestToDefault(this.system.getConfig().getDeployWorkingDir());
    // request and check cluster configuration
    ConfigurationResponse configurationResponse = requestSharedConfiguration();
    deployJarsReceivedFromClusterConfiguration(configurationResponse);
    // apply the cluster's properties configuration and initialize security using that configuration
    ClusterConfigurationLoader.applyClusterPropertiesConfiguration(this, configurationResponse, this.system.getConfig());
    // first initialize the security service using the security properties
    this.securityService.initSecurity(this.system.getConfig().getSecurityProps());
    // secondly if cacheConfig has a securityManager, use that instead
    if (this.cacheConfig.getSecurityManager() != null) {
        this.securityService.setSecurityManager(this.cacheConfig.getSecurityManager());
    }
    // if cacheConfig has a postProcessor, use that instead
    if (this.cacheConfig.getPostProcessor() != null) {
        this.securityService.setPostProcessor(this.cacheConfig.getPostProcessor());
    }
    SystemMemberCacheEventProcessor.send(this, Operation.CACHE_CREATE);
    this.resourceAdvisor.initializationGate();
    // Register function that we need to execute to fetch available REST service endpoints in DS
    FunctionService.registerFunction(new FindRestEnabledServersFunction());
    // moved this after initializeDeclarativeCache because in the future
    // distributed system creation will not happen until we have read
    // cache.xml file.
    // For now this needs to happen before cache.xml otherwise
    // we will not be ready for all the events that cache.xml
    // processing can deliver (region creation, etc.).
    // This call may need to be moved inside initializeDeclarativeCache.
    // Entry to GemFire Management service
    this.jmxAdvisor.initializationGate();
    // this starts up the ManagementService, register and federate the internal beans
    this.system.handleResourceEvent(ResourceEvent.CACHE_CREATE, this);
    initializeServices();
    boolean completedCacheXml = false;
    try {
        if (configurationResponse == null) {
            // Deploy all the jars from the deploy working dir.
            ClassPathLoader.getLatest().getJarDeployer().loadPreviouslyDeployedJarsFromDisk();
        }
        ClusterConfigurationLoader.applyClusterXmlConfiguration(this, configurationResponse, this.system.getConfig());
        initializeDeclarativeCache();
        completedCacheXml = true;
    } finally {
        if (!completedCacheXml) {
            // so initializeDeclarativeCache threw an exception
            try {
                // fix for bug 34041
                close();
            } catch (Throwable ignore) {
            // I don't want init to throw an exception that came from the close.
            // I want it to throw the original exception that came from initializeDeclarativeCache.
            }
        }
    }
    this.poolFactory = null;
    startColocatedJmxManagerLocator();
    startMemcachedServer();
    startRedisServer();
    startRestAgentServer(this);
    this.isInitialized = true;
}
Also used : ConfigurationResponse(org.apache.geode.management.internal.configuration.messages.ConfigurationResponse) FindRestEnabledServersFunction(org.apache.geode.internal.cache.execute.util.FindRestEnabledServersFunction)

Aggregations

FindRestEnabledServersFunction (org.apache.geode.internal.cache.execute.util.FindRestEnabledServersFunction)1 ConfigurationResponse (org.apache.geode.management.internal.configuration.messages.ConfigurationResponse)1