Examples of GridConfiguration


Examples of org.gridgain.grid.GridConfiguration

    /** Tx isolation to use. */
    private GridCacheTxIsolation txIsolation;

    /** {@inheritDoc} */
    @Override protected GridConfiguration getConfiguration(String gridName) throws Exception {
        GridConfiguration c = super.getConfiguration(gridName);

        GridCacheConfiguration cc = defaultCacheConfiguration();

        cc.setCacheMode(cacheMode());
        cc.setAtomicityMode(TRANSACTIONAL);

        cc.setSwapEnabled(false);

        cc.setWriteSynchronizationMode(GridCacheWriteSynchronizationMode.FULL_SYNC);
        cc.setDistributionMode(GridCacheDistributionMode.PARTITIONED_ONLY);

        cc.setEvictionPolicy(plc);
        cc.setNearEvictionPolicy(nearPlc);
        cc.setEvictSynchronizedKeyBufferSize(1);

        cc.setDefaultTxConcurrency(txConcurrency);
        cc.setDefaultTxIsolation(txIsolation);

        cc.setEvictNearSynchronized(true);
        cc.setEvictSynchronized(true);

        cc.setStore(testStore);

        cc.setTxSerializableEnabled(true);

        c.setCacheConfiguration(cc);

        GridTcpDiscoverySpi disco = new GridTcpDiscoverySpi();

        disco.setIpFinder(ipFinder);

        c.setDiscoverySpi(disco);

        return c;
    }
View Full Code Here

Examples of org.gridgain.grid.GridConfiguration

        if (url != null)
            return start(DFLT_CFG, null, springCtx);

        U.warn(null, "Default Spring XML file not found (is GRIDGAIN_HOME set?): " + DFLT_CFG);

        return start0(new GridStartContext(new GridConfiguration(), null, springCtx)).grid();
    }
View Full Code Here

Examples of org.gridgain.grid.GridConfiguration

     *      read. This exception will be thrown also if grid with given name has already
     *      been started or Spring XML configuration file is invalid.
     */
    public static Grid start(@Nullable String springCfgPath, @Nullable String gridName) throws GridException {
        if (springCfgPath == null) {
            GridConfiguration cfg = new GridConfiguration();

            if (cfg.getGridName() == null && !F.isEmpty(gridName))
                cfg.setGridName(gridName);

            return start(cfg);
        }
        else
            return start(springCfgPath, gridName, null);
View Full Code Here

Examples of org.gridgain.grid.GridConfiguration

         */
        @SuppressWarnings({"unchecked", "TooBroadScope"})
        private void start0(GridStartContext startCtx) throws GridException {
            assert grid == null : "Grid is already started: " + name;

            GridConfiguration cfg = startCtx.config();

            if (cfg == null)
                cfg = new GridConfiguration();

            GridConfiguration myCfg = new GridConfiguration();

            String ggHome = cfg.getGridGainHome();

            // Set GridGain home.
            if (ggHome == null)
                ggHome = U.getGridGainHome();
            else
                // If user provided GRIDGAIN_HOME - set it as a system property.
                U.setGridGainHome(ggHome);

            U.setWorkDirectory(cfg.getWorkDirectory(), ggHome);

            /*
             * Set up all defaults and perform all checks.
             */

            // Ensure invariant.
            // It's a bit dirty - but this is a result of late refactoring
            // and I don't want to reshuffle a lot of code.
            assert F.eq(name, cfg.getGridName());

            // Set configuration URL, if any, into system property.
            if (startCtx.configUrl() != null)
                System.setProperty(GG_CONFIG_URL, startCtx.configUrl().toString());

            myCfg.setGridName(cfg.getGridName());

            UUID nodeId = cfg.getNodeId();

            if (nodeId == null)
                nodeId = UUID.randomUUID();

            GridLogger cfgLog = initLogger(cfg.getGridLogger(), nodeId);

            assert cfgLog != null;

            cfgLog = new GridLoggerProxy(cfgLog, null, name, U.id8(nodeId));

            // Initialize factory's log.
            log = cfgLog.getLogger(G.class);

            // Check GridGain home folder (after log is available).
            if (ggHome != null) {
                File ggHomeFile = new File(ggHome);

                if (!ggHomeFile.exists() || !ggHomeFile.isDirectory())
                    throw new GridException("Invalid GridGain installation home folder: " + ggHome);
            }

            myCfg.setGridGainHome(ggHome);

            // Copy values that don't need extra processing.
            myCfg.setLicenseUrl(cfg.getLicenseUrl());
            myCfg.setPeerClassLoadingEnabled(cfg.isPeerClassLoadingEnabled());
            myCfg.setDeploymentMode(cfg.getDeploymentMode());
            myCfg.setNetworkTimeout(cfg.getNetworkTimeout());
            myCfg.setClockSyncSamples(cfg.getClockSyncSamples());
            myCfg.setClockSyncFrequency(cfg.getClockSyncFrequency());
            myCfg.setDiscoveryStartupDelay(cfg.getDiscoveryStartupDelay());
            myCfg.setMetricsHistorySize(cfg.getMetricsHistorySize());
            myCfg.setMetricsExpireTime(cfg.getMetricsExpireTime());
            myCfg.setMetricsUpdateFrequency(cfg.getMetricsUpdateFrequency());
            myCfg.setLifecycleBeans(cfg.getLifecycleBeans());
            myCfg.setLocalEventListeners(cfg.getLocalEventListeners());
            myCfg.setPeerClassLoadingMissedResourcesCacheSize(cfg.getPeerClassLoadingMissedResourcesCacheSize());
            myCfg.setIncludeEventTypes(cfg.getIncludeEventTypes());
            myCfg.setDaemon(cfg.isDaemon());
            myCfg.setIncludeProperties(cfg.getIncludeProperties());
            myCfg.setLifeCycleEmailNotification(cfg.isLifeCycleEmailNotification());
            myCfg.setMetricsLogFrequency(cfg.getMetricsLogFrequency());
            myCfg.setNetworkSendRetryDelay(cfg.getNetworkSendRetryDelay());
            myCfg.setNetworkSendRetryCount(cfg.getNetworkSendRetryCount());
            myCfg.setDataCenterId(cfg.getDataCenterId());
            myCfg.setSecurityCredentialsProvider(cfg.getSecurityCredentialsProvider());
            myCfg.setServiceConfiguration(cfg.getServiceConfiguration());
            myCfg.setWarmupClosure(cfg.getWarmupClosure());
            myCfg.setDotNetConfiguration(cfg.getDotNetConfiguration());

            GridClientConnectionConfiguration clientCfg = cfg.getClientConnectionConfiguration();

            if (clientCfg == null) {
                // If client config is not provided then create config copying values from GridConfiguration.
                if (cfg.isRestEnabled()) {
                    clientCfg = new GridClientConnectionConfiguration();

                    clientCfg.setClientMessageInterceptor(cfg.getClientMessageInterceptor());
                    clientCfg.setRestAccessibleFolders(cfg.getRestAccessibleFolders());
                    clientCfg.setRestExecutorService(cfg.getRestExecutorService());
                    clientCfg.setRestExecutorServiceShutdown(cfg.getRestExecutorServiceShutdown());
                    clientCfg.setRestIdleTimeout(cfg.getRestIdleTimeout());
                    clientCfg.setRestJettyPath(cfg.getRestJettyPath());
                    clientCfg.setRestPortRange(cfg.getRestPortRange());
                    clientCfg.setRestSecretKey(cfg.getRestSecretKey());
                    clientCfg.setRestTcpDirectBuffer(cfg.isRestTcpDirectBuffer());
                    clientCfg.setRestTcpHost(cfg.getRestTcpHost());
                    clientCfg.setRestTcpNoDelay(cfg.isRestTcpNoDelay());
                    clientCfg.setRestTcpPort(cfg.getRestTcpPort());
                    clientCfg.setRestTcpReceiveBufferSize(cfg.getRestTcpReceiveBufferSize());
                    clientCfg.setRestTcpSelectorCount(cfg.getRestTcpSelectorCount());
                    clientCfg.setRestTcpSendBufferSize(cfg.getRestTcpSendBufferSize());
                    clientCfg.setRestTcpSendQueueLimit(cfg.getRestTcpSendQueueLimit());
                    clientCfg.setRestTcpSslClientAuth(cfg.isRestTcpSslClientAuth());
                    clientCfg.setRestTcpSslContextFactory(cfg.getRestTcpSslContextFactory());
                    clientCfg.setRestTcpSslEnabled(cfg.isRestTcpSslEnabled());
                }
            }
            else
                clientCfg = new GridClientConnectionConfiguration(clientCfg);


            String ntfStr = GridSystemProperties.getString(GG_LIFECYCLE_EMAIL_NOTIFY);

            if (ntfStr != null)
                myCfg.setLifeCycleEmailNotification(Boolean.parseBoolean(ntfStr));

            // Local host.
            String locHost = GridSystemProperties.getString(GG_LOCAL_HOST);

            myCfg.setLocalHost(F.isEmpty(locHost) ? cfg.getLocalHost() : locHost);

            // Override daemon flag if it was set on the factory.
            if (daemon)
                myCfg.setDaemon(true);

            // Check for deployment mode override.
            String depModeName = GridSystemProperties.getString(GG_DEP_MODE_OVERRIDE);

            if (!F.isEmpty(depModeName)) {
                if (!F.isEmpty(cfg.getCacheConfiguration())) {
                    U.quietAndInfo(log, "Skipping deployment mode override for caches (custom closure " +
                        "execution may not work for console Visor)");
                }
                else {
                    try {
                        GridDeploymentMode depMode = GridDeploymentMode.valueOf(depModeName);

                        if (myCfg.getDeploymentMode() != depMode)
                            myCfg.setDeploymentMode(depMode);
                    }
                    catch (IllegalArgumentException e) {
                        throw new GridException("Failed to override deployment mode using system property " +
                            "(are there any misspellings?)" +
                            "[name=" + GG_DEP_MODE_OVERRIDE + ", value=" + depModeName + ']', e);
                    }
                }
            }

            Map<String, ?> attrs = cfg.getUserAttributes();

            if (attrs == null)
                attrs = Collections.emptyMap();

            MBeanServer mbSrv = cfg.getMBeanServer();

            GridMarshaller marsh = cfg.getMarshaller();

            String[] p2pExclude = cfg.getPeerClassLoadingLocalClassPathExclude();

            GridCommunicationSpi commSpi = cfg.getCommunicationSpi();
            GridDiscoverySpi discoSpi = cfg.getDiscoverySpi();
            GridEventStorageSpi evtSpi = cfg.getEventStorageSpi();
            GridCollisionSpi colSpi = cfg.getCollisionSpi();
            GridAuthenticationSpi authSpi = cfg.getAuthenticationSpi();
            GridSecureSessionSpi sesSpi = cfg.getSecureSessionSpi();
            GridDeploymentSpi deploySpi = cfg.getDeploymentSpi();
            GridCheckpointSpi[] cpSpi = cfg.getCheckpointSpi();
            GridFailoverSpi[] failSpi = cfg.getFailoverSpi();
            GridLoadBalancingSpi[] loadBalancingSpi = cfg.getLoadBalancingSpi();
            GridSwapSpaceSpi swapspaceSpi = cfg.getSwapSpaceSpi();
            GridIndexingSpi[] indexingSpi = cfg.getIndexingSpi();

            execSvc = cfg.getExecutorService();
            sysExecSvc = cfg.getSystemExecutorService();
            p2pExecSvc = cfg.getPeerClassLoadingExecutorService();
            mgmtExecSvc = cfg.getManagementExecutorService();
            ggfsExecSvc = cfg.getGgfsExecutorService();

            if (execSvc == null) {
                isAutoExecSvc = true;

                execSvc = new GridThreadPoolExecutor(
                    "pub-" + cfg.getGridName(),
                    DFLT_PUBLIC_CORE_THREAD_CNT,
                    DFLT_PUBLIC_MAX_THREAD_CNT,
                    DFLT_PUBLIC_KEEP_ALIVE_TIME,
                    new LinkedBlockingQueue<Runnable>(DFLT_PUBLIC_THREADPOOL_QUEUE_CAP));

                // Pre-start all threads as they are guaranteed to be needed.
                ((ThreadPoolExecutor)execSvc).prestartAllCoreThreads();
            }

            if (sysExecSvc == null) {
                isAutoSysSvc = true;

                // Note that since we use 'LinkedBlockingQueue', number of
                // maximum threads has no effect.
                sysExecSvc = new GridThreadPoolExecutor(
                    "sys-" + cfg.getGridName(),
                    DFLT_SYSTEM_CORE_THREAD_CNT,
                    DFLT_SYSTEM_MAX_THREAD_CNT,
                    DFLT_SYSTEM_KEEP_ALIVE_TIME,
                    new LinkedBlockingQueue<Runnable>(DFLT_SYSTEM_THREADPOOL_QUEUE_CAP));

                // Pre-start all threads as they are guaranteed to be needed.
                ((ThreadPoolExecutor)sysExecSvc).prestartAllCoreThreads();
            }

            if (mgmtExecSvc == null) {
                isAutoMgmtSvc = true;

                // Note that since we use 'LinkedBlockingQueue', number of
                // maximum threads has no effect.
                // Note, that we do not pre-start threads here as management pool may
                // not be needed.
                mgmtExecSvc = new GridThreadPoolExecutor(
                    "mgmt-" + cfg.getGridName(),
                    DFLT_MGMT_THREAD_CNT,
                    DFLT_MGMT_THREAD_CNT,
                    0,
                    new LinkedBlockingQueue<Runnable>());
            }

            if (p2pExecSvc == null) {
                isAutoP2PSvc = true;

                // Note that since we use 'LinkedBlockingQueue', number of
                // maximum threads has no effect.
                // Note, that we do not pre-start threads here as class loading pool may
                // not be needed.
                p2pExecSvc = new GridThreadPoolExecutor(
                    "p2p-" + cfg.getGridName(),
                    DFLT_P2P_THREAD_CNT,
                    DFLT_P2P_THREAD_CNT,
                    0,
                    new LinkedBlockingQueue<Runnable>());
            }

            if (ggfsExecSvc == null) {
                isAutoGgfsSvc = true;

                int procCnt = Runtime.getRuntime().availableProcessors();

                // Note that we do not pre-start threads here as ggfs pool may not be needed.
                ggfsExecSvc = new GridThreadPoolExecutor(
                    "ggfs-" + cfg.getGridName(),
                    procCnt,
                    procCnt,
                    0,
                    new LinkedBlockingQueue<Runnable>());
            }

            restExecSvc = clientCfg != null ? clientCfg.getRestExecutorService() : null;

            if (restExecSvc != null && !cfg.isRestEnabled()) {
                U.warn(log, "REST executor service is configured, but REST is disabled in configuration " +
                    "(safely ignoring).");
            }
            else if (restExecSvc == null && clientCfg != null) {
                isAutoRestSvc = true;

                restExecSvc = new GridThreadPoolExecutor(
                    "rest-" + cfg.getGridName(),
                    DFLT_REST_CORE_THREAD_CNT,
                    DFLT_REST_MAX_THREAD_CNT,
                    DFLT_REST_KEEP_ALIVE_TIME,
                    new LinkedBlockingQueue<Runnable>(DFLT_REST_THREADPOOL_QUEUE_CAP)
                );

                clientCfg.setRestExecutorService(restExecSvc);
            }

            execSvcShutdown = cfg.getExecutorServiceShutdown();
            sysSvcShutdown = cfg.getSystemExecutorServiceShutdown();
            mgmtSvcShutdown = cfg.getManagementExecutorServiceShutdown();
            p2pSvcShutdown = cfg.getPeerClassLoadingExecutorServiceShutdown();
            ggfsSvcShutdown = cfg.getGgfsExecutorServiceShutdown();
            restSvcShutdown = clientCfg != null && clientCfg.isRestExecutorServiceShutdown();

            if (marsh == null) {
                if (!U.isHotSpot()) {
                    U.warn(log, "GridOptimizedMarshaller is not supported on this JVM " +
                        "(only Java HotSpot VMs are supported). Switching to standard JDK marshalling - " +
                        "object serialization performance will be significantly slower.",
                        "To enable fast marshalling upgrade to recent 1.6 or 1.7 HotSpot VM release.");

                    marsh = new GridJdkMarshaller();
                }
                else if (!GridOptimizedMarshaller.available()) {
                    U.warn(log, "GridOptimizedMarshaller is not supported on this JVM " +
                        "(only recent 1.6 and 1.7 versions HotSpot VMs are supported). " +
                        "To enable fast marshalling upgrade to recent 1.6 or 1.7 HotSpot VM release. " +
                        "Switching to standard JDK marshalling - " +
                        "object serialization performance will be significantly slower.",
                        "To enable fast marshalling upgrade to recent 1.6 or 1.7 HotSpot VM release.");

                    marsh = new GridJdkMarshaller();
                }
                else
                    marsh = new GridOptimizedMarshaller();
            }
            else if (marsh instanceof GridOptimizedMarshaller && !U.isHotSpot()) {
                U.warn(log, "Using GridOptimizedMarshaller on untested JVM (only Java HotSpot VMs were tested) - " +
                    "object serialization behavior could yield unexpected results.",
                    "Using GridOptimizedMarshaller on untested JVM.");
            }

            myCfg.setUserAttributes(attrs);
            myCfg.setMBeanServer(mbSrv == null ? ManagementFactory.getPlatformMBeanServer() : mbSrv);
            myCfg.setGridLogger(cfgLog);
            myCfg.setMarshaller(marsh);
            myCfg.setMarshalLocalJobs(cfg.isMarshalLocalJobs());
            myCfg.setExecutorService(execSvc);
            myCfg.setSystemExecutorService(sysExecSvc);
            myCfg.setManagementExecutorService(mgmtExecSvc);
            myCfg.setPeerClassLoadingExecutorService(p2pExecSvc);
            myCfg.setGgfsExecutorService(ggfsExecSvc);
            myCfg.setExecutorServiceShutdown(execSvcShutdown);
            myCfg.setSystemExecutorServiceShutdown(sysSvcShutdown);
            myCfg.setManagementExecutorServiceShutdown(mgmtSvcShutdown);
            myCfg.setPeerClassLoadingExecutorServiceShutdown(p2pSvcShutdown);
            myCfg.setGgfsExecutorServiceShutdown(ggfsSvcShutdown);
            myCfg.setNodeId(nodeId);

            GridGgfsConfiguration[] ggfsCfgs = cfg.getGgfsConfiguration();

            if (ggfsCfgs != null) {
                GridGgfsConfiguration[] clone = ggfsCfgs.clone();

                for (int i = 0; i < ggfsCfgs.length; i++)
                    clone[i] = new GridGgfsConfiguration(ggfsCfgs[i]);

                myCfg.setGgfsConfiguration(clone);
            }

            GridStreamerConfiguration[] streamerCfgs = cfg.getStreamerConfiguration();

            if (streamerCfgs != null) {
                GridStreamerConfiguration[] clone = streamerCfgs.clone();

                for (int i = 0; i < streamerCfgs.length; i++)
                    clone[i] = new GridStreamerConfiguration(streamerCfgs[i]);

                myCfg.setStreamerConfiguration(clone);
            }

            if (p2pExclude == null)
                p2pExclude = EMPTY_STR_ARR;

            myCfg.setPeerClassLoadingLocalClassPathExclude(p2pExclude);

            /*
             * Initialize default SPI implementations.
             */

            if (commSpi == null)
                commSpi = new GridTcpCommunicationSpi();

            if (discoSpi == null)
                discoSpi = new GridTcpDiscoverySpi();

            if (discoSpi instanceof GridTcpDiscoverySpi) {
                GridTcpDiscoverySpi tcpDisco = (GridTcpDiscoverySpi)discoSpi;

                if (tcpDisco.getIpFinder() == null)
                    tcpDisco.setIpFinder(new GridTcpDiscoveryMulticastIpFinder());
            }

            if (evtSpi == null)
                evtSpi = new GridMemoryEventStorageSpi();

            if (colSpi == null)
                colSpi = new GridNoopCollisionSpi();

            if (authSpi == null)
                authSpi = new GridNoopAuthenticationSpi();

            if (sesSpi == null)
                sesSpi = new GridNoopSecureSessionSpi();

            if (deploySpi == null)
                deploySpi = new GridLocalDeploymentSpi();

            if (cpSpi == null)
                cpSpi = new GridCheckpointSpi[] {new GridNoopCheckpointSpi()};

            if (failSpi == null)
                failSpi = new GridFailoverSpi[] {new GridAlwaysFailoverSpi()};

            if (loadBalancingSpi == null)
                loadBalancingSpi = new GridLoadBalancingSpi[] {new GridRoundRobinLoadBalancingSpi()};

            if (swapspaceSpi == null) {
                boolean needSwap = false;

                GridCacheConfiguration[] caches = cfg.getCacheConfiguration();

                if (caches != null) {
                    for (GridCacheConfiguration c : caches) {
                        if (c.isSwapEnabled()) {
                            needSwap = true;

                            break;
                        }
                    }
                }

                swapspaceSpi = needSwap ? new GridFileSwapSpaceSpi() : new GridNoopSwapSpaceSpi();
            }

            if (indexingSpi == null)
                indexingSpi = new GridIndexingSpi[] {(GridIndexingSpi)H2_INDEXING.createOptional()};

            myCfg.setCommunicationSpi(commSpi);
            myCfg.setDiscoverySpi(discoSpi);
            myCfg.setCheckpointSpi(cpSpi);
            myCfg.setEventStorageSpi(evtSpi);
            myCfg.setAuthenticationSpi(authSpi);
            myCfg.setSecureSessionSpi(sesSpi);
            myCfg.setDeploymentSpi(deploySpi);
            myCfg.setFailoverSpi(failSpi);
            myCfg.setCollisionSpi(colSpi);
            myCfg.setLoadBalancingSpi(loadBalancingSpi);
            myCfg.setSwapSpaceSpi(swapspaceSpi);
            myCfg.setIndexingSpi(indexingSpi);

            myCfg.setAddressResolver(cfg.getAddressResolver());

            // Set SMTP configuration.
            myCfg.setSmtpFromEmail(cfg.getSmtpFromEmail());
            myCfg.setSmtpHost(cfg.getSmtpHost());
            myCfg.setSmtpPort(cfg.getSmtpPort());
            myCfg.setSmtpSsl(cfg.isSmtpSsl());
            myCfg.setSmtpUsername(cfg.getSmtpUsername());
            myCfg.setSmtpPassword(cfg.getSmtpPassword());
            myCfg.setAdminEmails(cfg.getAdminEmails());

            // REST configuration.
            myCfg.setClientConnectionConfiguration(clientCfg);

            // Portable configuration.
            myCfg.setPortableConfiguration(cfg.getPortableConfiguration());

            // Replication configuration.
            myCfg.setDrSenderHubConfiguration(cfg.getDrSenderHubConfiguration());
            myCfg.setDrReceiverHubConfiguration(cfg.getDrReceiverHubConfiguration());

            // Hadoop configuration.
            myCfg.setHadoopConfiguration(cfg.getHadoopConfiguration());

            // Validate segmentation configuration.
            GridSegmentationPolicy segPlc = cfg.getSegmentationPolicy();

            if (segPlc == RECONNECT) {
                U.warn(log, "RECONNECT segmentation policy is not supported anymore and " +
                    "will be removed in the next major release (will automatically switch to NOOP)");

                segPlc = NOOP;
            }

            // 1. Warn on potential configuration problem: grid is not configured to wait
            // for correct segment after segmentation happens.
            if (!F.isEmpty(cfg.getSegmentationResolvers()) && segPlc == RESTART_JVM && !cfg.isWaitForSegmentOnStart()) {
                U.warn(log, "Found potential configuration problem (forgot to enable waiting for segment" +
                    "on start?) [segPlc=" + segPlc + ", wait=false]");
            }

            myCfg.setSegmentationResolvers(cfg.getSegmentationResolvers());
            myCfg.setSegmentationPolicy(segPlc);
            myCfg.setSegmentCheckFrequency(cfg.getSegmentCheckFrequency());
            myCfg.setWaitForSegmentOnStart(cfg.isWaitForSegmentOnStart());
            myCfg.setAllSegmentationResolversPassRequired(cfg.isAllSegmentationResolversPassRequired());

            // Override SMTP configuration from system properties
            // and environment variables, if specified.
            String fromEmail = GridSystemProperties.getString(GG_SMTP_FROM);

            if (fromEmail != null)
                myCfg.setSmtpFromEmail(fromEmail);

            String smtpHost = GridSystemProperties.getString(GG_SMTP_HOST);

            if (smtpHost != null)
                myCfg.setSmtpHost(smtpHost);

            String smtpUsername = GridSystemProperties.getString(GG_SMTP_USERNAME);

            if (smtpUsername != null)
                myCfg.setSmtpUsername(smtpUsername);

            String smtpPwd = GridSystemProperties.getString(GG_SMTP_PWD);

            if (smtpPwd != null)
                myCfg.setSmtpPassword(smtpPwd);

            int smtpPort = GridSystemProperties.getInteger(GG_SMTP_PORT,-1);

            if(smtpPort != -1)
                myCfg.setSmtpPort(smtpPort);

            myCfg.setSmtpSsl(GridSystemProperties.getBoolean(GG_SMTP_SSL));

            String adminEmails = GridSystemProperties.getString(GG_ADMIN_EMAILS);

            if (adminEmails != null)
                myCfg.setAdminEmails(adminEmails.split(","));

            Collection<String> drSysCaches = new HashSet<>();

            GridDrSenderHubConfiguration sndHubCfg = cfg.getDrSenderHubConfiguration();

            if (sndHubCfg != null && sndHubCfg.getCacheNames() != null) {
                for (String cacheName : sndHubCfg.getCacheNames())
                    drSysCaches.add(CU.cacheNameForDrSystemCache(cacheName));
            }

            GridCacheConfiguration[] cacheCfgs = cfg.getCacheConfiguration();

            boolean hasHadoop = GridComponentType.HADOOP.inClassPath();

            GridCacheConfiguration[] copies;

            if (cacheCfgs != null && cacheCfgs.length > 0) {
                if (!U.discoOrdered(discoSpi) && !U.relaxDiscoveryOrdered())
                    throw new GridException("Discovery SPI implementation does not support node ordering and " +
                        "cannot be used with cache (use SPI with @GridDiscoverySpiOrderSupport annotation, " +
                        "like GridTcpDiscoverySpi)");

                for (GridCacheConfiguration ccfg : cacheCfgs) {
                    if (CU.isDrSystemCache(ccfg.getName()))
                        throw new GridException("Cache name cannot start with \"" + CU.SYS_CACHE_DR_PREFIX +
                            "\" because this prefix is reserved for internal purposes.");

                    if (CU.isHadoopSystemCache(ccfg.getName()))
                        throw new GridException("Cache name cannot be \"" + CU.SYS_CACHE_HADOOP_MR +
                            "\" because it is reserved for internal purposes.");

                    if (ccfg.getDrSenderConfiguration() != null)
                        drSysCaches.add(CU.cacheNameForDrSystemCache(ccfg.getName()));

                    if (CU.isUtilityCache(ccfg.getName()))
                        throw new GridException("Cache name cannot start with \"" + CU.UTILITY_CACHE_NAME +
                            "\" because this prefix is reserved for internal purposes.");
                }

                copies = new GridCacheConfiguration[cacheCfgs.length + drSysCaches.size() + (hasHadoop ? 1 : 0) + 1];

                int cloneIdx = 0;

                if (hasHadoop)
                    copies[cloneIdx++] = CU.hadoopSystemCache();

                for (String drSysCache : drSysCaches)
                    copies[cloneIdx++] = CU.drSystemCache(drSysCache);

                for (GridCacheConfiguration ccfg : cacheCfgs)
                    copies[cloneIdx++] = new GridCacheConfiguration(ccfg);
            }
            else if (!drSysCaches.isEmpty() || hasHadoop) {
                // Populate system caches
                copies = new GridCacheConfiguration[drSysCaches.size() + (hasHadoop ? 1 : 0) + 1];

                int idx = 0;

                if (hasHadoop)
                    copies[idx++] = CU.hadoopSystemCache();

                for (String drSysCache : drSysCaches)
                    copies[idx++] = CU.drSystemCache(drSysCache);
            }
            else
                copies = new GridCacheConfiguration[1];

            // Always add utility cache.
            copies[copies.length - 1] = utilitySystemCache();

            myCfg.setCacheConfiguration(copies);

            myCfg.setCacheSanityCheckEnabled(cfg.isCacheSanityCheckEnabled());

            try {
                // Use reflection to avoid loading undesired classes.
                Class helperCls = Class.forName("org.gridgain.grid.util.GridConfigurationHelper");

                helperCls.getMethod("overrideConfiguration", GridConfiguration.class, Properties.class,
                    String.class, GridLogger.class).invoke(helperCls, myCfg, System.getProperties(), name, log);
            }
            catch (Exception ignored) {
                // No-op.
            }

            if (!drSysCaches.isEmpty()) {
                // Note that since we use 'LinkedBlockingQueue', number of
                // maximum threads has no effect.
                drExecSvc = new GridThreadPoolExecutor(
                    "dr-" + cfg.getGridName(),
                    Math.min(16, drSysCaches.size() * 2),
                    Math.min(16, drSysCaches.size() * 2),
                    DFLT_SYSTEM_KEEP_ALIVE_TIME,
                    new LinkedBlockingQueue<Runnable>(DFLT_SYSTEM_THREADPOOL_QUEUE_CAP));

                // Pre-start all threads as they are guaranteed to be needed.
                ((ThreadPoolExecutor)drExecSvc).prestartAllCoreThreads();
            }

            // Ensure that SPIs support multiple grid instances, if required.
            if (!startCtx.single()) {
                ensureMultiInstanceSupport(deploySpi);
                ensureMultiInstanceSupport(commSpi);
                ensureMultiInstanceSupport(discoSpi);
                ensureMultiInstanceSupport(cpSpi);
                ensureMultiInstanceSupport(evtSpi);
                ensureMultiInstanceSupport(colSpi);
                ensureMultiInstanceSupport(failSpi);
                ensureMultiInstanceSupport(authSpi);
                ensureMultiInstanceSupport(sesSpi);
                ensureMultiInstanceSupport(loadBalancingSpi);
                ensureMultiInstanceSupport(swapspaceSpi);
            }

            // Register GridGain MBean for current grid instance.
            registerFactoryMbean(myCfg.getMBeanServer());

            boolean started = false;

            try {
                GridKernal grid0 = new GridKernal(startCtx.springContext());
View Full Code Here

Examples of org.gridgain.grid.GridConfiguration

public class GridCacheValueBytesPreloadingSelfTest extends GridCommonAbstractTest {
    /** Memory mode. */
    private GridCacheMemoryMode memMode;

    @Override protected GridConfiguration getConfiguration(String gridName) throws Exception {
        GridConfiguration cfg = super.getConfiguration(gridName);

        cfg.setCacheConfiguration(cacheConfiguration(gridName));

        return cfg;
    }
View Full Code Here

Examples of org.gridgain.grid.GridConfiguration

* Partitioned cache nested transaction test.
*/
public class GridCachePartitionedNestedTxTest extends GridCacheNestedTxAbstractTest {
    /** {@inheritDoc} */
    @Override protected GridConfiguration getConfiguration(String gridName) throws Exception {
        GridConfiguration cfg = super.getConfiguration(gridName);

        GridCacheConfiguration cacheCfg = defaultCacheConfiguration();

        cacheCfg.setCacheMode(PARTITIONED);

        // Explicitly set number of backups equal to number of grids.
        cacheCfg.setBackups(1);

        // Query should be executed without ongoing transactions.
        cacheCfg.setWriteSynchronizationMode(FULL_SYNC);

        cfg.setCacheConfiguration(cacheCfg);

        return cfg;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.