本文整理汇总了Java中org.apache.ignite.configuration.CacheConfiguration.setNodeFilter方法的典型用法代码示例。如果您正苦于以下问题:Java CacheConfiguration.setNodeFilter方法的具体用法?Java CacheConfiguration.setNodeFilter怎么用?Java CacheConfiguration.setNodeFilter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ignite.configuration.CacheConfiguration
的用法示例。
在下文中一共展示了CacheConfiguration.setNodeFilter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: hadoopSystemCache
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* Create system cache used by Hadoop component.
*
* @return Hadoop cache configuration.
*/
public static CacheConfiguration hadoopSystemCache() {
CacheConfiguration cache = new CacheConfiguration();
cache.setName(CU.SYS_CACHE_HADOOP_MR);
cache.setCacheMode(REPLICATED);
cache.setAtomicityMode(TRANSACTIONAL);
cache.setWriteSynchronizationMode(FULL_SYNC);
cache.setEvictionPolicyFactory(null);
cache.setEvictionPolicy(null);
cache.setCacheStoreFactory(null);
cache.setNodeFilter(CacheConfiguration.ALL_NODES);
cache.setEagerTtl(true);
cache.setRebalanceMode(SYNC);
return cache;
}
示例2: utilitySystemCache
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* Creates utility system cache configuration.
*
* @return Utility system cache configuration.
*/
private static CacheConfiguration utilitySystemCache() {
CacheConfiguration cache = new CacheConfiguration();
cache.setName(CU.UTILITY_CACHE_NAME);
cache.setCacheMode(REPLICATED);
cache.setAtomicityMode(TRANSACTIONAL);
cache.setRebalanceMode(SYNC);
cache.setWriteSynchronizationMode(FULL_SYNC);
cache.setAffinity(new RendezvousAffinityFunction(false, 100));
cache.setNodeFilter(CacheConfiguration.ALL_NODES);
cache.setRebalanceOrder(-2); //Prior to user caches.
cache.setCopyOnRead(false);
return cache;
}
示例3: cacheConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
*
* @param cacheMode Cache mode.
* @param backups Number of backups.
* @param atomicityMode Cache atomicity mode.
* @param filter Filter enabled.
* @return Cache configuration.
*/
private CacheConfiguration<Object, Object> cacheConfiguration(
CacheMode cacheMode,
int backups,
CacheAtomicityMode atomicityMode,
boolean filter) {
CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
ccfg.setAtomicityMode(atomicityMode);
ccfg.setCacheMode(cacheMode);
ccfg.setWriteSynchronizationMode(FULL_SYNC);
if (cacheMode == PARTITIONED)
ccfg.setBackups(backups);
if (filter)
ccfg.setNodeFilter(new P1<ClusterNode>() {
@Override public boolean apply(ClusterNode node) {
return !node.attributes().get(ATTR_IGNITE_INSTANCE_NAME).equals(SERVER2);
}
});
return ccfg;
}
示例4: cacheConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* Get cache configuration.
*
* @param clss QUery classes.
* @return Configuration.
*/
@SuppressWarnings("unchecked")
private static CacheConfiguration cacheConfiguration(Class... clss) {
CacheConfiguration ccfg = new CacheConfiguration().setName(CACHE_NAME).setIndexedTypes(clss);
if (filterNodeName != null) {
ccfg.setNodeFilter(new IgnitePredicate<ClusterNode>() {
@Override public boolean apply(ClusterNode node) {
return node.attribute("AFF_NODE") != null;
}
});
}
return ccfg;
}
示例5: getConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
CacheConfiguration ccfg1 = new CacheConfiguration(DEFAULT_CACHE_NAME);
ccfg1.setBackups(1);
ccfg1.setName(CACHE1);
ccfg1.setAffinity(new RendezvousAffinityFunction());
ccfg1.setNodeFilter(new TestNodesFilter());
CacheConfiguration ccfg2 = new CacheConfiguration(DEFAULT_CACHE_NAME);
ccfg2.setBackups(1);
ccfg2.setName(CACHE2);
ccfg2.setAffinity(new RendezvousAffinityFunction());
CacheConfiguration ccfg4 = new CacheConfiguration(DEFAULT_CACHE_NAME);
ccfg4.setCacheMode(REPLICATED);
ccfg4.setName(CACHE4);
ccfg4.setNodeFilter(new TestNodesFilter());
CacheConfiguration ccfg5 = new CacheConfiguration(DEFAULT_CACHE_NAME);
ccfg5.setBackups(1);
ccfg5.setName(CACHE5);
if (igniteInstanceName.equals(getTestIgniteInstanceName(NODE_CNT - 1))) {
cfg.setClientMode(true);
cfg.setCacheConfiguration(ccfg5);
}
else
cfg.setCacheConfiguration(ccfg1, ccfg2, ccfg4);
return cfg;
}
示例6: cacheConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* Gets cache configuration.
*
* @return Cache configuration.
*/
private CacheConfiguration cacheConfiguration() {
CacheConfiguration cacheCfg = defaultCacheConfiguration();
cacheCfg.setCacheMode(PARTITIONED);
cacheCfg.setBackups(1);
cacheCfg.setWriteSynchronizationMode(FULL_SYNC);
if (noNodesFilter)
cacheCfg.setNodeFilter(F.alwaysFalse());
return cacheCfg;
}
示例7: startNodeWithCache
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* Start first, attribute-bearing, node, create new cache and launch continuous query on it.
*
* @return Node.
* @throws Exception if failed.
*/
private Ignite startNodeWithCache() throws Exception {
Ignite node1 = startGrid("node1", getConfiguration("node1", true, null));
CacheConfiguration<Integer, Integer> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
ccfg.setName("attrsTestCache");
ccfg.setNodeFilter(new IgnitePredicate<ClusterNode>() {
/** {@inheritDoc} */
@Override public boolean apply(ClusterNode node) {
return "data".equals(node.attribute("node-type"));
}
});
IgniteCache<Integer, Integer> cache = node1.createCache(ccfg);
ContinuousQuery<Integer, Integer> qry = new ContinuousQuery<>();
qry.setRemoteFilterFactory(new RemoteFilterFactory());
qry.setLocalListener(new CacheEntryUpdatedListener<Integer, Integer>() {
/** {@inheritDoc} */
@Override public void onUpdated(Iterable<CacheEntryEvent<? extends Integer, ? extends Integer>> evts) {
// No-op.
}
});
RemoteFilterFactory.clsLdr = getExternalClassLoader();
cache.query(qry);
// Switch class loader before starting the second node.
RemoteFilterFactory.clsLdr = getClass().getClassLoader();
return node1;
}
示例8: loadExternalClassesToCfg
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
*
* @param cacheCfg Configuration.
*/
private void loadExternalClassesToCfg(CacheConfiguration cacheCfg) {
try {
Object sf = getExternalClassLoader().
loadClass("org.apache.ignite.tests.p2p.CacheDeploymentTestStoreFactory").newInstance();
cacheCfg.setCacheStoreFactory((Factory)sf);
Object sslf = getExternalClassLoader().
loadClass("org.apache.ignite.tests.p2p.CacheDeploymentStoreSessionListenerFactory").newInstance();
cacheCfg.setCacheStoreSessionListenerFactories((Factory)sslf);
Object cpc = getExternalClassLoader().
loadClass("org.apache.ignite.tests.p2p.CacheDeploymentCachePluginConfiguration").newInstance();
cacheCfg.setPluginConfigurations((CachePluginConfiguration)cpc);
Object akm = getExternalClassLoader().
loadClass("org.apache.ignite.tests.p2p.CacheDeploymentAffinityKeyMapper").newInstance();
cacheCfg.setAffinityMapper((AffinityKeyMapper)akm);
Object pred = getExternalClassLoader().
loadClass("org.apache.ignite.tests.p2p.CacheDeploymentAlwaysTruePredicate2").newInstance();
cacheCfg.setNodeFilter((IgnitePredicate)pred);
}
catch (Exception e) {
throw new RuntimeException(e);
}
}
示例9: testClientNodeNotInAffinity
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* @throws Exception If failed.
*/
public void testClientNodeNotInAffinity() throws Exception {
checkCache(CACHE1, 2);
checkCache(CACHE2, 2);
checkCache(CACHE4, 3);
checkCache(CACHE5, 2);
Ignite client = ignite(NODE_CNT - 1);
CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
ccfg.setBackups(0);
ccfg.setNodeFilter(new TestNodesFilter());
IgniteCache<Integer, Integer> cache = client.createCache(ccfg);
try {
checkCache(DEFAULT_CACHE_NAME, 1);
}
finally {
cache.destroy();
}
cache = client.createCache(ccfg, new NearCacheConfiguration());
try {
checkCache(DEFAULT_CACHE_NAME, 1);
}
finally {
cache.destroy();
}
}
示例10: getConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
X.println("Ignite instance name: " + igniteInstanceName);
IgniteConfiguration c = super.getConfiguration(igniteInstanceName);
TcpDiscoverySpi disco = new TcpDiscoverySpi();
disco.setIpFinder(ipFinder);
c.setDiscoverySpi(disco);
int i = 0;
CacheConfiguration<?, ?>[] ccs = new CacheConfiguration[4];
for (String name : F.asList("co", "pr", "pe", "pu")) {
CacheConfiguration<?, ?> cc = defaultCacheConfiguration();
cc.setNodeFilter(DATA_NODES_FILTER);
cc.setName(name);
cc.setCacheMode(REPLICATED);
cc.setWriteSynchronizationMode(FULL_SYNC);
cc.setAtomicityMode(TRANSACTIONAL);
cc.setRebalanceMode(SYNC);
cc.setAffinity(new RendezvousAffinityFunction(false, 50));
switch (name) {
case "co":
cc.setIndexedTypes(
Integer.class, Company.class
);
break;
case "pr":
cc.setIndexedTypes(
Integer.class, Product.class
);
break;
case "pe":
cc.setIndexedTypes(
Integer.class, Person.class
);
break;
case "pu":
cc.setIndexedTypes(
AffinityKey.class, Purchase.class
);
break;
}
ccs[i++] = cc;
}
c.setCacheConfiguration(ccs);
return c;
}
示例11: getConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
ccfg.setWriteSynchronizationMode(FULL_SYNC);
ccfg.setCacheMode(REPLICATED);
ccfg.setRebalanceMode(SYNC);
ccfg.setNodeFilter(new TestNodeFilter("A"));
if (attrVal != null) {
Map<String, Object> attrs = new HashMap<>();
attrs.put(ATTR_NAME, attrVal);
cfg.setUserAttributes(attrs);
}
cfg.setCacheConfiguration(ccfg);
return cfg;
}
示例12: testDeployFilter
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* @throws Exception If failed.
*/
public void testDeployFilter() throws Exception {
try {
testAttribute = false;
startGrid(nodeCount());
final IgniteEx kernal = grid(0);
CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
ccfg.setName(DYNAMIC_CACHE_NAME);
ccfg.setNodeFilter(NODE_FILTER);
kernal.createCache(ccfg);
startGrid(nodeCount() + 1);
for (int i = 0; i < 100; i++)
grid(0).cache(DYNAMIC_CACHE_NAME).put(i, i);
for (int i = 0; i < 100; i++)
assertEquals(i, grid(1).cache(DYNAMIC_CACHE_NAME).get(i));
info("Affinity nodes: " + grid(0).affinity(DYNAMIC_CACHE_NAME).mapKeyToPrimaryAndBackups(0));
for (int g = 0; g < nodeCount(); g++) {
for (int i = 0; i < 100; i++) {
assertFalse(grid(g).affinity(DYNAMIC_CACHE_NAME).mapKeyToPrimaryAndBackups(i)
.contains(grid(nodeCount()).cluster().localNode()));
assertFalse(grid(g).affinity(DYNAMIC_CACHE_NAME).mapKeyToPrimaryAndBackups(i)
.contains(grid(nodeCount() + 1).cluster().localNode()));
}
}
awaitPartitionMapExchange();
// Check that cache is not deployed on new node after undeploy.
for (int g = 0; g < nodeCount() + 2; g++) {
final IgniteKernal kernal0 = (IgniteKernal)grid(g);
if (g < nodeCount())
assertNotNull(grid(g).cache(DYNAMIC_CACHE_NAME));
else
GridTestUtils.assertThrows(log, new Callable<Object>() {
@Override public Object call() throws Exception {
return kernal0.getCache(DYNAMIC_CACHE_NAME);
}
}, IllegalArgumentException.class, null);
}
kernal.destroyCache(DYNAMIC_CACHE_NAME);
stopGrid(nodeCount() + 1);
stopGrid(nodeCount());
}
finally {
testAttribute = true;
}
}
示例13: testGetOrCreate
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** {@inheritDoc} */
public void testGetOrCreate() throws Exception {
try {
final CacheConfiguration cfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
cfg.setName(DYNAMIC_CACHE_NAME);
cfg.setNodeFilter(NODE_FILTER);
grid(0).getOrCreateCache(cfg);
grid(0).getOrCreateCache(cfg);
GridTestUtils.assertThrows(log, new Callable<Object>() {
@Override public Object call() throws Exception {
return grid(0).getOrCreateCache(cfg, new NearCacheConfiguration());
}
}, CacheException.class, null);
GridTestUtils.assertThrows(log, new Callable<Object>() {
@Override public Object call() throws Exception {
return grid(0).getOrCreateNearCache(DYNAMIC_CACHE_NAME, new NearCacheConfiguration());
}
}, CacheException.class, null);
testAttribute = false;
startGrid(nodeCount());
startGrid(nodeCount() + 1);
try {
IgniteEx nearGrid = grid(nodeCount());
nearGrid.getOrCreateCache(cfg, new NearCacheConfiguration());
nearGrid.getOrCreateNearCache(DYNAMIC_CACHE_NAME, new NearCacheConfiguration());
GridCacheContext<Object, Object> nCtx = ((IgniteKernal)nearGrid)
.internalCache(DYNAMIC_CACHE_NAME).context();
assertTrue(nCtx.isNear());
assertFalse(nCtx.affinityNode());
IgniteEx clientGrid = grid(nodeCount() + 1);
clientGrid.getOrCreateCache(cfg);
clientGrid.getOrCreateCache(cfg);
GridCacheContext<Object, Object> cCtx = ((IgniteKernal)clientGrid)
.internalCache(DYNAMIC_CACHE_NAME).context();
assertFalse(cCtx.isNear());
assertFalse(cCtx.affinityNode());
}
finally {
stopGrid(nodeCount() + 1);
stopGrid(nodeCount());
}
}
finally {
grid(0).destroyCache(DYNAMIC_CACHE_NAME);
}
}
示例14: notAffinityNode2
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* @param ccfg Cache configuration.
* @throws Exception If failed.
*/
private void notAffinityNode2(final CacheConfiguration ccfg) throws Exception {
log.info("Test with cache: " + ccfg.getName());
IgniteEx ignite0 = grid(0);
IgniteEx ignite1 = grid(1);
assertEquals(2L, ignite1.localNode().order());
ccfg.setNodeFilter(new TestFilterExcludeNode(2));
assertNotNull(ignite0.getOrCreateCache(ccfg));
assertNotNull(ignite1.cache(ccfg.getName()));
awaitPartitionMapExchange();
checkCache(ccfg.getName());
}
示例15: oldestNotAffinityNode1
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* @param ccfg Cache configuration.
* @throws Exception If failed.
*/
private void oldestNotAffinityNode1(final CacheConfiguration ccfg) throws Exception {
log.info("Test with cache: " + ccfg.getName());
IgniteEx ignite = grid(0);
assertEquals(1L, ignite.localNode().order());
ccfg.setNodeFilter(new TestFilterExcludeOldest());
assertNotNull(ignite.getOrCreateCache(ccfg));
awaitPartitionMapExchange();
checkCache(ccfg.getName());
}