/** * Awaits a signal on flush condition * * @throws GridInterruptedException If thread was interrupted. */ private void waitForFlush() throws GridInterruptedException { U.await(flushCond); }
/** * @throws GridInterruptedException If interrupted. */ public void awaitInitialized() throws GridInterruptedException { assert init != null; U.await(init); }
/** {@inheritDoc} */ @Override public boolean waitForMap(long timeout, TimeUnit unit) throws GridException { if (!mapped && !isDone()) U.await(mappedLatch, timeout, unit); return mapped; }
/** {@inheritDoc} */ @Override public void await() throws GridException { initializeLatch(); U.await(internalLatch); }
/** {@inheritDoc} */ @Override public boolean await(long timeout, TimeUnit unit) throws GridException { initializeLatch(); return U.await(internalLatch, timeout, unit); }
/** {@inheritDoc} */ @Override public boolean waitForMap() throws GridException { if (!mapped && !isDone()) U.await(mappedLatch); return mapped; }
/** {@inheritDoc} */ @Override protected GridSpiContext getSpiContext() { if (ctxInitLatch.getCount() != 0) { try { U.await(ctxInitLatch); } catch (GridInterruptedException ignored) { U.warn(log, "Thread has been interrupted while waiting for SPI context initialization."); } } return super.getSpiContext(); }
/** {@inheritDoc} */ @Override public void run() { Thread t = Thread.currentThread(); // We clear interrupted flag here in order to let the final flush proceed normally with IO operations. while (!Thread.interrupted()) { flushLock.lock(); try { while (cnt.get() < batchSize && !t.isInterrupted()) { try { U.await(flushCond, 1000L, TimeUnit.MILLISECONDS); } catch (GridInterruptedException ignore) { t.interrupt(); break; } } } finally { flushLock.unlock(); } if (!t.isInterrupted()) flush(); } // Flush remaining entries. flush(); }
/** {@inheritDoc} */ private void initialize() { if (!init.get() && init.compareAndSet(false, true)) { if (log.isInfoEnabled()) log.info("Consistent hash configuration [cacheName=" + cacheName + ", partitions=" + parts + ", excludeNeighbors=" + exclNeighbors + ", replicas=" + replicas + ", backupFilter=" + backupFilter + ", hashIdRslvr=" + hashIdRslvr + ']'); nodeHash = new GridConsistentHash<>(); initLatch.countDown(); } else { if (initLatch.getCount() > 0) { try { U.await(initLatch); } catch (GridInterruptedException ignored) { // Recover interrupted state flag. Thread.currentThread().interrupt(); } } } }
/** * @throws GridException If thread is interrupted or manager * was not successfully initialized. */ private void waitInitialization() throws GridException { if (initLatch.getCount() > 0) U.await(initLatch); if (!initFlag) throw new GridException("DataStructures manager was not properly initialized for cache: " + cctx.cache().name()); }
/** {@inheritDoc} */ @SuppressWarnings("NonPrivateFieldAccessedInSynchronizedContext") @Override protected void loadAllPages() throws GridInterruptedException { assert !Thread.holdsLock(mux); U.await(firstPageLatch); Collection<GridNode> nodes = null; synchronized (mux) { if (!isDone() && !subgrid.isEmpty()) nodes = nodes(); } if (nodes != null) cctx.queries().loadPage(reqId, qry.query(), nodes, true); }
/** * Checks correctness of existing DB schema. * * @throws GridSpiException If schema wasn't properly initialized. */ private void checkSchema() throws GridSpiException { try { U.await(initLatch); } catch (GridInterruptedException e) { throw new GridSpiException("Thread has been interrupted.", e); } Connection conn = null; Statement stmt = null; try { conn = dataSrc.getConnection(); conn.setTransactionIsolation(TRANSACTION_READ_COMMITTED); // Check if tbl_addrs exists and database initialized properly. stmt = conn.createStatement(); stmt.execute(CHK_QRY); } catch (SQLException e) { throw new GridSpiException("IP finder has not been properly initialized.", e); } finally { U.closeQuiet(stmt); U.closeQuiet(conn); } }
U.await(cond, 500, MILLISECONDS);
/** * Checks correctness of existing DB schema. * * @throws GridSpiException If schema wasn't properly initialized. */ private void checkSchema() throws GridSpiException { try { U.await(initLatch); } catch (GridInterruptedException e) { throw new GridSpiException("Thread has been interrupted.", e); } Connection conn = null; Statement stmt = null; try { conn = dataSrc.getConnection(); conn.setTransactionIsolation(TRANSACTION_REPEATABLE_READ); // Check if tbl_metrics exists and database initialized properly. stmt = conn.createStatement(); stmt.execute(CHK_QRY); } catch (SQLException e) { throw new GridSpiException("Metrics store has not been properly initialized.", e); } finally { U.closeQuiet(stmt); U.closeQuiet(conn); } }
U.await(initLatch);
U.await(initLatch);
U.await(initLatch);
/** {@inheritDoc} */ @Override protected GridSpiContext getSpiContext() { if (ctxInitLatch.getCount() > 0) { if (log.isDebugEnabled()) log.debug("Waiting for context initialization."); try { U.await(ctxInitLatch); if (log.isDebugEnabled()) log.debug("Context has been initialized."); } catch (GridInterruptedException e) { U.warn(log, "Thread has been interrupted while waiting for SPI context initialization.", e); } } return super.getSpiContext(); }
/** {@inheritDoc} */ @Override protected GridSpiContext getSpiContext() { if (ctxInitLatch.getCount() > 0) { if (log.isDebugEnabled()) log.debug("Waiting for context initialization."); try { U.await(ctxInitLatch); if (log.isDebugEnabled()) log.debug("Context has been initialized."); } catch (GridInterruptedException e) { U.warn(log, "Thread has been interrupted while waiting for SPI context initialization.", e); } } return super.getSpiContext(); }
U.await(initLatch);