/** * Starts all grids specified within given Spring XML configuration file. If grid with given name * is already started, then exception is thrown. In this case all instances that may * have been started so far will be stopped too. * <p> * Usually Spring XML configuration file will contain only one Grid definition. Note that * Grid configuration bean(s) is retrieved form configuration file by type, so the name of * the Grid configuration bean is ignored. * * @param springCfgPath Spring XML configuration file path or URL. * @param gridName Grid name that will override default. * @return Started grid. If Spring configuration contains multiple grid instances, * then the 1st found instance is returned. * @throws GridException If grid could not be started or configuration * 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); }
discoSpi = cfg.getDiscoverySpi(); commSpi = cfg.getCommunicationSpi(); deploySpi = cfg.getDeploymentSpi(); evtSpi = cfg.getEventStorageSpi(); cpSpi = cfg.getCheckpointSpi(); colSpi = cfg.getCollisionSpi(); failSpi = cfg.getFailoverSpi(); authSpi = cfg.getAuthenticationSpi(); sesSpi = cfg.getSecureSessionSpi(); loadBalancingSpi = cfg.getLoadBalancingSpi(); swapSpaceSpi = cfg.getSwapSpaceSpi(); indexingSpi = cfg.getIndexingSpi(); addrRslvr = cfg.getAddressResolver(); adminEmails = cfg.getAdminEmails(); allResolversPassReq = cfg.isAllSegmentationResolversPassRequired(); daemon = cfg.isDaemon(); cacheCfg = cfg.getCacheConfiguration(); cacheSanityCheckEnabled = cfg.isCacheSanityCheckEnabled(); clientCfg = cfg.getClientConnectionConfiguration(); clientMsgInterceptor = cfg.getClientMessageInterceptor(); clockSyncFreq = cfg.getClockSyncFrequency(); clockSyncSamples = cfg.getClockSyncSamples(); dataCenterId = cfg.getDataCenterId(); deployMode = cfg.getDeploymentMode(); discoStartupDelay = cfg.getDiscoveryStartupDelay(); drExecSvc = cfg.getDrExecutorService(); drExecSvcShutdown = cfg.getDrExecutorServiceShutdown(); drRcvHubCfg = cfg.getDrReceiverHubConfiguration() != null ?
/** * Notifies life-cycle beans of grid event. * * @param evt Grid event. * @throws GridException If user threw exception during start. */ @SuppressWarnings({"CatchGenericClass"}) private void notifyLifecycleBeans(GridLifecycleEventType evt) throws GridException { if (!cfg.isDaemon() && cfg.getLifecycleBeans() != null) for (GridLifecycleBean bean : cfg.getLifecycleBeans()) if (bean != null) bean.onLifecycleEvent(evt); }
/** * @param ctx Kernal context. */ public GridClosureProcessor(GridKernalContext ctx) { super(ctx); sysPool = ctx.config().getSystemExecutorService(); pubPool = ctx.config().getExecutorService(); ggfsPool = ctx.config().getGgfsExecutorService(); }
/** * @return Timeout for initial map exchange before preloading. We make it {@code 4} times * bigger than network timeout by default. */ public long preloadExchangeTimeout() { long t1 = gridConfig().getNetworkTimeout() * 4; long t2 = gridConfig().getNetworkTimeout() * gridConfig().getCacheConfiguration().length * 2; long timeout = Math.max(t1, t2); return timeout < 0 ? Long.MAX_VALUE : timeout; }
cfg = new GridConfiguration(); GridConfiguration myCfg = new GridConfiguration(); String ggHome = cfg.getGridGainHome(); U.setWorkDirectory(cfg.getWorkDirectory(), ggHome); assert F.eq(name, cfg.getGridName()); myCfg.setGridName(cfg.getGridName()); UUID nodeId = cfg.getNodeId(); GridLogger cfgLog = initLogger(cfg.getGridLogger(), nodeId); myCfg.setGridGainHome(ggHome); 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());
A.notNull(cfg.getNodeId(), "cfg.getNodeId()"); A.notNull(cfg.getMBeanServer(), "cfg.getMBeanServer()"); A.notNull(cfg.getGridLogger(), "cfg.getGridLogger()"); A.notNull(cfg.getMarshaller(), "cfg.getMarshaller()"); A.notNull(cfg.getExecutorService(), "cfg.getExecutorService()"); A.notNull(cfg.getUserAttributes(), "cfg.getUserAttributes()"); A.notNull(cfg.getSwapSpaceSpi(), "cfg.getSwapSpaceSpi()"); A.notNull(cfg.getCheckpointSpi(), "cfg.getCheckpointSpi()"); A.notNull(cfg.getCommunicationSpi(), "cfg.getCommunicationSpi()"); A.notNull(cfg.getDeploymentSpi(), "cfg.getDeploymentSpi()"); A.notNull(cfg.getDiscoverySpi(), "cfg.getDiscoverySpi()"); A.notNull(cfg.getEventStorageSpi(), "cfg.getEventStorageSpi()"); A.notNull(cfg.getAuthenticationSpi(), "cfg.getAuthenticationSpi()"); A.notNull(cfg.getSecureSessionSpi(), "cfg.getSecureSessionSpi()"); A.notNull(cfg.getCollisionSpi(), "cfg.getCollisionSpi()"); A.notNull(cfg.getFailoverSpi(), "cfg.getFailoverSpi()"); A.notNull(cfg.getLoadBalancingSpi(), "cfg.getLoadBalancingSpi()"); A.notNull(cfg.getIndexingSpi(), "cfg.getIndexingSpi()"); A.ensure(cfg.getNetworkTimeout() > 0, "cfg.getNetworkTimeout() > 0"); A.ensure(cfg.getNetworkSendRetryDelay() > 0, "cfg.getNetworkSendRetryDelay() > 0"); A.ensure(cfg.getNetworkSendRetryCount() > 0, "cfg.getNetworkSendRetryCount() > 0"); A.ensure(cfg.getDataCenterId() >= 0, "cfg.getDataCenterId() >= 0"); A.ensure(cfg.getDataCenterId() < MAX_DATA_CENTERS, "cfg.getDataCenterId() <= 31"); boolean hasHubCfg = cfg.getDrSenderHubConfiguration() != null || cfg.getDrReceiverHubConfiguration() != null;
VisorBasicConfig cfg = new VisorBasicConfig(); cfg.gridName(c.getGridName()); cfg.ggHome(getProperty(GG_HOME, c.getGridGainHome())); cfg.localHost(getProperty(GG_LOCAL_HOST, c.getLocalHost())); cfg.nodeId(g.localNode().id()); cfg.marshaller(compactClass(c.getMarshaller())); cfg.deploymentMode(compactObject(c.getDeploymentMode())); cfg.daemon(boolValue(GG_DAEMON, c.isDaemon())); cfg.jmxRemote(g.isJmxRemoteEnabled()); cfg.restart(g.isRestartEnabled()); cfg.networkTimeout(c.getNetworkTimeout()); cfg.licenseUrl(c.getLicenseUrl()); cfg.logger(compactClass(c.getGridLogger())); cfg.discoStartupDelay(c.getDiscoveryStartupDelay()); cfg.mBeanServer(compactClass(c.getMBeanServer())); cfg.noAscii(boolValue(GG_NO_ASCII, false)); cfg.noDiscoOrder(boolValue(GG_NO_DISCO_ORDER, false)); cfg.successFile(getProperty(GG_SUCCESS_FILE)); cfg.updateNotifier(boolValue(GG_UPDATE_NOTIFIER, true)); cfg.securityCredentialsProvider(compactClass(c.getSecurityCredentialsProvider()));
public void start(final GridConfiguration cfg, @Nullable ExecutorService utilityCachePool, GridAbsClosure errHnd) throws GridException { gw.compareAndSet(null, new GridKernalGatewayImpl(cfg.getGridName())); gridName = cfg.getGridName(); log = (GridLoggerProxy)cfg.getGridLogger().getLogger(getClass().getName() + (gridName != null ? '%' + gridName : "")); GridDiagnostic.runBackgroundCheck(gridName, cfg.getExecutorService(), log); verChecker0.checkForNewVersion(cfg.getExecutorService(), log); if (log.isInfoEnabled() && cfg.getGridGainHome() != null) log.info("3-rd party licenses can be found at: " + cfg.getGridGainHome() + File.separatorChar + "libs" + File.separatorChar + "licenses"); for (String name : cfg.getUserAttributes().keySet()) if (name.startsWith(ATTR_PREFIX)) throw new GridException("User attribute has illegal name: '" + name + "'. Note that all names " + if (!cfg.isDaemon() && cfg.getLifecycleBeans() != null) for (GridLifecycleBean bean : cfg.getLifecycleBeans()) if (bean != null) rsrcProc.inject(bean); addHelper(ctx, GGFS_HELPER.create(F.isEmpty(cfg.getGgfsConfiguration()))); startProcessor(ctx, (GridProcessor)EMAIL.create(ctx, cfg.getSmtpHost() == null), attrs);
/** * Creates resources processor. * * @param ctx Kernal context. */ public GridResourceProcessor(GridKernalContext ctx) { super(ctx); gridInjector = new GridResourceBasicInjector<>(ctx.grid()); ggHomeInjector = new GridResourceBasicInjector<>(ctx.config().getGridGainHome()); ggNameInjector = new GridResourceBasicInjector<>(ctx.config().getGridName()); locHostInjector = new GridResourceBasicInjector<>(ctx.config().getLocalHost()); mbeanSrvInjector = new GridResourceBasicInjector<>(ctx.config().getMBeanServer()); marshInjector = new GridResourceBasicInjector<>(ctx.config().getMarshaller()); execInjector = new GridResourceBasicInjector<Executor>(ctx.config().getExecutorService()); nodeIdInjector = new GridResourceBasicInjector<>(ctx.config().getNodeId()); logInjector = new GridResourceLoggerInjector(ctx.config().getGridLogger()); srvcInjector = new GridResourceServiceInjector(ctx.grid()); addrsRslvrInjector = new GridResourceBasicInjector<>(ctx.config().getAddressResolver()); }
/** * @param g Grid. * @return Data transfer object for node configuration data. */ public static VisorGridConfig from(GridEx g) { assert g != null; GridConfiguration c = g.configuration(); VisorGridConfig cfg = new VisorGridConfig(); cfg.license(VisorLicense.from(g)); cfg.basic(VisorBasicConfig.from(g, c)); cfg.metrics(VisorMetricsConfig.from(c)); cfg.spis(VisorSpisConfig.from(c)); cfg.p2p(VisorPeerToPeerConfig.from(c)); cfg.email(VisorEmailConfig.from(c)); cfg.lifecycle(VisorLifecycleConfig.from(c)); cfg.executeService(VisorExecutorServiceConfig.from(c)); cfg.segmentation(VisorSegmentationConfig.from(c)); cfg.includeProperties(compactArray(c.getIncludeProperties())); cfg.includeEventTypes(c.getIncludeEventTypes()); cfg.rest(VisorRestConfig.from(c)); cfg.userAttributes(c.getUserAttributes()); cfg.caches(VisorCacheConfig.list(c.getCacheConfiguration())); cfg.ggfss(VisorGgfsConfig.list(c.getGgfsConfiguration())); cfg.streamers(VisorStreamerConfig.list(c.getStreamerConfiguration())); cfg.drSenderHub(VisorDrSenderHubConfig.from(c.getDrSenderHubConfiguration())); cfg.drReceiverHub(VisorDrReceiverHubConfig.from(c.getDrReceiverHubConfiguration())); cfg.env(new HashMap<>(getenv())); cfg.systemProperties(getProperties()); return cfg; }
/** * @param cfg Grid configuration. * @return Components provided in configuration which can implement {@link GridLifecycleAware} interface. */ private Iterable<Object> lifecycleAwares(GridConfiguration cfg) { Collection<Object> objs = new ArrayList<>(); if (!F.isEmpty(cfg.getLifecycleBeans())) F.copy(objs, cfg.getLifecycleBeans()); if (!F.isEmpty(cfg.getSegmentationResolvers())) F.copy(objs, cfg.getSegmentationResolvers()); if (cfg.getClientConnectionConfiguration() != null) F.copy(objs, cfg.getClientConnectionConfiguration().getClientMessageInterceptor(), cfg.getClientConnectionConfiguration().getRestTcpSslContextFactory()); F.copy(objs, cfg.getMarshaller(), cfg.getGridLogger(), cfg.getMBeanServer()); return objs; }
/** * * @return {@code True} is this node is daemon. */ private boolean isDaemon() { assert cfg != null; return cfg.isDaemon() || "true".equalsIgnoreCase(System.getProperty(GG_DAEMON)); }
/** * @param c Grid configuration. * @return Data transfer object for node email configuration properties. */ public static VisorEmailConfig from(GridConfiguration c) { VisorEmailConfig cfg = new VisorEmailConfig(); cfg.smtpHost(getProperty(GG_SMTP_HOST, c.getSmtpHost())); cfg.smtpPort(intValue(GG_SMTP_PORT, c.getSmtpPort())); cfg.smtpUsername(getProperty(GG_SMTP_USERNAME, c.getSmtpUsername())); cfg.adminEmails(getProperty(GG_ADMIN_EMAILS, compactArray(c.getAdminEmails()))); cfg.smtpFromEmail(getProperty(GG_SMTP_FROM, c.getSmtpFromEmail())); cfg.smtpSsl(boolValue(GG_SMTP_SSL, c.isSmtpSsl())); cfg.smtpStartTls(boolValue(GG_SMTP_STARTTLS, c.isSmtpStartTls())); return cfg; }
cacheCfg = ctx.config(); locNodeId = ctx.gridConfig().getNodeId(); log = ctx.gridConfig().getGridLogger().getLogger(getClass()); GridGgfsConfiguration[] ggfsCfgs = gridCfg.getGgfsConfiguration(); for (GridCacheConfiguration ccfg : gridCfg.getCacheConfiguration()) { if (ccfg.getDrSenderConfiguration() != null && F.eq(ctx.name(), CU.cacheNameForDrSystemCache(ccfg.getName()))) { GridDrSenderHubConfiguration sndHubCfg = gridCfg.getDrSenderHubConfiguration();
if (gridCfg.isDaemon() || F.isEmpty(gridCfg.getGgfsConfiguration()) || F.isEmpty(gridCfg.getCacheConfiguration())) return; F.forEach(gridCfg.getCacheConfiguration(), new CI1<GridCacheConfiguration>() { @Override public void apply(GridCacheConfiguration c) { cacheCfgs.put(c.getName(), c); assert gridCfg.getGgfsConfiguration() != null; for (GridGgfsConfiguration ggfsCfg : gridCfg.getGgfsConfiguration()) { GridCacheConfiguration cacheCfg = cacheCfgs.get(ggfsCfg.getDataCacheName());
if (ctx.config().isDaemon()) return; GridDhtTransactionalCacheAdapter.DHT_VERSION_IN_FINISH_RESPONSE_SINCE); GridDeploymentMode depMode = ctx.config().getDeploymentMode(); if (!F.isEmpty(ctx.config().getCacheConfiguration())) { if (depMode != CONTINUOUS && depMode != SHARED) U.warn(log, "Deployment mode for cache is not CONTINUOUS or SHARED " + maxPreloadOrder = validatePreloadOrder(ctx.config().getCacheConfiguration()); GridGgfsConfiguration[] ggfsCfgs = ctx.grid().configuration().getGgfsConfiguration(); sysCaches.add(CU.SYS_CACHE_HADOOP_MR); for (GridCacheConfiguration ccfg : ctx.grid().configuration().getCacheConfiguration()) { if (ccfg.getDrSenderConfiguration() != null) sysCaches.add(CU.cacheNameForDrSystemCache(ccfg.getName())); GridDrSenderHubConfiguration sndHubCfg = ctx.grid().configuration().getDrSenderHubConfiguration(); GridCacheConfiguration[] cfgs = ctx.config().getCacheConfiguration();
/** * @return Marshaller. */ public GridMarshaller marshaller() { return ctx.config().getMarshaller(); }
", caches=" + cfg.getCacheConfiguration().length + ']'); GridConfiguration cfg0 = new GridConfiguration(cfg); cfg0.setDiscoverySpi(discoSpi); cfg0.setGridLogger(new GridNullLogger()); cfg0.setGridName("gridgain-warmup-grid-" + i);
if (F.isEmpty(gridCfg.getCacheConfiguration())) return null; GridConfiguration cp = new GridConfiguration(); cp.setClientConnectionConfiguration(null); for (GridCacheConfiguration ccfg : gridCfg.getCacheConfiguration()) { if (CU.isSystemCache(ccfg.getName())) continue; cp.setCacheConfiguration(res);