use of org.apache.ignite.IgniteException in project ignite by apache.
the class IgniteChangeGlobalStateTest method testActivateAfterFailGetLock.
/**
* @throws Exception If failed.
*/
public void testActivateAfterFailGetLock() throws Exception {
Ignite ig1P = primary(0);
Ignite ig2P = primary(1);
Ignite ig3P = primary(2);
Ignite ig1CP = primaryClient(0);
Ignite ig2CP = primaryClient(1);
Ignite ig3CP = primaryClient(2);
Ignite ig1B = backUp(0);
Ignite ig2B = backUp(1);
Ignite ig3B = backUp(2);
Ignite ig1CB = backUpClient(0);
Ignite ig2CB = backUpClient(1);
Ignite ig3CB = backUpClient(2);
assertTrue(ig1P.active());
assertTrue(ig2P.active());
assertTrue(ig3P.active());
assertTrue(!ig1B.active());
assertTrue(!ig2B.active());
assertTrue(!ig3B.active());
assertTrue(!ig1CB.active());
assertTrue(!ig2CB.active());
assertTrue(!ig3CB.active());
stopPrimary(0);
try {
ig3CB.active(true);
fail("Activation should fail");
} catch (IgniteException e) {
log.error("Stack trace from remote node", e);
for (Throwable t : e.getSuppressed()) assertTrue(t.getMessage().contains("can't get lock during"));
}
assertTrue(!ig1B.active());
assertTrue(!ig2B.active());
assertTrue(!ig3B.active());
assertTrue(!ig1CB.active());
assertTrue(!ig2CB.active());
assertTrue(!ig3CB.active());
assertTrue(ig2P.active());
assertTrue(ig3P.active());
assertTrue(ig1CP.active());
assertTrue(ig2CP.active());
assertTrue(ig3CP.active());
stopAllPrimary();
ig2CB.active(true);
assertTrue(ig1B.active());
assertTrue(ig2B.active());
assertTrue(ig3B.active());
assertTrue(ig1CB.active());
assertTrue(ig2CB.active());
assertTrue(ig3CB.active());
}
use of org.apache.ignite.IgniteException in project ignite by apache.
the class DataStreamProcessorSelfTest method testLocalDataStreamerDedicatedThreadPool.
/**
* @throws Exception If failed.
*/
public void testLocalDataStreamerDedicatedThreadPool() throws Exception {
try {
useCache = true;
Ignite ignite = startGrid(1);
final IgniteCache<String, String> cache = ignite.cache(DEFAULT_CACHE_NAME);
try (IgniteDataStreamer<String, String> ldr = ignite.dataStreamer(DEFAULT_CACHE_NAME)) {
ldr.receiver(new StreamReceiver<String, String>() {
@Override
public void receive(IgniteCache<String, String> cache, Collection<Map.Entry<String, String>> entries) throws IgniteException {
String threadName = Thread.currentThread().getName();
cache.put("key", threadName);
}
});
ldr.addData("key", "value");
ldr.tryFlush();
GridTestUtils.waitForCondition(new GridAbsPredicate() {
@Override
public boolean apply() {
return cache.get("key") != null;
}
}, 3_000);
}
assertNotNull(cache.get("key"));
assertTrue(cache.get("key").startsWith("data-streamer"));
} finally {
stopAllGrids();
}
}
use of org.apache.ignite.IgniteException in project ignite by apache.
the class IgfsAbstractSelfTest method testConcurrentRenameDeleteSource.
/**
* Ensure that in case we rename the folder A and delete it at the same time, only one of these requests succeed.
*
* @throws Exception If failed.
*/
public void testConcurrentRenameDeleteSource() throws Exception {
for (int i = 0; i < REPEAT_CNT; i++) {
final CyclicBarrier barrier = new CyclicBarrier(2);
create(igfs, paths(DIR, SUBDIR, DIR_NEW), paths());
IgniteInternalFuture<Boolean> res1 = execute(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
U.awaitQuiet(barrier);
try {
igfs.rename(SUBDIR, SUBDIR_NEW);
return true;
} catch (IgniteException ignored) {
return false;
}
}
});
IgniteInternalFuture<Boolean> res2 = execute(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
U.awaitQuiet(barrier);
try {
return igfs.delete(SUBDIR, true);
} catch (IgniteException ignored) {
return false;
}
}
});
res1.get();
res2.get();
if (res1.get()) {
// Rename succeeded, so delete must fail.
assert !res2.get();
checkExist(igfs, igfsSecondary, DIR, DIR_NEW, SUBDIR_NEW);
checkNotExist(igfs, igfsSecondary, SUBDIR);
} else {
// Rename failed because delete succeeded.
assert res2.get();
// DIR_NEW should not be synchronized with he primary IGFS.
checkExist(igfs, DIR);
if (dual)
checkExist(igfsSecondary, DIR, DIR_NEW);
checkNotExist(igfs, igfsSecondary, SUBDIR, SUBDIR_NEW);
}
clear(igfs, igfsSecondary);
}
}
use of org.apache.ignite.IgniteException in project ignite by apache.
the class IgfsAbstractSelfTest method testConcurrentRenameDeleteDestination.
/**
* Ensure that in case we rename the folder A to B and delete B at the same time, FS consistency is not
* compromised.
*
* @throws Exception If failed.
*/
public void testConcurrentRenameDeleteDestination() throws Exception {
for (int i = 0; i < REPEAT_CNT; i++) {
final CyclicBarrier barrier = new CyclicBarrier(2);
create(igfs, paths(DIR, SUBDIR, DIR_NEW), paths());
IgniteInternalFuture<Boolean> res1 = execute(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
U.awaitQuiet(barrier);
try {
igfs.rename(SUBDIR, SUBDIR_NEW);
return true;
} catch (IgniteException ignored) {
return false;
}
}
});
IgniteInternalFuture<Boolean> res2 = execute(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
U.awaitQuiet(barrier);
try {
return igfs.delete(SUBDIR_NEW, true);
} catch (IgniteException ignored) {
return false;
}
}
});
assert res1.get();
if (res2.get()) {
// Delete after rename.
checkExist(igfs, igfsSecondary, DIR, DIR_NEW);
checkNotExist(igfs, igfsSecondary, SUBDIR, SUBDIR_NEW);
} else {
// Delete before rename.
checkExist(igfs, igfsSecondary, DIR, DIR_NEW, SUBDIR_NEW);
checkNotExist(igfs, igfsSecondary, SUBDIR);
}
clear(igfs, igfsSecondary);
}
}
use of org.apache.ignite.IgniteException in project ignite by apache.
the class IgfsAbstractSelfTest method testAppendDeleteParentNoClose.
/**
* Test delete on the file parent when it was opened for write(append) and is not closed yet.
*
* @throws Exception If failed.
*/
public void testAppendDeleteParentNoClose() throws Exception {
if (mode != PRIMARY)
return;
if (appendSupported()) {
create(igfs, paths(DIR, SUBDIR), null);
createFile(igfs, FILE, false);
IgfsOutputStream os = null;
IgniteUuid id = null;
try {
id = igfs.context().meta().fileId(FILE);
os = igfs.append(FILE, false);
// Since GG-4911 we allow deletes in this case.
boolean del = igfs.delete(SUBDIR, true);
assertTrue(del);
assertFalse(igfs.exists(FILE));
// id still exists in meta cache since
assertTrue(igfs.context().meta().exists(id));
// it is locked for writing and just moved to TRASH.
// Delete worker cannot delete it for that reason.
os.write(chunk);
os.close();
} finally {
U.closeQuiet(os);
}
assert id != null;
final IgniteUuid id0 = id;
// Delete worker should delete the file once its output stream is finally closed:
GridTestUtils.waitForCondition(new GridAbsPredicate() {
@Override
public boolean apply() {
try {
return !igfs.context().meta().exists(id0);
} catch (IgniteCheckedException ice) {
throw new IgniteException(ice);
}
}
}, 5_000L);
}
}
Aggregations