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

The following examples show how to use org.apache.ignite.configuration.IgniteConfiguration#setUserAttributes() . 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: GridCachePreloadingEvictionsSelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    CacheConfiguration partCacheCfg = defaultCacheConfiguration();

    partCacheCfg.setCacheMode(PARTITIONED);
    partCacheCfg.setAffinity(new GridCacheModuloAffinityFunction(1, 1));
    partCacheCfg.setWriteSynchronizationMode(FULL_SYNC);
    partCacheCfg.setNearConfiguration(null);
    partCacheCfg.setEvictionPolicy(null);
    partCacheCfg.setRebalanceMode(ASYNC);
    partCacheCfg.setAtomicityMode(TRANSACTIONAL);

    // This test requires artificial slowing down of the preloading.
    partCacheCfg.setRebalanceThrottle(2000);

    cfg.setCacheConfiguration(partCacheCfg);

    cfg.setUserAttributes(F.asMap(GridCacheModuloAffinityFunction.IDX_ATTR, idxGen.getAndIncrement()));

    cfg.setNetworkTimeout(60000);

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

    CacheConfiguration ccfg = defaultCacheConfiguration();

    ccfg.setName(cacheName);
    ccfg.setCacheMode(cacheMode);
    ccfg.setAtomicityMode(TRANSACTIONAL);
    ccfg.setNodeFilter(new AttributeFilter(cacheName));

    if (cacheMode == PARTITIONED)
        ccfg.setBackups(1);

    cfg.setCacheConfiguration(ccfg);

    cfg.setUserAttributes(F.asMap(TEST_ATTRIBUTE, cacheName));

    return cfg;
}
 
Example 3
Source File: AffinityFunctionBackupFilterAbstractSelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    CacheConfiguration cacheCfg = defaultCacheConfiguration();

    cacheCfg.setCacheMode(PARTITIONED);
    cacheCfg.setBackups(backups);

    if (backups < 2)
        cacheCfg.setAffinity(affinityFunction());
    else
        cacheCfg.setAffinity(affinityFunctionWithAffinityBackupFilter(SPLIT_ATTRIBUTE_NAME));

    cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    cacheCfg.setRebalanceMode(SYNC);
    cacheCfg.setAtomicityMode(TRANSACTIONAL);

    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    cfg.setCacheConfiguration(cacheCfg);
    cfg.setUserAttributes(F.asMap(SPLIT_ATTRIBUTE_NAME, splitAttrVal));

    return cfg;
}
 
Example 4
Source File: GridCacheContinuousQueryNodesFilteringTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @param name Node name.
 * @param setAttr Flag indicating whether node user attribute should be set.
 * @param log Logger.
 * @return Node configuration w/specified name.
 * @throws Exception If failed.
 */
private IgniteConfiguration getConfiguration(String name, boolean setAttr, GridStringLogger log) throws Exception {
    IgniteConfiguration cfg = optimize(getConfiguration(name));

    if (setAttr)
        cfg.setUserAttributes(Collections.singletonMap("node-type", "data"));

    cfg.setGridLogger(log);

    return cfg;
}
 
Example 5
Source File: CacheBaselineTopologyTest.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.setConsistentId(igniteInstanceName);

    if (disableAutoActivation)
        cfg.setAutoActivationEnabled(false);

    cfg.setDataStorageConfiguration(
        new DataStorageConfiguration().setDefaultDataRegionConfiguration(
            new DataRegionConfiguration()
                .setPersistenceEnabled(true)
                .setMaxSize(100L * 1024 * 1024)
                .setInitialSize(100L * 1024 * 1024)
        )
        .setDataRegionConfigurations(
            new DataRegionConfiguration()
            .setName("memory")
            .setPersistenceEnabled(false)
            .setMaxSize(100L * 1024 * 1024)
            .setInitialSize(100L * 1024 * 1024)
        )
        .setWalMode(WALMode.LOG_ONLY)
    );

    if (userAttrs != null)
        cfg.setUserAttributes(userAttrs);

    return cfg;
}
 
Example 6
Source File: TxOptimisticReadThroughTest.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);

    // Different adresses not to pickup only first node when searching value wihit transaction.
    cfg.setUserAttributes(Collections.singletonMap(
        IgniteNodeAttributes.ATTR_MACS_OVERRIDE, UUID.randomUUID().toString()));

    return cfg;
}
 
Example 7
Source File: GridCachePartitionedStorePutSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    MvccFeatureChecker.skipIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE);

    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    cfg.setCacheConfiguration(cacheConfiguration());
    cfg.setUserAttributes(F.asMap(IDX_ATTR, CNT.getAndIncrement()));

    return cfg;
}
 
Example 8
Source File: DynamicColumnsAbstractConcurrentSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * Create server configuration.
 * @param nodeIdx Node index.
 * @param filtered Whether this node should not be treated as affinity node.
 * @return Configuration.
 * @throws Exception if failed.
 */
private IgniteConfiguration serverConfiguration(int nodeIdx, boolean filtered) throws Exception {
    IgniteConfiguration cfg = serverConfiguration(nodeIdx);

    if (filtered)
        cfg.setUserAttributes(Collections.singletonMap(ATTR_FILTERED, true));

    return cfg;
}
 
Example 9
Source File: DynamicEnableIndexingAbstractTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** */
protected IgniteConfiguration serverConfiguration(int idx, boolean filter) throws Exception {
    IgniteConfiguration cfg = commonConfiguration(idx);

    if (filter)
        cfg.setUserAttributes(Collections.singletonMap(ATTR_FILTERED, true));

    return cfg;
}
 
Example 10
Source File: WalModeChangeCommonAbstractSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * Create node configuration.
 *
 * @param name Name.
 * @param cli Client flag.
 * @param filter Whether node should be filtered out.
 * @return Node configuration.
 */
protected IgniteConfiguration config(String name, boolean cli, boolean filter) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(name);

    cfg.setIgniteInstanceName(name);
    cfg.setClientMode(cli);
    cfg.setLocalHost("127.0.0.1");

    DataRegionConfiguration regionCfg = new DataRegionConfiguration()
        .setPersistenceEnabled(true)
        .setMaxSize(DataStorageConfiguration.DFLT_DATA_REGION_INITIAL_SIZE);

    DataRegionConfiguration volatileRegionCfg = new DataRegionConfiguration().setName(REGION_VOLATILE)
        .setPersistenceEnabled(false);

    DataStorageConfiguration storageCfg = new DataStorageConfiguration();

    storageCfg.setDefaultDataRegionConfiguration(regionCfg);
    storageCfg.setDataRegionConfigurations(volatileRegionCfg);

    cfg.setDataStorageConfiguration(storageCfg);

    if (filter)
        cfg.setUserAttributes(Collections.singletonMap(FILTER_ATTR, true));

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

        cfg.setNetworkTimeout(2000);

        cfg.setMarshaller(new JdkMarshaller());

        CacheConfiguration repCacheCfg = defaultCacheConfiguration();

        repCacheCfg.setName("replicated");
        repCacheCfg.setCacheMode(REPLICATED);
        repCacheCfg.setRebalanceMode(mode);
        repCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
        repCacheCfg.setAtomicityMode(TRANSACTIONAL);

        // TODO GG-10884.
//        if (offheap)
//            repCacheCfg.setOffHeapMaxMemory(OFFHEAP);
//        else
//            repCacheCfg.setSwapEnabled(true);

        CacheConfiguration partCacheCfg = defaultCacheConfiguration();

        partCacheCfg.setName("partitioned");
        partCacheCfg.setCacheMode(PARTITIONED);
        partCacheCfg.setRebalanceMode(mode);
        partCacheCfg.setAffinity(new GridCacheModuloAffinityFunction(11, 1));
        partCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
        partCacheCfg.setAtomicityMode(TRANSACTIONAL);

        // TODO GG-10884.
//        if (offheap)
//            partCacheCfg.setOffHeapMaxMemory(OFFHEAP);
//        else
//            partCacheCfg.setSwapEnabled(true);

        cfg.setCacheConfiguration(repCacheCfg, partCacheCfg);

        cfg.setDeploymentMode(SHARED);
        cfg.setPeerClassLoadingLocalClassPathExclude(GridCacheP2PUndeploySelfTest.class.getName());

        cfg.setUserAttributes(F.asMap(GridCacheModuloAffinityFunction.IDX_ATTR, idxGen.getAndIncrement()));

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

    DataStorageConfiguration memCfg = new DataStorageConfiguration().setDefaultDataRegionConfiguration(
        new DataRegionConfiguration().setMaxSize(20L * 1024 * 1024));

    cfg.setDataStorageConfiguration(memCfg);

    /** Clients cache */
    CacheConfiguration<ClientKey, Client> clientCfg = new CacheConfiguration<>();
    clientCfg.setName("cl");
    clientCfg.setWriteSynchronizationMode(FULL_SYNC);
    clientCfg.setAtomicityMode(TRANSACTIONAL);
    clientCfg.setRebalanceMode(SYNC);
    clientCfg.setBackups(2);
    clientCfg.setAffinity(AFFINITY);
    clientCfg.setIndexedTypes(ClientKey.class, Client.class);

    /** Deposits cache */
    CacheConfiguration<DepositKey, Deposit> depoCfg = new CacheConfiguration<>();
    depoCfg.setName("de");
    depoCfg.setWriteSynchronizationMode(FULL_SYNC);
    depoCfg.setAtomicityMode(TRANSACTIONAL);
    depoCfg.setRebalanceMode(SYNC);
    depoCfg.setBackups(2);
    depoCfg.setAffinity(AFFINITY);
    depoCfg.setIndexedTypes(DepositKey.class, Deposit.class);

    /** Regions cache. Uses default affinity. */
    CacheConfiguration<Integer, Region> regionCfg = new CacheConfiguration<>();
    regionCfg.setName("re");
    regionCfg.setWriteSynchronizationMode(FULL_SYNC);
    regionCfg.setAtomicityMode(TRANSACTIONAL);
    regionCfg.setRebalanceMode(SYNC);
    regionCfg.setCacheMode(CacheMode.REPLICATED);
    regionCfg.setIndexedTypes(Integer.class, Region.class);

    cfg.setCacheConfiguration(clientCfg, depoCfg, regionCfg);

    if (!"client".equals(gridName)) {
        Integer reg = regionForGrid(gridName);

        cfg.setUserAttributes(F.asMap(REGION_ATTR_NAME, reg));

        log().info("Assigned region " + reg + " to grid " + gridName);
    }

    return cfg;
}
 
Example 13
Source File: WarningOnBigQueryResultsBaseTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName).
        setCacheConfiguration(
            new CacheConfiguration()
                .setName(CACHE0)
                .setSqlSchema("TEST0")
                .setQueryEntities(Collections.singleton(new QueryEntity(Long.class, Long.class)
                    .setTableName("test0")
                    .addQueryField("id", Long.class.getName(), null)
                    .addQueryField("val", Long.class.getName(), null)
                    .setKeyFieldName("id")
                    .setValueFieldName("val")))
                .setAffinity(new RendezvousAffinityFunction(false, 10))
                .setNodeFilter((IgnitePredicate<ClusterNode>)node ->
                    node.attribute(TEST0_ATTR) != null && (boolean)node.attribute(TEST0_ATTR)),
            new CacheConfiguration()
                .setName(CACHE1)
                .setSqlSchema("TEST1")
                .setQueryEntities(Collections.singleton(new QueryEntity(Long.class, Long.class)
                    .setTableName("test1")
                    .addQueryField("id", Long.class.getName(), null)
                    .addQueryField("val", Long.class.getName(), null)
                    .setKeyFieldName("id")
                    .setValueFieldName("val")))
                .setAffinity(new RendezvousAffinityFunction(false, 10))
                .setNodeFilter((IgnitePredicate<ClusterNode>)node ->
                    node.attribute(TEST1_ATTR) != null && (boolean)node.attribute(TEST1_ATTR)));

    if (igniteInstanceName.startsWith("cli")) {
        cfg.setClientMode(true)
            .setClientConnectorConfiguration(new ClientConnectorConfiguration()
                .setPort(CLI_PORT));
    }
    else {
        cfg.setUserAttributes(Collections.singletonMap(
            getTestIgniteInstanceIndex(igniteInstanceName) < 2 ? TEST0_ATTR : TEST1_ATTR, true));
    }

    ListeningTestLogger testLog = new ListeningTestLogger(false, log);
    BigResultsLogListener lst = new BigResultsLogListener();

    testLog.registerListener(lst);

    logListeners.put(igniteInstanceName, lst);

    cfg.setGridLogger(new ListeningTestLogger(false, testLog));

    return cfg;
}
 
Example 14
Source File: ComputeLeaveAwareNodeStartup.java    From gridgain-advanced-examples with Apache License 2.0 4 votes vote down vote up
/**
 * Executes example.
 *
 * @param args Command line arguments, none required.
 */
public static void main(String[] args) {
    IgniteConfiguration cfg = new IgniteConfiguration();

    HashMap<String, Object> attrs = new HashMap<>();
    attrs.put("checkpoint_key", "slave_node");

    cfg.setUserAttributes(attrs);

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

    cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(ipFinder));

    // Configuring checkpoints spi.
    CacheCheckpointSpi checkpointSpi = new CacheCheckpointSpi();

    checkpointSpi.setCacheName("checkpoints");

    // Overriding default checkpoints SPI
    cfg.setCheckpointSpi(checkpointSpi);

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

    if (cfg.isClientMode())
        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setForceServerMode(true);

    cfg.setUserAttributes(F.asMap(TEST_ATTRIBUTE_NAME, testAttribute));

    CacheConfiguration cacheCfg = new CacheConfiguration(DEFAULT_CACHE_NAME);

    cacheCfg.setCacheMode(CacheMode.REPLICATED);

    cacheCfg.setName(STATIC_CACHE_NAME);

    cfg.setCacheConfiguration(cacheCfg);

    cfg.setIncludeEventTypes(EVT_CACHE_STARTED, EVT_CACHE_STOPPED, EventType.EVT_CACHE_NODES_LEFT);

    if (daemon)
        cfg.setDaemon(true);

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

    CacheConfiguration<Object, Object> cacheCfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);

    cacheCfg.setCacheMode(CacheMode.PARTITIONED);

    cacheCfg.setNodeFilter(node -> node.attribute("filter") == null);

    cfg.setCacheConfiguration(cacheCfg);

    if (setExternalLoader)
        cfg.setClassLoader(extLdr);

    if (log != null)
        cfg.setGridLogger(log);

    if (setFilterAttr)
        cfg.setUserAttributes(U.map("filter", 1));

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

    CacheConfiguration cacheCfg = defaultCacheConfiguration();

    cacheCfg.setCacheMode(PARTITIONED);
    cacheCfg.setWriteSynchronizationMode(FULL_SYNC);
    cacheCfg.setRebalanceMode(NONE);

    cacheCfg.setAffinity(aff);
    cacheCfg.setAtomicityMode(atomicityMode());
    cacheCfg.setBackups(aff.backups());

    NearCacheConfiguration nearCfg = new NearCacheConfiguration();

    cacheCfg.setNearConfiguration(nearCfg);

    cfg.setCacheConfiguration(cacheCfg);

    cfg.setUserAttributes(F.asMap(GridCacheModuloAffinityFunction.IDX_ATTR, cntr.getAndIncrement()));

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

    ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1);

    cfg.setPeerClassLoadingEnabled(false);

    cfg.setDeploymentMode(DeploymentMode.CONTINUOUS);

    TcpDiscoverySpi discoverySpi = (TcpDiscoverySpi)cfg.getDiscoverySpi();

    discoverySpi.setAckTimeout(60000);
    discoverySpi.setForceServerMode(true);

    cfg.setDiscoverySpi(discoverySpi);

    if (igniteInstanceName.startsWith("master")) {
        cfg.setUserAttributes(ImmutableMap.of("segment", "master"));

        // For sure.
        failoverSpi.setMaximumFailoverAttempts(100);

        cfg.setFailoverSpi(failoverSpi);
    }
    else if (igniteInstanceName.startsWith("worker")) {
        cfg.setUserAttributes(ImmutableMap.of("segment", "worker"));

        CacheConfiguration cacheCfg = defaultCacheConfiguration();
        cacheCfg.setName("partitioned");
        cacheCfg.setAtomicityMode(atomicityMode());
        cacheCfg.setCacheMode(PARTITIONED);

        cacheCfg.setBackups(backups);

        cacheCfg.setNearConfiguration(nearEnabled ? new NearCacheConfiguration() : null);

        cacheCfg.setWriteSynchronizationMode(FULL_SYNC);

        cfg.setCacheConfiguration(cacheCfg);
    }
    else
        throw new IllegalStateException("Unexpected Ignite instance name: " + igniteInstanceName);

    return cfg;
}
 
Example 19
Source File: GridSpringBeanSerializationSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * @return Grid configuration.
 */
private IgniteConfiguration config() {
    IgniteConfiguration cfg = new IgniteConfiguration();

    cfg.setUserAttributes(F.asMap(ATTR_KEY, true));

    cfg.setConnectorConfiguration(null);

    cfg.setIgniteInstanceName(getTestIgniteInstanceName());

    cfg.setBinaryConfiguration(new BinaryConfiguration());

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

    return cfg;
}
 
Example 20
Source File: CacheDataLossOnPartitionMoveTest.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.setConsistentId(igniteInstanceName);

    cfg.setCommunicationSpi(new TestRecordingCommunicationSpi());

    cfg.setPeerClassLoadingEnabled(true);

    Map<String, Object> attrs = new HashMap<>();

    attrs.put(GRP_ATTR, grp(getTestIgniteInstanceIndex(igniteInstanceName)));

    cfg.setUserAttributes(attrs);

    DataStorageConfiguration memCfg = new DataStorageConfiguration()
        .setDefaultDataRegionConfiguration(
            new DataRegionConfiguration().setPersistenceEnabled(true).setInitialSize(50 * MB).setMaxSize(50 * MB))
        .setWalMode(WALMode.LOG_ONLY);

    cfg.setDataStorageConfiguration(memCfg);

    cfg.setCacheConfiguration(configuration(DEFAULT_CACHE_NAME));

    return cfg;
}