Java Code Examples for org.apache.ignite.configuration.IgniteConfiguration#getIgniteInstanceName()

The following examples show how to use org.apache.ignite.configuration.IgniteConfiguration#getIgniteInstanceName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JdbcConnection.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @param cfgUrl Config URL.
 * @param jdbcName Appended to instance name or used as default.
 * @return Ignite config and Spring context.
 */
private IgniteBiTuple<IgniteConfiguration, ? extends GridSpringResourceContext> loadConfiguration(String cfgUrl,
    String jdbcName) {
    try {
        IgniteBiTuple<Collection<IgniteConfiguration>, ? extends GridSpringResourceContext> cfgMap =
            IgnitionEx.loadConfigurations(cfgUrl);

        IgniteConfiguration cfg = F.first(cfgMap.get1());

        if (cfg.getIgniteInstanceName() == null)
            cfg.setIgniteInstanceName(jdbcName);
        else
            cfg.setIgniteInstanceName(cfg.getIgniteInstanceName() + "-" + jdbcName);

        cfg.setClientMode(true); // Force client mode.

        return new IgniteBiTuple<>(cfg, cfgMap.getValue());
    }
    catch (IgniteCheckedException e) {
        throw new IgniteException(e);
    }
}
 
Example 2
Source File: IgniteDatastoreProvider.java    From hibernate-ogm-ignite with GNU Lesser General Public License v2.1 5 votes vote down vote up
private String gridName(String instanceName, URL ingiteConfigUrl, IgniteConfiguration conf) {
	if ( isNotEmpty( instanceName ) ) {
		return instanceName;
	}
	if ( isNotEmpty( conf.getIgniteInstanceName() ) ) {
		return conf.getIgniteInstanceName();
	}
	if ( ingiteConfigUrl != null ) {
		String name = ingiteConfigUrl.getPath();
		return name.replaceAll( "[\\,\\\",:,\\*,\\/,\\\\]", "_" );
	}
	else {
		return UUID.randomUUID().toString();
	}
}
 
Example 3
Source File: VisorBasicConfiguration.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * Create data transfer object for node basic configuration properties.
 *
 * @param ignite Grid.
 * @param c Grid configuration.
 */
public VisorBasicConfiguration(IgniteEx ignite, IgniteConfiguration c) {
    igniteInstanceName = c.getIgniteInstanceName();
    ggHome = getProperty(IGNITE_HOME, c.getIgniteHome());
    locHost = getProperty(IGNITE_LOCAL_HOST, c.getLocalHost());
    marsh = compactClass(c.getMarshaller());
    deployMode = c.getDeploymentMode();
    clientMode = c.isClientMode();
    daemon = boolValue(IGNITE_DAEMON, c.isDaemon());
    jmxRemote = ignite.isJmxRemoteEnabled();
    restart = ignite.isRestartEnabled();
    netTimeout = c.getNetworkTimeout();
    log = compactClass(c.getGridLogger());
    discoStartupDelay = c.getDiscoveryStartupDelay();
    mBeanSrv = compactClass(c.getMBeanServer());
    noAscii = boolValue(IGNITE_NO_ASCII, false);
    noDiscoOrder = boolValue(IGNITE_NO_DISCO_ORDER, false);
    noShutdownHook = boolValue(IGNITE_NO_SHUTDOWN_HOOK, false);
    progName = getProperty(IGNITE_PROG_NAME);
    quiet = boolValue(IGNITE_QUIET, true);
    successFile = getProperty(IGNITE_SUCCESS_FILE);
    updateNtf = boolValue(IGNITE_UPDATE_NOTIFIER, true);
    activeOnStart = c.isActiveOnStart();
    addrRslvr = compactClass(c.getAddressResolver());
    cacheSanityCheckEnabled = c.isCacheSanityCheckEnabled();
    clsLdr = compactClass(c.getClassLoader());
    consistentId = c.getConsistentId() != null ? String.valueOf(c.getConsistentId()) : null;
    failureDetectionTimeout = c.getFailureDetectionTimeout();
    igniteWorkDir = c.getWorkDirectory();
    lateAffAssignment = c.isLateAffinityAssignment();
    marshLocJobs = c.isMarshalLocalJobs();
    metricsUpdateFreq = c.getMetricsUpdateFrequency();
    clientFailureDetectionTimeout = c.getClientFailureDetectionTimeout();
    sndRetryCnt = c.getNetworkSendRetryCount();
    sndRetryDelay = c.getNetworkSendRetryDelay();
    timeSrvPortBase = c.getTimeServerPortBase();
    timeSrvPortRange = c.getTimeServerPortRange();
    utilityCacheKeepAliveTime = c.getUtilityCacheKeepAliveTime();
}
 
Example 4
Source File: ClientStartNodeTask.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override protected Object executeJob(int gridSize, String type) {
    log.info(">>> Starting new grid node [currGridSize=" + gridSize + ", arg=" + type + "]");

    if (type == null)
        throw new IllegalArgumentException("Node type to start should be specified.");

    IgniteConfiguration cfg = getConfig(type);

    // Generate unique for this VM Ignite instance name.
    String igniteInstanceName = cfg.getIgniteInstanceName() + " (" + UUID.randomUUID() + ")";

    // Update Ignite instance name (required to be unique).
    cfg.setIgniteInstanceName(igniteInstanceName);

    // Start new node in current VM.
    Ignite g = G.start(cfg);

    log.info(">>> Grid started [nodeId=" + g.cluster().localNode().id() + ", name='" + g.name() + "']");

    return true;
}
 
Example 5
Source File: IgniteEntityManagerFactoryBean.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
public void setIgnite(IgniteConfiguration igniteConfiguration) {
    String igniteInstanceName = igniteConfiguration.getIgniteInstanceName();
    getJpaPropertyMap().put("org.apache.ignite.hibernate.ignite_instance_name", igniteInstanceName);
    log.info("Ignite instance name [{}] configured as hibernate cache provider", igniteInstanceName);
}
 
Example 6
Source File: IgniteEntityManagerFactoryBean.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
public void setIgnite(IgniteConfiguration igniteConfiguration) {
    String igniteInstanceName = igniteConfiguration.getIgniteInstanceName();
    getJpaPropertyMap().put("org.apache.ignite.hibernate.ignite_instance_name", igniteInstanceName);
    log.info("Ignite instance name [{}] configured as hibernate cache provider", igniteInstanceName);
}
 
Example 7
Source File: IgnitionEx.java    From ignite with Apache License 2.0 3 votes vote down vote up
/**
 * 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 igniteInstanceName Ignite instance name that will override default.
 * @return Started grid. If Spring configuration contains multiple grid instances,
 *      then the 1st found instance is returned.
 * @throws IgniteCheckedException 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 Ignite start(@Nullable String springCfgPath, @Nullable String igniteInstanceName)
    throws IgniteCheckedException {
    if (springCfgPath == null) {
        IgniteConfiguration cfg = new IgniteConfiguration();

        if (cfg.getIgniteInstanceName() == null && !F.isEmpty(igniteInstanceName))
            cfg.setIgniteInstanceName(igniteInstanceName);

        return start(cfg);
    }
    else
        return start(springCfgPath, igniteInstanceName, null, null);
}