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

The following examples show how to use org.apache.ignite.configuration.IgniteConfiguration#setLocalHost() . 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: GridCacheNearReaderPreloadSelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * Create configuration for data node.
 *
 * @param ipFinder IP finder.
 * @param igniteInstanceName Ignite instance name.
 * @return Configuration for data node.
 * @throws IgniteCheckedException If failed.
 */
private IgniteConfiguration dataNode(TcpDiscoveryIpFinder ipFinder, String igniteInstanceName)
    throws Exception {
    CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);

    ccfg.setName(CACHE_NAME);
    ccfg.setCacheMode(PARTITIONED);
    ccfg.setAtomicityMode(TRANSACTIONAL);
    ccfg.setNearConfiguration(new NearCacheConfiguration());
    ccfg.setWriteSynchronizationMode(FULL_SYNC);
    ccfg.setBackups(1);

    IgniteConfiguration cfg = getConfiguration(igniteInstanceName);

    TcpDiscoverySpi spi = new TcpDiscoverySpi();

    spi.setIpFinder(ipFinder);

    cfg.setLocalHost("127.0.0.1");
    cfg.setDiscoverySpi(spi);
    cfg.setCacheConfiguration(ccfg);
    cfg.setIncludeProperties();
    cfg.setConnectorConfiguration(null);

    return cfg;
}
 
Example 2
Source File: GridCacheCommandHandlerSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration() throws Exception {
    // Discovery config.
    TcpDiscoverySpi disco = new TcpDiscoverySpi();

    disco.setIpFinder(new TcpDiscoveryVmIpFinder(true));
    disco.setJoinTimeout(5000);

    // Cache config.
    CacheConfiguration cacheCfg = defaultCacheConfiguration();

    cacheCfg.setCacheMode(CacheMode.LOCAL);

    cacheCfg.setAtomicityMode(atomicityMode());

    // Grid config.
    IgniteConfiguration cfg = super.getConfiguration();

    cfg.setLocalHost("127.0.0.1");

    ConnectorConfiguration clnCfg = new ConnectorConfiguration();
    clnCfg.setHost("127.0.0.1");

    cfg.setConnectorConfiguration(clnCfg);
    cfg.setDiscoverySpi(disco);
    cfg.setCacheConfiguration(cacheCfg); // Add 'null' cache configuration.

    return cfg;
}
 
Example 3
Source File: ParameterTypeInferenceTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String name) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(name);

    cfg.setLocalHost("127.0.0.1");
    cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER));

    return cfg;
}
 
Example 4
Source File: LocalCacheTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * Updates the given ignite configuration and specifies a local cache with persistence enabled.
 *
 * @param cfg Ignite configuration to be updated.
 * @param consistentId Consistent id.
 * @return Updated configuration.
 */
private static IgniteConfiguration prepareConfig(IgniteConfiguration cfg, @Nullable String consistentId) {
    cfg.setLocalHost("127.0.0.1");

    TcpDiscoverySpi disco = new TcpDiscoverySpi();
    disco.setIpFinder(GridCacheAbstractFullApiSelfTest.LOCAL_IP_FINDER);

    cfg.setDiscoverySpi(disco);

    cfg.setPeerClassLoadingEnabled(false);

    DataStorageConfiguration memCfg = new DataStorageConfiguration()
        .setDefaultDataRegionConfiguration(
            new DataRegionConfiguration()
                .setPersistenceEnabled(true)
                .setInitialSize(10L * 1024 * 1024)
                .setMaxSize(10L * 1024 * 1024))
        .setPageSize(4096);

    cfg.setDataStorageConfiguration(memCfg);

    if (consistentId != null) {
        cfg.setIgniteInstanceName(consistentId);
        cfg.setConsistentId(consistentId);
    }

    CacheConfiguration<Object, Object> locCacheCfg = new CacheConfiguration<>("test-local-cache");
    locCacheCfg.setCacheMode(CacheMode.LOCAL);
    cfg.setCacheConfiguration(locCacheCfg);

    return cfg;
}
 
Example 5
Source File: FoldersReuseCompatibilityTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public void apply(IgniteConfiguration cfg) {
    cfg.setLocalHost("127.0.0.1");
    TcpDiscoverySpi disco = new TcpDiscoverySpi();
    disco.setIpFinder(GridCacheAbstractFullApiSelfTest.LOCAL_IP_FINDER);

    cfg.setDiscoverySpi(disco);

    configPersistence(cfg);
}
 
Example 6
Source File: TcpDiscoverySpiWildcardSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    cfg.setLocalHost(null);

    return cfg;
}
 
Example 7
Source File: JdbcStreamingToPublicCacheTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);

    CacheConfiguration<?,?> cache = defaultCacheConfiguration();

    cache.setCacheMode(PARTITIONED);
    cache.setBackups(1);
    cache.setWriteSynchronizationMode(FULL_SYNC);
    cache.setIndexedTypes(
        Integer.class, Integer.class
    );

    cfg.setCacheConfiguration(cache);
    cfg.setLocalHost("127.0.0.1");

    TcpDiscoverySpi disco = new TcpDiscoverySpi();

    TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
    ipFinder.setAddresses(Collections.singleton("127.0.0.1:47500..47501"));

    disco.setIpFinder(ipFinder);

    cfg.setDiscoverySpi(disco);

    cfg.setConnectorConfiguration(new ConnectorConfiguration());

    return cfg;
}
 
Example 8
Source File: IgfsEventsTestSuite.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * Start a grid with the secondary file system.
 *
 * @return Secondary file system handle.
 * @throws Exception If failed.
 */
@Nullable private IgniteFileSystem startSecondary() throws Exception {
    IgniteConfiguration cfg = getConfiguration("grid-secondary", getSecondaryIgfsConfiguration());

    cfg.setLocalHost("127.0.0.1");
    cfg.setPeerClassLoadingEnabled(false);

    Ignite secG = G.start(cfg);

    return secG.fileSystem("igfs-secondary");
}
 
Example 9
Source File: IgfsCachePerBlockLruEvictionPolicySelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * Start a grid with the secondary file system.
 *
 * @throws Exception If failed.
 */
private void startSecondary() throws Exception {
    FileSystemConfiguration igfsCfg = new FileSystemConfiguration();

    igfsCfg.setName(IGFS_SECONDARY);
    igfsCfg.setBlockSize(512);
    igfsCfg.setDefaultMode(PRIMARY);
    igfsCfg.setIpcEndpointConfiguration(SECONDARY_REST_CFG);

    CacheConfiguration dataCacheCfg = defaultCacheConfiguration();

    dataCacheCfg.setCacheMode(PARTITIONED);
    dataCacheCfg.setNearConfiguration(null);
    dataCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    dataCacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(128));
    dataCacheCfg.setBackups(0);
    dataCacheCfg.setAtomicityMode(TRANSACTIONAL);

    CacheConfiguration metaCacheCfg = defaultCacheConfiguration();

    metaCacheCfg.setCacheMode(REPLICATED);
    metaCacheCfg.setNearConfiguration(null);
    metaCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    metaCacheCfg.setAtomicityMode(TRANSACTIONAL);

    igfsCfg.setMetaCacheConfiguration(metaCacheCfg);
    igfsCfg.setDataCacheConfiguration(dataCacheCfg);

    IgniteConfiguration cfg = new IgniteConfiguration();

    cfg.setIgniteInstanceName("grid-secondary");

    TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();

    discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true));

    cfg.setDiscoverySpi(discoSpi);
    cfg.setFileSystemConfiguration(igfsCfg);

    cfg.setLocalHost("127.0.0.1");
    cfg.setConnectorConfiguration(null);

    Ignite g = G.start(cfg);

    secondaryFs = (IgfsImpl)g.fileSystem(IGFS_SECONDARY);
}
 
Example 10
Source File: HadoopAbstractMapReduceTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * Start grid with IGFS.
 *
 * @param igniteInstanceName Ignite instance name.
 * @param igfsName IGFS name
 * @param mode IGFS mode.
 * @param secondaryFs Secondary file system (optional).
 * @param restCfg Rest configuration string (optional).
 * @return Started grid instance.
 * @throws Exception If failed.
 */
protected Ignite startGridWithIgfs(String igniteInstanceName, String igfsName, IgfsMode mode,
    @Nullable IgfsSecondaryFileSystem secondaryFs, @Nullable IgfsIpcEndpointConfiguration restCfg) throws Exception {
    FileSystemConfiguration igfsCfg = new FileSystemConfiguration();

    igfsCfg.setName(igfsName);
    igfsCfg.setBlockSize(IGFS_BLOCK_SIZE);
    igfsCfg.setDefaultMode(mode);
    igfsCfg.setIpcEndpointConfiguration(restCfg);
    igfsCfg.setSecondaryFileSystem(secondaryFs);
    igfsCfg.setPrefetchBlocks(PREFETCH_BLOCKS);
    igfsCfg.setSequentialReadsBeforePrefetch(SEQ_READS_BEFORE_PREFETCH);

    CacheConfiguration dataCacheCfg = defaultCacheConfiguration();

    dataCacheCfg.setName("dataCache");
    dataCacheCfg.setCacheMode(PARTITIONED);
    dataCacheCfg.setNearConfiguration(null);
    dataCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    dataCacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(2));
    dataCacheCfg.setBackups(0);
    dataCacheCfg.setAtomicityMode(TRANSACTIONAL);

    CacheConfiguration metaCacheCfg = defaultCacheConfiguration();

    metaCacheCfg.setName("metaCache");
    metaCacheCfg.setCacheMode(REPLICATED);
    metaCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    metaCacheCfg.setAtomicityMode(TRANSACTIONAL);

    igfsCfg.setDataCacheConfiguration(dataCacheCfg);
    igfsCfg.setMetaCacheConfiguration(metaCacheCfg);

    IgniteConfiguration cfg = new IgniteConfiguration();

    cfg.setIgniteInstanceName(igniteInstanceName);

    TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();

    discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true));

    cfg.setDiscoverySpi(discoSpi);
    cfg.setFileSystemConfiguration(igfsCfg);

    cfg.setLocalHost("127.0.0.1");
    cfg.setConnectorConfiguration(null);

    HadoopConfiguration hadoopCfg = createHadoopConfiguration();

    if (hadoopCfg != null)
        cfg.setHadoopConfiguration(hadoopCfg);

    return G.start(cfg);
}
 
Example 11
Source File: IgfsMetricsSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * Get configuration for a grid with the primary file system.
 *
 * @param idx Node index.
 * @return Configuration.
 * @throws Exception If failed.
 */
@SuppressWarnings("unchecked")
private IgniteConfiguration primaryConfiguration(int idx) throws Exception {
    FileSystemConfiguration igfsCfg = new FileSystemConfiguration();

    igfsCfg.setName(IGFS_PRIMARY);
    igfsCfg.setBlockSize(PRIMARY_BLOCK_SIZE);
    igfsCfg.setDefaultMode(DUAL_SYNC);
    igfsCfg.setSecondaryFileSystem(igfsSecondary.asSecondary());

    Map<String, IgfsMode> pathModes = new HashMap<>();

    pathModes.put("/primary", PRIMARY);

    igfsCfg.setPathModes(pathModes);

    CacheConfiguration dataCacheCfg = defaultCacheConfiguration();

    dataCacheCfg.setCacheMode(PARTITIONED);
    dataCacheCfg.setNearConfiguration(null);
    dataCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    dataCacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(128));
    dataCacheCfg.setBackups(0);
    dataCacheCfg.setAtomicityMode(TRANSACTIONAL);

    CacheConfiguration metaCacheCfg = defaultCacheConfiguration();

    metaCacheCfg.setCacheMode(REPLICATED);
    metaCacheCfg.setNearConfiguration(null);
    metaCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    metaCacheCfg.setAtomicityMode(TRANSACTIONAL);

    igfsCfg.setMetaCacheConfiguration(metaCacheCfg);
    igfsCfg.setDataCacheConfiguration(dataCacheCfg);

    IgniteConfiguration cfg = new IgniteConfiguration();

    cfg.setIgniteInstanceName("grid-" + idx);

    cfg.setFileSystemConfiguration(igfsCfg);

    cfg.setLocalHost("127.0.0.1");

    return cfg;
}
 
Example 12
Source File: BinarySerializationQuerySelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override protected void beforeTest() throws Exception {
    IgniteConfiguration cfg = new IgniteConfiguration();

    cfg.setLocalHost("127.0.0.1");

    TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
    discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true));
    cfg.setDiscoverySpi(discoSpi);

    cfg.setMarshaller(new BinaryMarshaller());

    if (useReflectiveSerializer()) {
        BinaryTypeConfiguration binTypCfg1 = new BinaryTypeConfiguration(EntityPlain.class.getName());
        BinaryTypeConfiguration binTypCfg2 = new BinaryTypeConfiguration(EntitySerializable.class.getName());
        BinaryTypeConfiguration binTypCfg3 = new BinaryTypeConfiguration(EntityExternalizable.class.getName());
        BinaryTypeConfiguration binTypCfg4 = new BinaryTypeConfiguration(EntityBinarylizable.class.getName());
        BinaryTypeConfiguration binTypCfg5 = new BinaryTypeConfiguration(EntityWriteReadObject.class.getName());

        binTypCfg1.setSerializer(new BinaryReflectiveSerializer());
        binTypCfg2.setSerializer(new BinaryReflectiveSerializer());
        binTypCfg3.setSerializer(new BinaryReflectiveSerializer());
        binTypCfg4.setSerializer(new BinaryReflectiveSerializer());
        binTypCfg5.setSerializer(new BinaryReflectiveSerializer());

        List<BinaryTypeConfiguration> binTypCfgs = new ArrayList<>();

        binTypCfgs.add(binTypCfg1);
        binTypCfgs.add(binTypCfg2);
        binTypCfgs.add(binTypCfg3);
        binTypCfgs.add(binTypCfg4);
        binTypCfgs.add(binTypCfg5);

        BinaryConfiguration binCfg = new BinaryConfiguration();

        binCfg.setTypeConfigurations(binTypCfgs);

        cfg.setBinaryConfiguration(binCfg);
    }

    CacheConfiguration cacheCfg = new CacheConfiguration(DEFAULT_CACHE_NAME);

    cacheCfg.setCacheMode(CacheMode.PARTITIONED);
    cacheCfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
    cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    cacheCfg.setRebalanceMode(CacheRebalanceMode.SYNC);

    List<QueryEntity> queryEntities = new ArrayList<>();

    queryEntities.add(entityForClass(EntityPlain.class));
    queryEntities.add(entityForClass(EntitySerializable.class));
    queryEntities.add(entityForClass(EntityExternalizable.class));
    queryEntities.add(entityForClass(EntityBinarylizable.class));
    queryEntities.add(entityForClass(EntityWriteReadObject.class));

    cacheCfg.setQueryEntities(queryEntities);

    cfg.setCacheConfiguration(cacheCfg);

    ignite = Ignition.start(cfg);

    cache = ignite.cache(DEFAULT_CACHE_NAME);
}
 
Example 13
Source File: HadoopFIleSystemFactorySelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * Start Ignite node with IGFS instance.
 *
 * @param name Node and IGFS name.
 * @param endpointPort Endpoint port.
 * @param dfltMode Default path mode.
 * @param secondaryFs Secondary file system.
 * @return Igfs instance.
 */
private static IgfsEx start(String name, int endpointPort, IgfsMode dfltMode,
    @Nullable IgfsSecondaryFileSystem secondaryFs) {
    IgfsIpcEndpointConfiguration endpointCfg = new IgfsIpcEndpointConfiguration();

    endpointCfg.setType(IgfsIpcEndpointType.TCP);
    endpointCfg.setHost("127.0.0.1");
    endpointCfg.setPort(endpointPort);

    FileSystemConfiguration igfsCfg = new FileSystemConfiguration();

    igfsCfg.setName(name);
    igfsCfg.setDefaultMode(dfltMode);
    igfsCfg.setIpcEndpointConfiguration(endpointCfg);
    igfsCfg.setSecondaryFileSystem(secondaryFs);

    CacheConfiguration dataCacheCfg = defaultCacheConfiguration();

    dataCacheCfg.setCacheMode(PARTITIONED);
    dataCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    dataCacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(2));
    dataCacheCfg.setBackups(0);
    dataCacheCfg.setAtomicityMode(TRANSACTIONAL);

    CacheConfiguration metaCacheCfg = defaultCacheConfiguration();

    metaCacheCfg.setCacheMode(REPLICATED);
    metaCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    metaCacheCfg.setAtomicityMode(TRANSACTIONAL);

    igfsCfg.setDataCacheConfiguration(dataCacheCfg);
    igfsCfg.setMetaCacheConfiguration(metaCacheCfg);

    if (secondaryFs != null) {
        Map<String, IgfsMode> modes = new HashMap<>();
        modes.put("/ignite/sync/", IgfsMode.DUAL_SYNC);
        modes.put("/ignite/async/", IgfsMode.DUAL_ASYNC);
        modes.put("/ignite/proxy/", IgfsMode.PROXY);

        igfsCfg.setPathModes(modes);
    }

    IgniteConfiguration cfg = new IgniteConfiguration();

    cfg.setIgniteInstanceName(name);

    TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();

    discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true));

    cfg.setDiscoverySpi(discoSpi);
    cfg.setFileSystemConfiguration(igfsCfg);

    cfg.setLocalHost("127.0.0.1");
    cfg.setConnectorConfiguration(null);

    return (IgfsEx)G.start(cfg).fileSystem(name);
}
 
Example 14
Source File: IgfsModesSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * Startup secondary file system.
 *
 * @throws Exception If failed.
 */
private void startUpSecondary() throws Exception {
    FileSystemConfiguration igfsCfg = new FileSystemConfiguration();

    igfsCfg.setName("igfs-secondary");
    igfsCfg.setBlockSize(512 * 1024);
    igfsCfg.setDefaultMode(PRIMARY);

    IgfsIpcEndpointConfiguration endpointCfg = new IgfsIpcEndpointConfiguration();

    endpointCfg.setType(IgfsIpcEndpointType.TCP);
    endpointCfg.setPort(11500);

    CacheConfiguration dataCacheCfg = defaultCacheConfiguration();

    dataCacheCfg.setCacheMode(PARTITIONED);
    dataCacheCfg.setNearConfiguration(null);
    dataCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    dataCacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(128));
    dataCacheCfg.setBackups(0);
    dataCacheCfg.setAtomicityMode(TRANSACTIONAL);

    CacheConfiguration metaCacheCfg = defaultCacheConfiguration();

    metaCacheCfg.setCacheMode(REPLICATED);
    metaCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    metaCacheCfg.setAtomicityMode(TRANSACTIONAL);

    igfsCfg.setMetaCacheConfiguration(metaCacheCfg);
    igfsCfg.setDataCacheConfiguration(dataCacheCfg);

    IgniteConfiguration cfg = new IgniteConfiguration();

    cfg.setIgniteInstanceName("igfs-grid-secondary");

    TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();

    discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true));

    cfg.setDiscoverySpi(discoSpi);
    cfg.setFileSystemConfiguration(igfsCfg);

    cfg.setLocalHost("127.0.0.1");
    cfg.setConnectorConfiguration(null);

    igfsSecondary = (IgfsImpl)G.start(cfg).fileSystem("igfs-secondary");
}
 
Example 15
Source File: TcpClientDiscoverySpiMulticastTest.java    From ignite with Apache License 2.0 3 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    cfg.setLocalHost("127.0.0.1");

    TcpDiscoverySpi spi = new TcpDiscoverySpi();

    TcpDiscoveryMulticastIpFinder ipFinder = new TcpDiscoveryMulticastIpFinder();

    ipFinder.setAddressRequestAttempts(5);

    spi.setIpFinder(ipFinder);

    Boolean clientFlag = client.get();

    client.set(null);

    if (clientFlag != null && clientFlag) {
        cfg.setClientMode(true);

        spi.setForceServerMode(forceSrv);
    }
    else {
        Integer port = discoPort.get();

        discoPort.set(null);

        if (port != null)
            spi.setLocalPort(port);
    }

    cfg.setDiscoverySpi(spi);

    return cfg;
}
 
Example 16
Source File: NoValueClassOnServerAbstractClient.java    From ignite with Apache License 2.0 3 votes vote down vote up
/**
 * @param args Command line arguments.
 * @throws Exception If failed.
 */
public NoValueClassOnServerAbstractClient(String[] args) throws Exception {
    System.out.println("Starting test client node.");

    IgniteConfiguration cfg = new IgniteConfiguration();

    cfg.setPeerClassLoadingEnabled(false);

    cfg.setClientMode(true);

    cfg.setLocalHost("127.0.0.1");

    TcpDiscoverySpi disco = new TcpDiscoverySpi();

    TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();

    ipFinder.setAddresses(Arrays.asList("127.0.0.1:47500..47509"));

    disco.setIpFinder(ipFinder);

    cfg.setDiscoverySpi(disco);

    ignite = Ignition.start(cfg);

    System.out.println("Test external node started");

    log = ignite.log().getLogger(getClass());

    log.info("Started node [id=" + ignite.cluster().localNode().id() +
        ", marsh=" + ignite.configuration().getMarshaller().getClass().getSimpleName() + ']');
}
 
Example 17
Source File: MemcacheRestExampleNodeStartup.java    From ignite with Apache License 2.0 3 votes vote down vote up
/**
 * Create Ignite configuration with IGFS and enabled IPC.
 *
 * @return Ignite configuration.
 * @throws IgniteException If configuration creation failed.
 */
public static IgniteConfiguration configuration() throws IgniteException {
    IgniteConfiguration cfg = new IgniteConfiguration();

    cfg.setLocalHost("127.0.0.1");
    cfg.setDeploymentMode(SHARED);
    cfg.setPeerClassLoadingEnabled(true);

    cfg.setConnectorConfiguration(new ConnectorConfiguration());

    CacheConfiguration cacheCfg = new CacheConfiguration();

    cacheCfg.setName("default");
    cacheCfg.setAtomicityMode(TRANSACTIONAL);
    cacheCfg.setWriteSynchronizationMode(FULL_SYNC);
    cacheCfg.setRebalanceMode(SYNC);
    cacheCfg.setAtomicityMode(TRANSACTIONAL);

    cfg.setCacheConfiguration(cacheCfg);

    TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();

    TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();

    ipFinder.setAddresses(Collections.singletonList("127.0.0.1:47500..47509"));

    discoSpi.setIpFinder(ipFinder);

    cfg.setDiscoverySpi(discoSpi);

    return cfg;
}
 
Example 18
Source File: QueryEntityCaseMismatchTest.java    From ignite with Apache License 2.0 2 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);

    cfg.setLocalHost("127.0.0.1");

    cfg.setPeerClassLoadingEnabled(true);

    TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
    ipFinder.setAddresses(Collections.singletonList("127.0.0.1:47500..47509"));

    TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();

    discoSpi.setIpFinder(ipFinder);

    cfg.setDiscoverySpi(discoSpi);

    CacheConfiguration<Object, Integer> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);

    cfg.setMarshaller(new BinaryMarshaller());

    QueryEntity queryEntity = new QueryEntity("KeyType", Integer.class.getName());

    LinkedHashMap<String, String> fields = new LinkedHashMap<>();

    fields.put("a", "TypeA");
    fields.put("b", "TypeB");

    queryEntity.setFields(fields);

    //Specify key fields in upper register
    HashSet<String> keyFields = new HashSet<>();

    keyFields.add("a");
    keyFields.add("B");

    queryEntity.setKeyFields(keyFields);

    ccfg.setQueryEntities(F.asList(queryEntity));

    cfg.setCacheConfiguration(ccfg);

    return cfg;
}
 
Example 19
Source File: AgentClusterDemo.java    From ignite with Apache License 2.0 2 votes vote down vote up
/**
 * Configure node.
 *
 * @param basePort Base port.
 * @param gridIdx Ignite instance name index.
 * @param client If {@code true} then start client node.
 * @return IgniteConfiguration
 */
private static IgniteConfiguration igniteConfiguration(int basePort, int gridIdx, boolean client)
    throws IgniteCheckedException {
    IgniteConfiguration cfg = new IgniteConfiguration();

    cfg.setGridLogger(new Slf4jLogger());

    cfg.setIgniteInstanceName((client ? CLN_NODE_NAME : SRV_NODE_NAME) + gridIdx);
    cfg.setLocalHost("127.0.0.1");
    cfg.setEventStorageSpi(new MemoryEventStorageSpi());
    cfg.setConsistentId(cfg.getIgniteInstanceName());

    File workDir = new File(U.workDirectory(null, null), "demo-work");

    cfg.setWorkDirectory(workDir.getAbsolutePath());

    int[] evts = new int[EVTS_DISCOVERY.length + VISOR_TASK_EVTS.length];

    System.arraycopy(EVTS_DISCOVERY, 0, evts, 0, EVTS_DISCOVERY.length);
    System.arraycopy(VISOR_TASK_EVTS, 0, evts, EVTS_DISCOVERY.length, VISOR_TASK_EVTS.length);

    cfg.setIncludeEventTypes(evts);

    cfg.getConnectorConfiguration().setPort(basePort);

    System.setProperty(IGNITE_JETTY_PORT, String.valueOf(basePort + 10));

    TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();

    int discoPort = basePort + 20;

    ipFinder.setAddresses(Collections.singletonList("127.0.0.1:" + discoPort + ".." + (discoPort + NODE_CNT - 1)));

    // Configure discovery SPI.
    TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();

    discoSpi.setLocalPort(discoPort);
    discoSpi.setIpFinder(ipFinder);

    cfg.setDiscoverySpi(discoSpi);

    TcpCommunicationSpi commSpi = new TcpCommunicationSpi();

    commSpi.setSharedMemoryPort(-1);
    commSpi.setMessageQueueLimit(10);

    int commPort = basePort + 30;

    commSpi.setLocalPort(commPort);

    cfg.setCommunicationSpi(commSpi);
    cfg.setGridLogger(new Slf4jLogger(log));
    cfg.setMetricsLogFrequency(0);

    DataRegionConfiguration dataRegCfg = new DataRegionConfiguration();
    dataRegCfg.setName("demo");
    dataRegCfg.setMetricsEnabled(true);
    dataRegCfg.setMaxSize(DFLT_DATA_REGION_INITIAL_SIZE);
    dataRegCfg.setPersistenceEnabled(true);

    DataStorageConfiguration dataStorageCfg = new DataStorageConfiguration();
    dataStorageCfg.setMetricsEnabled(true);
    dataStorageCfg.setStoragePath(PdsConsistentIdProcessor.DB_DEFAULT_FOLDER);
    dataStorageCfg.setDefaultDataRegionConfiguration(dataRegCfg);
    dataStorageCfg.setSystemRegionMaxSize(DFLT_DATA_REGION_INITIAL_SIZE);

    dataStorageCfg.setWalMode(LOG_ONLY);
    dataStorageCfg.setWalSegments(WAL_SEGMENTS);
    dataStorageCfg.setWalSegmentSize(WAL_SEGMENT_SZ);

    cfg.setDataStorageConfiguration(dataStorageCfg);

    cfg.setClientMode(client);

    return cfg;
}
 
Example 20
Source File: IgniteHadoopFileSystemHandshakeSelfTest.java    From ignite with Apache License 2.0 2 votes vote down vote up
/**
 * Create Grid configuration.
 *
 * @param dfltIgniteInstanceName Default Ignite instance name.
 * @return Grid configuration.
 * @throws Exception If failed.
 */
private IgniteConfiguration gridConfiguration(boolean dfltIgniteInstanceName)
    throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(dfltIgniteInstanceName ? null : IGNITE_INSTANCE_NAME);

    cfg.setLocalHost("127.0.0.1");
    cfg.setConnectorConfiguration(null);

    TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();

    discoSpi.setIpFinder(IP_FINDER);

    cfg.setDiscoverySpi(discoSpi);

    TcpCommunicationSpi commSpi = new TcpCommunicationSpi();

    commSpi.setSharedMemoryPort(-1);

    cfg.setCommunicationSpi(commSpi);

    CacheConfiguration metaCacheCfg = defaultCacheConfiguration();

    metaCacheCfg.setCacheMode(REPLICATED);
    metaCacheCfg.setWriteSynchronizationMode(FULL_SYNC);
    metaCacheCfg.setAtomicityMode(TRANSACTIONAL);

    CacheConfiguration dataCacheCfg = defaultCacheConfiguration();

    dataCacheCfg.setCacheMode(PARTITIONED);
    dataCacheCfg.setNearConfiguration(null);
    dataCacheCfg.setWriteSynchronizationMode(FULL_SYNC);
    dataCacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(128));
    dataCacheCfg.setBackups(0);
    dataCacheCfg.setAtomicityMode(TRANSACTIONAL);

    FileSystemConfiguration igfsCfg = new FileSystemConfiguration();

    igfsCfg.setName(IGFS_NAME);
    igfsCfg.setPrefetchBlocks(1);
    igfsCfg.setDefaultMode(PRIMARY);
    igfsCfg.setDataCacheConfiguration(dataCacheCfg);
    igfsCfg.setMetaCacheConfiguration(metaCacheCfg);

    IgfsIpcEndpointConfiguration endpointCfg = new IgfsIpcEndpointConfiguration();

    endpointCfg.setType(IgfsIpcEndpointType.TCP);
    endpointCfg.setPort(DFLT_IPC_PORT);

    igfsCfg.setIpcEndpointConfiguration(endpointCfg);

    igfsCfg.setManagementPort(-1);
    igfsCfg.setBlockSize(512 * 1024);

    cfg.setFileSystemConfiguration(igfsCfg);

    return cfg;
}