use of org.apache.ignite.internal.IgniteEx in project ignite by apache.
the class IgniteCacheLockPartitionOnAffinityRunTest method testReleasePartitionJobThrowsError.
/**
* @throws Exception If failed.
*/
public void testReleasePartitionJobThrowsError() throws Exception {
final int orgId = primaryKey(grid(1).cache(Organization.class.getSimpleName()));
try {
grid(0).compute().affinityRun(Arrays.asList(Organization.class.getSimpleName(), Person.class.getSimpleName()), new Integer(orgId), new IgniteRunnable() {
@IgniteInstanceResource
IgniteEx ignite;
@Override
public void run() {
try {
checkPartitionsReservations(ignite, orgId, 1);
} catch (Exception e) {
e.printStackTrace();
fail("Unexpected exception");
}
throw new Error("Test job throws error");
}
});
fail("Error must be thrown");
} catch (Throwable ignored) {
checkPartitionsReservations(grid(1), orgId, 0);
}
try {
grid(0).compute().affinityCall(Arrays.asList(Organization.class.getSimpleName(), Person.class.getSimpleName()), new Integer(orgId), new IgniteCallable<Object>() {
@IgniteInstanceResource
IgniteEx ignite;
@Override
public Object call() {
try {
checkPartitionsReservations(ignite, orgId, 1);
} catch (Exception e) {
e.printStackTrace();
fail("Unexpected exception");
}
throw new Error("Test job throws error");
}
});
fail("Error must be thrown");
} catch (Throwable ignored) {
checkPartitionsReservations(grid(1), orgId, 0);
}
}
use of org.apache.ignite.internal.IgniteEx in project ignite by apache.
the class IgniteCacheLockPartitionOnAffinityRunTest method testReleasePartitionJobCompletesNormally.
/**
* @throws Exception If failed.
*/
public void testReleasePartitionJobCompletesNormally() throws Exception {
final int orgId = primaryKey(grid(1).cache(Organization.class.getSimpleName()));
grid(0).compute().affinityRun(Arrays.asList(Organization.class.getSimpleName(), Person.class.getSimpleName()), new Integer(orgId), new IgniteRunnable() {
@IgniteInstanceResource
IgniteEx ignite;
@Override
public void run() {
try {
checkPartitionsReservations(ignite, orgId, 1);
} catch (Exception e) {
e.printStackTrace();
fail("Unexpected exception");
}
}
});
checkPartitionsReservations(grid(1), orgId, 0);
grid(0).compute().affinityCall(Arrays.asList(Organization.class.getSimpleName(), Person.class.getSimpleName()), new Integer(orgId), new IgniteCallable<Object>() {
@IgniteInstanceResource
IgniteEx ignite;
@Override
public Object call() {
try {
checkPartitionsReservations(ignite, orgId, 1);
} catch (Exception e) {
e.printStackTrace();
fail("Unexpected exception");
}
return null;
}
});
checkPartitionsReservations(grid(1), orgId, 0);
}
use of org.apache.ignite.internal.IgniteEx in project ignite by apache.
the class IgniteCacheLockPartitionOnAffinityRunTest method testReleasePartitionJobThrowsException.
/**
* @throws Exception If failed.
*/
public void testReleasePartitionJobThrowsException() throws Exception {
final int orgId = primaryKey(grid(1).cache(Organization.class.getSimpleName()));
try {
grid(0).compute().affinityRun(Arrays.asList(Organization.class.getSimpleName(), Person.class.getSimpleName()), new Integer(orgId), new IgniteRunnable() {
@IgniteInstanceResource
IgniteEx ignite;
@Override
public void run() {
try {
checkPartitionsReservations(ignite, orgId, 1);
} catch (Exception e) {
e.printStackTrace();
fail("Unexpected exception");
}
throw new RuntimeException("Test job throws exception");
}
});
fail("Exception must be thrown");
} catch (Exception ignored) {
checkPartitionsReservations(grid(1), orgId, 0);
}
try {
grid(0).compute().affinityCall(Arrays.asList(Organization.class.getSimpleName(), Person.class.getSimpleName()), new Integer(orgId), new IgniteCallable<Object>() {
@IgniteInstanceResource
IgniteEx ignite;
@Override
public Object call() {
try {
checkPartitionsReservations(ignite, orgId, 1);
} catch (Exception e) {
e.printStackTrace();
fail("Unexpected exception");
}
throw new RuntimeException("Test job throws exception");
}
});
fail("Exception must be thrown");
} catch (Exception ignored) {
checkPartitionsReservations(grid(1), orgId, 0);
}
}
use of org.apache.ignite.internal.IgniteEx in project ignite by apache.
the class IgniteCacheConfigVariationsFullApiTest method testRemoveAfterClear.
/**
* @throws Exception If failed.
*/
public void testRemoveAfterClear() throws Exception {
IgniteEx ignite = grid(0);
boolean affNode = ignite.context().cache().internalCache(cacheName()).context().affinityNode();
if (!affNode) {
if (gridCount() < 2)
return;
ignite = grid(1);
}
IgniteCache<Integer, Integer> cache = ignite.cache(cacheName());
int key = 0;
Collection<Integer> keys = new ArrayList<>();
for (int k = 0; k < 2; k++) {
while (!ignite.affinity(cacheName()).isPrimary(ignite.localNode(), key)) key++;
keys.add(key);
key++;
}
info("Keys: " + keys);
for (Integer k : keys) cache.put(k, k);
cache.clear();
for (int g = 0; g < gridCount(); g++) {
Ignite grid0 = grid(g);
grid0.cache(cacheName()).removeAll();
assertTrue(grid0.cache(cacheName()).localSize() == 0);
}
}
use of org.apache.ignite.internal.IgniteEx in project ignite by apache.
the class MemoryPolicyInitializationTest method testCustomConfigNoDefault.
/**
* Verifies that expected memory policies are allocated when used provides MemoryPolicyConfiguration
* with non-default custom MemoryPolicy.
*/
public void testCustomConfigNoDefault() throws Exception {
prepareCustomNoDefaultConfig();
IgniteEx ignite = startGrid(0);
Collection<MemoryPolicy> allMemPlcs = ignite.context().cache().context().database().memoryPolicies();
assertTrue(allMemPlcs.size() == 3);
verifyDefaultAndSystemMemoryPolicies(allMemPlcs);
assertTrue("Custom non-default memory policy is not presented", isMemoryPolicyPresented(allMemPlcs, CUSTOM_NON_DEFAULT_MEM_PLC_NAME));
}
Aggregations