/** * Callback that is invoked when kernal is ready. */ public void onKernalStart() { // Accept connections only when grid is ready. if (srvEndpoint != null) new IgniteThread(acceptWorker).start(); }
/** * @return If current thread belongs to client. */ private boolean clientThread() { assert Thread.currentThread() instanceof IgniteThread; return ((IgniteThread)Thread.currentThread()).getIgniteInstanceName().contains("client"); }
/** {@inheritDoc} */ @Override public String toString() { return S.toString(IgniteThread.class, this, "name", getName()); } }
/** * @throws Exception If failed. */ @Test public void testAssertion() throws Exception { Collection<IgniteThread> ts = new ArrayList<>(); for (int i = 0; i < THREAD_CNT; i++) { ts.add(new IgniteThread("test-grid-" + i, "test-thread", new Runnable() { @Override public void run() { assert false : "Expected assertion."; } })); } for (IgniteThread t : ts) t.start(); for (IgniteThread t : ts) t.join(); } }
IgniteThread checker = new IgniteThread(new GridWorker(ctx.igniteInstanceName(), "continuous-buffer-checker", log) { @Override protected void body() { long interval0 = interval; checker.setUncaughtExceptionHandler(new OomExceptionHandler(ctx)); checker.start();
/** * @throws Exception If failed. */ @Test public void testSyntheticWorkerTermination() throws Exception { IgniteEx ignite = grid(0); WorkersRegistry registry = ignite.context().workersRegistry(); long fdTimeout = ignite.configuration().getFailureDetectionTimeout(); GridWorker worker = new GridWorker(ignite.name(), "test-worker", log, registry) { @Override protected void body() throws InterruptedException { Thread.sleep(fdTimeout / 2); } }; IgniteThread thread = new IgniteThread(worker); failureHndThreadName = null; thread.start(); thread.join(); assertTrue(GridTestUtils.waitForCondition(() -> thread.getName().equals(failureHndThreadName), fdTimeout * 2)); }
/** {@inheritDoc} */ @Override public Thread newThread(@NotNull Runnable r) { Thread thread = new IgniteThread(igniteInstanceName, threadName, r, idxGen.incrementAndGet(), -1, plc); if (eHnd != null) thread.setUncaughtExceptionHandler(eHnd); return thread; }
clientThreads[i] = new IgniteThread(worker); clientThreads[i].setDaemon(daemon);
/** * @param routineId Routine ID. * @param hnd Handler * @param loc If Handler unregistered on master node. */ private void unregisterHandler(UUID routineId, GridContinuousHandler hnd, boolean loc) { assert routineId != null; assert hnd != null; if (loc && hnd.orderedTopic() != null) ctx.io().removeMessageListener(hnd.orderedTopic()); hnd.unregister(routineId, ctx); IgniteThread checker = bufCheckThreads.remove(routineId); if (checker != null) checker.interrupt(); }
final IgniteThread thread = (IgniteThread)curThread; if (thread.cachePoolThread()) {
/** * @return Index of current thread stripe. */ private int curIdx() { int idx; Thread curThread = Thread.currentThread(); if (curThread instanceof IgniteThread) { IgniteThread igniteThread = (IgniteThread)curThread; idx = igniteThread.compositeRwLockIndex(); if (idx == IgniteThread.GRP_IDX_UNASSIGNED) { idx = IDX_GEN.incrementAndGet(); igniteThread.compositeRwLockIndex(idx); } } else idx = IDX.get(); return idx % locks.length; }
IgniteThread thread = new IgniteThread(worker); thread.setUncaughtExceptionHandler(new OomExceptionHandler( cctx.kernalContext())); thread.start();
/** * Starts the stripe. */ void start() { thread = new IgniteThread(igniteInstanceName, name(), this, IgniteThread.GRP_IDX_UNASSIGNED, idx, GridIoPolicy.UNDEFINED); thread.start(); }
clientThreads[i] = new IgniteThread(worker); clientThreads[i].setDaemon(daemon);
/** * Interrupts checkpoint thread for given node. * * @param node Node. */ private void interruptCheckpointer(IgniteEx node) { GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager) node.context().cache().context().database(); dbMgr.checkpointerThread().interrupt(); } }
final IgniteThread thread = (IgniteThread)curThread; if (thread.cachePoolThread()) { ctx.time().waitAsync(topFut, req.timeout(), (e, timedOut) -> { if (e != null || timedOut) {
/** * @return Index of current thread stripe. */ private int curIdx() { int idx; Thread curThread = Thread.currentThread(); if (curThread instanceof IgniteThread) { IgniteThread igniteThread = (IgniteThread)curThread; idx = igniteThread.compositeRwLockIndex(); if (idx == IgniteThread.GRP_IDX_UNASSIGNED) { idx = IDX_GEN.incrementAndGet(); igniteThread.compositeRwLockIndex(idx); } } else idx = IDX.get(); return idx % locks.length; }
/** * Start this worker. */ void start() { new IgniteThread(this).start(); }
segChkWrk = new SegmentCheckWorker(); segChkThread = new IgniteThread(segChkWrk); segChkThread.setUncaughtExceptionHandler(new OomExceptionHandler(ctx)); segChkThread.start(); new IgniteThread(discoWrk).start();
/** * @param ctx Context. */ public GridRestProcessor(GridKernalContext ctx) { super(ctx); sesTtl = IgniteSystemProperties.getLong(IGNITE_REST_SESSION_TIMEOUT, DFLT_SES_TIMEOUT) * 1000; sesTokTtl = IgniteSystemProperties.getLong(IGNITE_REST_SECURITY_TOKEN_TIMEOUT, DFLT_SES_TOKEN_INVALIDATE_INTERVAL) * 100; sesTimeoutCheckerThread = new IgniteThread(ctx.igniteInstanceName(), "session-timeout-worker", new GridWorker(ctx.igniteInstanceName(), "session-timeout-worker", log) { @Override protected void body() throws InterruptedException { while (!isCancelled()) { Thread.sleep(SES_TIMEOUT_CHECK_DELAY); for (Map.Entry<UUID, Session> e : sesId2Ses.entrySet()) { Session ses = e.getValue(); if (ses.isTimedOut(sesTtl)) { clientId2SesId.remove(ses.clientId, ses.sesId); sesId2Ses.remove(ses.sesId, ses); if (ctx.security().enabled() && ses.secCtx != null && ses.secCtx.subject() != null) ctx.security().onSessionExpired(ses.secCtx.subject().id()); } } } } }); }