use of org.apache.ignite.Ignite in project ignite by apache.
the class SparseDistributedMatrix method times.
/**
* {@inheritDoc}
*/
@Override
public Vector times(Vector vec) {
if (vec == null)
throw new IllegalArgumentException("The vector should be not null.");
if (columnSize() != vec.size())
throw new CardinalityException(columnSize(), vec.size());
SparseDistributedMatrix matrixA = this;
SparseDistributedVector vectorB = (SparseDistributedVector) vec;
String cacheName = storage().cacheName();
int rows = this.rowSize();
SparseDistributedVector vectorC = (SparseDistributedVector) likeVector(rows);
CacheUtils.bcast(cacheName, () -> {
Ignite ignite = Ignition.localIgnite();
Affinity<RowColMatrixKey> affinity = ignite.affinity(cacheName);
ClusterNode locNode = ignite.cluster().localNode();
SparseDistributedVectorStorage storageC = vectorC.storage();
Map<ClusterNode, Collection<RowColMatrixKey>> keysCToNodes = affinity.mapKeysToNodes(storageC.getAllKeys());
Collection<RowColMatrixKey> locKeys = keysCToNodes.get(locNode);
if (locKeys == null)
return;
// compute Cij locally on each node
// TODO: IGNITE:5114, exec in parallel
locKeys.forEach(key -> {
int idx = key.index();
Vector Aik = matrixA.getRow(idx);
vectorC.set(idx, Aik.times(vectorB).sum());
});
});
return vectorC;
}
use of org.apache.ignite.Ignite in project ignite by apache.
the class ServiceThreadPoolSelfTest method testDefaultPoolSize.
/**
* @throws Exception If failed.
*/
public void testDefaultPoolSize() throws Exception {
Ignite ignite = startGrid("grid", new IgniteConfiguration());
IgniteConfiguration cfg = ignite.configuration();
assertEquals(IgniteConfiguration.DFLT_PUBLIC_THREAD_CNT, cfg.getPublicThreadPoolSize());
assertEquals(IgniteConfiguration.DFLT_PUBLIC_THREAD_CNT, cfg.getServiceThreadPoolSize());
}
use of org.apache.ignite.Ignite in project ignite by apache.
the class GridSessionCancelSiblingsFromFutureSelfTest method checkTask.
/**
* @param num Task argument.
* @throws InterruptedException if failed
* @throws IgniteCheckedException if failed
*/
private void checkTask(int num) throws InterruptedException, IgniteCheckedException {
Ignite ignite = G.ignite(getTestIgniteInstanceName());
ComputeTaskFuture<?> fut = executeAsync(ignite.compute(), GridTaskSessionTestTask.class, num);
assert fut != null;
try {
// Wait until jobs begin execution.
boolean await = startSig[num].await(WAIT_TIME, TimeUnit.MILLISECONDS);
assert await : "Jobs did not start.";
Collection<ComputeJobSibling> jobSiblings = fut.getTaskSession().getJobSiblings();
// Cancel all jobs.
for (ComputeJobSibling jobSibling : jobSiblings) {
jobSibling.cancel();
}
Object res = fut.get();
assert "interrupt-task-data".equals(res) : "Invalid task result: " + res;
// Wait for all jobs to finish.
await = stopSig[num].await(WAIT_TIME, TimeUnit.MILLISECONDS);
assert await : "Jobs did not cancel.";
int cnt = interruptCnt[num].get();
assert cnt == SPLIT_COUNT : "Invalid interrupt count value: " + cnt;
} finally {
// We must wait for the jobs to be sure that they have completed
// their execution since they use static variable (shared for the tests).
fut.get();
}
}
use of org.apache.ignite.Ignite in project ignite by apache.
the class GridLog4jCorrectFileNameTest method checkOneNode.
/**
* Starts the local node and checks for presence of log file.
* Also checks that this is really a log of a started node.
*
* @param id Test-local node ID.
* @throws Exception If error occurred.
*/
private void checkOneNode(int id) throws Exception {
try (Ignite ignite = G.start(getConfiguration("grid" + id))) {
String id8 = U.id8(ignite.cluster().localNode().id());
String logPath = "work/log/ignite-" + id8 + ".log";
File logFile = U.resolveIgnitePath(logPath);
assertNotNull("Failed to resolve path: " + logPath, logFile);
assertTrue("Log file does not exist: " + logFile, logFile.exists());
String logContent = U.readFileToString(logFile.getAbsolutePath(), "UTF-8");
assertTrue("Log file does not contain it's node ID: " + logFile, logContent.contains(">>> Local node [ID=" + id8.toUpperCase()));
}
}
use of org.apache.ignite.Ignite in project ignite by apache.
the class GridSessionLoadSelfTest method checkSessionLoad.
/**
* @throws Exception If failed.
*/
private void checkSessionLoad() throws Exception {
final Ignite ignite = grid(0);
assert ignite != null;
assert ignite.cluster().nodes().size() == 2;
info("Thread count: " + THREAD_CNT);
GridTestUtils.runMultiThreaded(new Callable<Object>() {
@Override
public Object call() throws Exception {
ComputeTaskFuture f = null;
try {
for (int i = 0; i < EXEC_CNT; i++) assertEquals(Boolean.TRUE, (f = executeAsync(ignite.compute().withName("task-name"), SessionLoadTestTask.class, ignite.cluster().nodes().size() * 2)).get(20000));
} catch (Exception e) {
U.error(log, "Task failed: " + f != null ? f.getTaskSession().getId() : "N/A", e);
throw e;
} finally {
info("Thread finished.");
}
return null;
}
}, THREAD_CNT, "grid-load-test-thread");
}
Aggregations