/** Collect license. */ private void license(VisorDataCollectorJobResult res) { if (ENT) try { // If license could not be retrieved, try to let it load for 5 time. for (int i = 0; i < 5; i++) { res.license = VisorLicense.from(g); if (res.license != null) break; U.sleep(1000); } } catch(Throwable licenseEx) { res.licenseEx = licenseEx; } }
/** * @param c Transform closure to be applied for queue header. * @return Value computed by the transform closure. * @throws GridException If failed. */ @SuppressWarnings("unchecked") @Nullable private Long transformHeader(GridClosure<GridCacheQueueHeader, GridBiTuple<GridCacheQueueHeader, Long>> c) throws GridException { int cnt = 0; while (true) { try { return (Long)cache.transformAndCompute(queueKey, c); } catch (GridCachePartialUpdateException e) { if (cnt++ == MAX_UPDATE_RETRIES) throw e; else { U.warn(log, "Failed to update queue header, will retry [err=" + e + ']'); U.sleep(RETRY_DELAY); } } } } }
/** {@inheritDoc} */ @Override protected void body() throws GridInterruptedException { while (!isCancelled()) { U.sleep(METRICS_UPDATE_FREQ); gcCpuLoad = getGcCpuLoad(); cpuLoad = getCpuLoad(); } }
/** * Executes command using {@code shell} channel. * * @param ses SSH session. * @param cmd Command. * @throws JSchException In case of SSH error. * @throws IOException If IO error occurs. * @throws GridInterruptedException If thread was interrupted while waiting. */ private void shell(Session ses, String cmd) throws JSchException, IOException, GridInterruptedException { ChannelShell ch = null; try { ch = (ChannelShell)ses.openChannel("shell"); ch.connect(); try (PrintStream out = new PrintStream(ch.getOutputStream(), true)) { out.println(cmd); U.sleep(1000); } } finally { if (ch != null && ch.isConnected()) ch.disconnect(); } }
U.warn(log, "Failed to execute data structure operation, will retry [err=" + e + ']'); U.sleep(RETRY_DELAY);
U.sleep(checkPntFreq);
U.warn(log, "Failed to add items, will retry [err=" + e + ']'); U.sleep(RETRY_DELAY);
/** * @param nodeId Node ID to send message to. * @param msg Message to send. * @throws GridException If send failed. */ private void sendWithRetries(UUID nodeId, GridGgfsCommunicationMessage msg) throws GridException { for (int i = 0; i < MESSAGE_SEND_RETRY_COUNT; i++) { try { ggfsCtx.send(nodeId, topic, msg, SYSTEM_POOL); return; } catch (GridException e) { if (!ggfsCtx.kernalContext().discovery().alive(nodeId)) throw new GridTopologyException("Failed to send message (node left the grid) " + "[nodeId=" + nodeId + ", msg=" + msg + ']'); if (i == MESSAGE_SEND_RETRY_COUNT - 1) throw e; U.sleep(MESSAGE_SEND_RETRY_INTERVAL); } } }
/** * @param nodeId Node ID to send message to. * @param msg Message to send. * @throws GridException If send failed. */ private void sendWithRetries(UUID nodeId, GridGgfsCommunicationMessage msg) throws GridException { for (int i = 0; i < MESSAGE_SEND_RETRY_COUNT; i++) { try { ggfsCtx.send(nodeId, topic, msg, SYSTEM_POOL); return; } catch (GridException e) { if (!ggfsCtx.kernalContext().discovery().alive(nodeId)) throw new GridTopologyException("Failed to send message (node left the grid) " + "[nodeId=" + nodeId + ", msg=" + msg + ']'); if (i == MESSAGE_SEND_RETRY_COUNT - 1) throw e; U.sleep(MESSAGE_SEND_RETRY_INTERVAL); } } }
/** * @throws GridSpiException If failed. */ @SuppressWarnings("BusyWait") private void registerLocalNodeAddress() throws GridSpiException { // Make sure address registration succeeded. while (true) { try { ipFinder.initializeLocalAddresses(locNode.socketAddresses()); // Success. break; } catch (IllegalStateException e) { throw new GridSpiException("Failed to register local node address with IP finder: " + locNode.socketAddresses(), e); } catch (GridSpiException e) { LT.error(log, e, "Failed to register local node address in IP finder on start " + "(retrying every 2000 ms)."); } try { U.sleep(2000); } catch (GridInterruptedException e) { throw new GridSpiException("Thread has been interrupted.", e); } } }
/** * Tries to send message to remote node. * * @param dstNodeId Destination node ID. * @param msg Message to send. * @throws GridException If failed. */ private void sendWithRetries(UUID dstNodeId, GridTcpCommunicationMessageAdapter msg) throws GridException { for (int i = 0; i < SEND_RETRY_COUNT; i++) { try { ctx.io().send(dstNodeId, topic, msg, GridIoPolicy.SYSTEM_POOL); return; } catch (GridException e) { if (log.isDebugEnabled()) log.debug("Failed to send message to remote node (will retry) [dstNodeId=" + dstNodeId + ", msg=" + msg + ", err=" + e + ']'); if (!ctx.discovery().alive(dstNodeId)) throw new GridTopologyException("Failed to send message (destination node left grid): " + dstNodeId); if (i == SEND_RETRY_COUNT - 1) throw e; U.sleep(SEND_RETRY_DELAY); } } }
U.warn(log, "Failed to poll, will retry [err=" + e + ']'); U.sleep(RETRY_DELAY);
U.warn(log, "Failed to put queue item, will retry [err=" + e + ", idx=" + idx + ']'); U.sleep(RETRY_DELAY);
@SuppressWarnings("ConstantConditions") @Override protected void body() { long interval0 = interval; while (!isCancelled()) { try { U.sleep(interval0); } catch (GridInterruptedException ignored) { break; } GridBiTuple<Collection<Object>, Long> t = info.checkInterval(); Collection<Object> toSnd = t.get1(); if (toSnd != null) { try { sendNotification(nodeId, routineId, toSnd, hnd.orderedTopic()); } catch (GridTopologyException ignored) { if (log.isDebugEnabled()) log.debug("Failed to send notification to node (is node alive?): " + nodeId); } catch (GridException e) { U.error(log, "Failed to send notification to node: " + nodeId, e); } } interval0 = t.get2(); } } });
/** * Checks segment on start waiting for correct segment if necessary. * * @throws GridException If check failed. */ private void checkSegmentOnStart() throws GridException { assert hasRslvrs; if (log.isDebugEnabled()) log.debug("Starting network segment check."); while (true) { if (ctx.segmentation().isValidSegment()) break; if (ctx.config().isWaitForSegmentOnStart()) { LT.warn(log, null, "Failed to check network segment (retrying every 2000 ms)."); // Wait and check again. U.sleep(2000); } else throw new GridException("Failed to check network segment."); } if (log.isDebugEnabled()) log.debug("Finished network segment check successfully."); }
U.warn(log, "Failed to remove item, will retry [err=" + e + ", idx=" + rmvIdx + ']'); U.sleep(RETRY_DELAY);
U.warn(log, "Failed to add items, will retry [err=" + e + ']'); U.sleep(RETRY_DELAY);
U.warn(log, "Failed to add item, will retry [err=" + e + ']'); U.sleep(RETRY_DELAY);
U.sleep(retryDelay);