Search in sources :

Example 1 with EVT_CACHE_OBJECT_UNLOCKED

use of org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_UNLOCKED in project ignite by apache.

the class CacheEventSecurityContextTest method checkEvents.

/**
 * Executes specified cache operation on each server node and checks events.
 */
private void checkEvents(ConsumerX<Integer> op, boolean withInitVal, Integer... expEvtTypes) throws Exception {
    IgniteEx crd = grid("crd");
    Set<Integer> evts = Arrays.stream(expEvtTypes).collect(Collectors.toSet());
    // TODO Remove the following workaround after resolving IGNITE-13490.
    if (ATOMIC_CACHE.equals(cacheName) && evts.size() > 1)
        evts.remove(EVT_CACHE_OBJECT_READ);
    if (TRANSACTIONAL_CACHE.equals(cacheName) && !(evts.size() == 1 && evts.contains(EVT_CACHE_OBJECT_READ))) {
        evts.add(EVT_CACHE_OBJECT_LOCKED);
        evts.add(EVT_CACHE_OBJECT_UNLOCKED);
    }
    List<Integer> keys = testNodes().stream().map(node -> keyForNode(crd.affinity(cacheName), KEY_COUNTER, node)).collect(Collectors.toList());
    if (withInitVal)
        keys.forEach(key -> crd.cache(cacheName).put(key, "val"));
    checkEvents(() -> keys.forEach(op), evts);
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) CacheAtomicityMode(org.apache.ignite.cache.CacheAtomicityMode) Arrays(java.util.Arrays) Transaction(org.apache.ignite.transactions.Transaction) ClientTransactions(org.apache.ignite.client.ClientTransactions) IgniteEx(org.apache.ignite.internal.IgniteEx) EVT_CACHE_OBJECT_READ(org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_READ) CACHE_REPLACE(org.apache.ignite.internal.processors.rest.GridRestCommand.CACHE_REPLACE) ClientCache(org.apache.ignite.client.ClientCache) Collections.singletonList(java.util.Collections.singletonList) MutableEntry(javax.cache.processor.MutableEntry) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) SecurityCredentials(org.apache.ignite.plugin.security.SecurityCredentials) Arrays.asList(java.util.Arrays.asList) CACHE_APPEND(org.apache.ignite.internal.processors.rest.GridRestCommand.CACHE_APPEND) CACHE_REMOVE(org.apache.ignite.internal.processors.rest.GridRestCommand.CACHE_REMOVE) Parameterized(org.junit.runners.Parameterized) EVT_CACHE_OBJECT_UNLOCKED(org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_UNLOCKED) GridClientFactory(org.apache.ignite.internal.client.GridClientFactory) Collection(java.util.Collection) IgniteException(org.apache.ignite.IgniteException) TransactionConcurrency(org.apache.ignite.transactions.TransactionConcurrency) Set(java.util.Set) Collectors(java.util.stream.Collectors) CACHE_GET_AND_REMOVE(org.apache.ignite.internal.processors.rest.GridRestCommand.CACHE_GET_AND_REMOVE) IgniteCache(org.apache.ignite.IgniteCache) CACHE_PREPEND(org.apache.ignite.internal.processors.rest.GridRestCommand.CACHE_PREPEND) List(java.util.List) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) GridClientData(org.apache.ignite.internal.client.GridClientData) CacheEntryProcessor(org.apache.ignite.cache.CacheEntryProcessor) CACHE_GET_ALL(org.apache.ignite.internal.processors.rest.GridRestCommand.CACHE_GET_ALL) ClientConfiguration(org.apache.ignite.configuration.ClientConfiguration) CACHE_GET_AND_PUT(org.apache.ignite.internal.processors.rest.GridRestCommand.CACHE_GET_AND_PUT) CACHE_CAS(org.apache.ignite.internal.processors.rest.GridRestCommand.CACHE_CAS) GridClientDataConfiguration(org.apache.ignite.internal.client.GridClientDataConfiguration) RunnableX(org.apache.ignite.testframework.GridTestUtils.RunnableX) GridRestCommand(org.apache.ignite.internal.processors.rest.GridRestCommand) ScanQuery(org.apache.ignite.cache.query.ScanQuery) CACHE_GET(org.apache.ignite.internal.processors.rest.GridRestCommand.CACHE_GET) SecurityCredentialsBasicProvider(org.apache.ignite.plugin.security.SecurityCredentialsBasicProvider) TransactionIsolation(org.apache.ignite.transactions.TransactionIsolation) RunWith(org.junit.runner.RunWith) CACHE_GET_AND_REPLACE(org.apache.ignite.internal.processors.rest.GridRestCommand.CACHE_GET_AND_REPLACE) EntryProcessorException(javax.cache.processor.EntryProcessorException) ArrayList(java.util.ArrayList) Config(org.apache.ignite.client.Config) ClientTransaction(org.apache.ignite.client.ClientTransaction) IgniteClient(org.apache.ignite.client.IgniteClient) EVT_CACHE_QUERY_OBJECT_READ(org.apache.ignite.events.EventType.EVT_CACHE_QUERY_OBJECT_READ) Assume(org.junit.Assume) Collections.singletonMap(java.util.Collections.singletonMap) EVT_CACHE_OBJECT_REMOVED(org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_REMOVED) ImmutableSet.of(com.google.common.collect.ImmutableSet.of) CACHE_REMOVE_ALL(org.apache.ignite.internal.processors.rest.GridRestCommand.CACHE_REMOVE_ALL) EVT_CACHE_OBJECT_PUT(org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT) GridClient(org.apache.ignite.internal.client.GridClient) CACHE_ADD(org.apache.ignite.internal.processors.rest.GridRestCommand.CACHE_ADD) CACHE_PUT_ALL(org.apache.ignite.internal.processors.rest.GridRestCommand.CACHE_PUT_ALL) GridClientConfiguration(org.apache.ignite.internal.client.GridClientConfiguration) Test(org.junit.Test) Ignite(org.apache.ignite.Ignite) CACHE_PUT_IF_ABSENT(org.apache.ignite.internal.processors.rest.GridRestCommand.CACHE_PUT_IF_ABSENT) TRANSACTIONAL(org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL) CACHE_REMOVE_VALUE(org.apache.ignite.internal.processors.rest.GridRestCommand.CACHE_REMOVE_VALUE) Consumer(java.util.function.Consumer) Lock(java.util.concurrent.locks.Lock) Ignition(org.apache.ignite.Ignition) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) CACHE_PUT(org.apache.ignite.internal.processors.rest.GridRestCommand.CACHE_PUT) CACHE_REPLACE_VALUE(org.apache.ignite.internal.processors.rest.GridRestCommand.CACHE_REPLACE_VALUE) ATOMIC(org.apache.ignite.cache.CacheAtomicityMode.ATOMIC) EVT_CACHE_OBJECT_LOCKED(org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_LOCKED) IgniteTransactions(org.apache.ignite.IgniteTransactions) EVT_CACHE_QUERY_EXECUTED(org.apache.ignite.events.EventType.EVT_CACHE_QUERY_EXECUTED) IgniteEx(org.apache.ignite.internal.IgniteEx)

Aggregations

ImmutableSet.of (com.google.common.collect.ImmutableSet.of)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Arrays.asList (java.util.Arrays.asList)1 Collection (java.util.Collection)1 Collections.singletonList (java.util.Collections.singletonList)1 Collections.singletonMap (java.util.Collections.singletonMap)1 List (java.util.List)1 Set (java.util.Set)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Lock (java.util.concurrent.locks.Lock)1 Consumer (java.util.function.Consumer)1 Collectors (java.util.stream.Collectors)1 EntryProcessorException (javax.cache.processor.EntryProcessorException)1 MutableEntry (javax.cache.processor.MutableEntry)1 Ignite (org.apache.ignite.Ignite)1 IgniteCache (org.apache.ignite.IgniteCache)1 IgniteException (org.apache.ignite.IgniteException)1 IgniteTransactions (org.apache.ignite.IgniteTransactions)1 Ignition (org.apache.ignite.Ignition)1