use of org.apache.ignite.configuration.CacheConfiguration in project ignite by apache.
the class GridAffinityProcessor method affinityInfoFromNode.
/**
* Requests {@link AffinityFunction} and {@link AffinityKeyMapper} from remote node.
*
* @param cacheName Name of cache on which affinity is requested.
* @param topVer Topology version.
* @param n Node from which affinity is requested.
* @return Affinity cached function.
* @throws IgniteCheckedException If either local or remote node cannot get deployment for affinity objects.
*/
private AffinityInfo affinityInfoFromNode(String cacheName, AffinityTopologyVersion topVer, ClusterNode n) throws IgniteCheckedException {
GridTuple3<GridAffinityMessage, GridAffinityMessage, GridAffinityAssignment> t = ctx.closure().callAsyncNoFailover(BROADCAST, affinityJob(cacheName, topVer), F.asList(n), true, /*system pool*/
0, false).get();
AffinityFunction f = (AffinityFunction) unmarshall(ctx, n.id(), t.get1());
AffinityKeyMapper m = (AffinityKeyMapper) unmarshall(ctx, n.id(), t.get2());
assert m != null;
// Bring to initial state.
f.reset();
m.reset();
CacheConfiguration ccfg = ctx.cache().cacheConfiguration(cacheName);
return new AffinityInfo(f, m, t.get3(), ctx.cacheObjects().contextForCache(ccfg));
}
use of org.apache.ignite.configuration.CacheConfiguration in project ignite by apache.
the class IgniteDiagnosticMessagesTest method testSeveralLongRunningTxs.
/**
* @throws Exception If failed.
*/
public void testSeveralLongRunningTxs() throws Exception {
int timeout = 3500;
System.setProperty(IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT, String.valueOf(timeout));
try {
testSpi = true;
startGrid(0);
GridStringLogger strLog = this.strLog = new GridStringLogger();
strLog.logLength(1024 * 100);
startGrid(1);
awaitPartitionMapExchange();
CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
ccfg.setWriteSynchronizationMode(FULL_SYNC);
ccfg.setCacheMode(PARTITIONED);
ccfg.setAtomicityMode(TRANSACTIONAL);
final Ignite node0 = ignite(0);
final Ignite node1 = ignite(1);
node0.createCache(ccfg);
UUID id0 = node0.cluster().localNode().id();
TestRecordingCommunicationSpi.spi(node0).blockMessages(GridNearLockResponse.class, node1.name());
IgniteCache<Object, Object> cache = node0.cache(DEFAULT_CACHE_NAME);
int txCnt = 4;
final List<Integer> keys = primaryKeys(cache, txCnt, 0);
final AtomicInteger idx = new AtomicInteger();
IgniteInternalFuture<Long> fut = GridTestUtils.runMultiThreadedAsync(new Callable<Void>() {
@Override
public Void call() throws Exception {
IgniteCache<Object, Object> cache = node1.cache(DEFAULT_CACHE_NAME);
try (Transaction tx = node1.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
Integer key = keys.get(idx.getAndIncrement() % keys.size());
cache.putIfAbsent(key, String.valueOf(key));
tx.commit();
}
return null;
}
}, txCnt * 2, "tx");
U.sleep(timeout * 2);
assertFalse(fut.isDone());
TestRecordingCommunicationSpi.spi(node0).stopBlock();
fut.get();
String log = strLog.toString();
assertTrue(log.contains("Cache entries [cacheId=" + CU.cacheId(DEFAULT_CACHE_NAME) + ", cacheName=" + DEFAULT_CACHE_NAME + "]:"));
assertTrue(countTxKeysInASingleBlock(log) == txCnt);
assertTrue(log.contains("General node info [id=" + id0));
} finally {
System.clearProperty(IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT);
}
}
use of org.apache.ignite.configuration.CacheConfiguration in project ignite by apache.
the class IgniteDiagnosticMessagesTest method checkBasicDiagnosticInfo.
/**
* @throws Exception If failed.
*/
private void checkBasicDiagnosticInfo() throws Exception {
startGrids(3);
client = true;
startGrid(3);
startGrid(4);
CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
ccfg.setWriteSynchronizationMode(FULL_SYNC);
ccfg.setCacheMode(REPLICATED);
ccfg.setAtomicityMode(TRANSACTIONAL);
ignite(0).createCache(ccfg);
awaitPartitionMapExchange();
sendDiagnostic();
for (int i = 0; i < 5; i++) {
final IgniteCache<Object, Object> cache = ignite(i).cache(DEFAULT_CACHE_NAME);
// Put from multiple threads to create multiple connections.
GridTestUtils.runMultiThreaded(new Runnable() {
@Override
public void run() {
for (int j = 0; j < 10; j++) cache.put(ThreadLocalRandom.current().nextInt(), j);
}
}, 10, "cache-thread");
}
sendDiagnostic();
}
use of org.apache.ignite.configuration.CacheConfiguration in project ignite by apache.
the class IgniteDiagnosticMessagesTest method testLongRunning.
/**
* @throws Exception If failed.
*/
public void testLongRunning() throws Exception {
System.setProperty(IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT, "3500");
try {
testSpi = true;
startGrid(0);
GridStringLogger strLog = this.strLog = new GridStringLogger();
startGrid(1);
awaitPartitionMapExchange();
CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
ccfg.setWriteSynchronizationMode(FULL_SYNC);
ccfg.setCacheMode(PARTITIONED);
ccfg.setAtomicityMode(TRANSACTIONAL);
final Ignite node0 = ignite(0);
node0.createCache(ccfg);
final Ignite node1 = ignite(1);
UUID id0 = node0.cluster().localNode().id();
TestRecordingCommunicationSpi.spi(node0).blockMessages(GridNearSingleGetResponse.class, node1.name());
IgniteInternalFuture fut = GridTestUtils.runAsync(new Callable<Void>() {
@Override
public Void call() throws Exception {
Integer key = primaryKey(node0.cache(DEFAULT_CACHE_NAME));
node1.cache(DEFAULT_CACHE_NAME).get(key);
return null;
}
}, "get");
U.sleep(10_000);
assertFalse(fut.isDone());
TestRecordingCommunicationSpi.spi(node0).stopBlock();
fut.get();
String log = strLog.toString();
assertTrue(log.contains("GridPartitionedSingleGetFuture waiting for response [node=" + id0));
assertTrue(log.contains("General node info [id=" + id0));
} finally {
System.clearProperty(IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT);
}
}
use of org.apache.ignite.configuration.CacheConfiguration in project ignite by apache.
the class GridCheckpointManagerAbstractSelfTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
assert igniteInstanceName != null;
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
discoSpi.setIpFinder(IP_FINDER);
cfg.setDiscoverySpi(discoSpi);
if (igniteInstanceName.contains("cache")) {
String cacheName = "test-checkpoints";
CacheConfiguration cacheCfg = defaultCacheConfiguration();
cacheCfg.setName(cacheName);
cacheCfg.setWriteSynchronizationMode(FULL_SYNC);
CacheCheckpointSpi spi = new CacheCheckpointSpi();
spi.setCacheName(cacheName);
cfg.setCacheConfiguration(cacheCfg);
cfg.setCheckpointSpi(spi);
} else if (igniteInstanceName.contains("jdbc")) {
JdbcCheckpointSpi spi = new JdbcCheckpointSpi();
jdbcDataSource ds = new jdbcDataSource();
ds.setDatabase("jdbc:hsqldb:mem:gg_test_" + getClass().getSimpleName());
ds.setUser("sa");
ds.setPassword("");
spi.setDataSource(ds);
spi.setCheckpointTableName("test_checkpoints");
spi.setKeyFieldName("key");
spi.setValueFieldName("value");
spi.setValueFieldType("longvarbinary");
spi.setExpireDateFieldName("expire_date");
cfg.setCheckpointSpi(spi);
}
return cfg;
}
Aggregations