/** {@inheritDoc} */ @Nullable @Override public final R reduce(List<ComputeJobResult> results) { try { return reduce0(results); } finally { if (debug) logFinish(ignite.log(), getClass(), start); } } }
/** {@inheritDoc} */ @Override protected Void run(Collection<String> qryIds) { long start = U.currentTimeMillis(); if (debug) { start = log( ignite.log(), "Queries cancellation started: [" + String.join(", ", qryIds) + "]", getClass(), start); } for (String qryId : qryIds) removeQueryHolder(ignite, qryId); if (debug) log(ignite.log(), "Queries cancellation finished", getClass(), start); return null; }
/** * Parse all IGFS log files in specified log directory. * * @param logDir Folder were log files located. * @return List of line with aggregated information by files. */ private List<VisorIgfsProfilerEntry> parse(Path logDir, String igfsName) throws IOException { List<VisorIgfsProfilerEntry> parsedFiles = new ArrayList<>(512); try (DirectoryStream<Path> dirStream = Files.newDirectoryStream(logDir)) { PathMatcher matcher = FileSystems.getDefault().getPathMatcher("glob:igfs-log-" + igfsName + "-*.csv"); for (Path p : dirStream) { if (matcher.matches(p.getFileName())) { try { parsedFiles.addAll(parseFile(p)); } catch (NoSuchFileException ignored) { // Files was deleted, skip it. } catch (Exception e) { ignite.log().warning("Failed to parse IGFS profiler log file: " + p, e); } } } } return parsedFiles; }
/** {@inheritDoc} */ @Override protected Map<? extends ComputeJob, ClusterNode> map0(List<ClusterNode> subgrid, @Nullable VisorTaskArgument<VisorQueryCleanupTaskArg> arg) { Set<UUID> nodeIds = taskArg.getQueryIds().keySet(); if (nodeIds.isEmpty()) throw new VisorClusterGroupEmptyException("Nothing to clear. List with node IDs is empty!"); Map<ComputeJob, ClusterNode> map = U.newHashMap(nodeIds.size()); try { for (ClusterNode node : subgrid) if (nodeIds.contains(node.id())) map.put(new VisorQueryCleanupJob(taskArg.getQueryIds().get(node.id()), debug), node); if (map.isEmpty()) { StringBuilder notFoundNodes = new StringBuilder(); for (UUID nid : nodeIds) notFoundNodes.append((notFoundNodes.length() == 0) ? "" : ",").append(U.id8(nid)); throw new VisorClusterGroupEmptyException("Failed to clear query results. Nodes are not available: [" + notFoundNodes + "]"); } return map; } finally { if (debug) logMapped(ignite.log(), getClass(), map.values()); } }
/** * Actual map logic. * * @param arg Task execution argument. * @param subgrid Nodes available for this task execution. * @return Map of grid jobs assigned to subgrid node. * @throws IgniteException If mapping could not complete successfully. */ protected Map<? extends ComputeJob, ClusterNode> map0(List<ClusterNode> subgrid, VisorTaskArgument<A> arg) { Collection<UUID> nodeIds = jobNodes(arg); Map<ComputeJob, ClusterNode> map = U.newHashMap(nodeIds.size()); try { for (ClusterNode node : subgrid) if (nodeIds.contains(node.id())) map.put(job(taskArg), node); if (map.isEmpty()) ignite.log().warning("No mapped jobs: [task=" + getClass().getName() + ", topVer=" + ignite.cluster().topologyVersion() + ", jobNids=" + nodeIds + ", subGrid=" + U.toShortString(subgrid) + "]"); return map; } finally { if (debug) logMapped(ignite.log(), getClass(), map.values()); } }
/** {@inheritDoc} */ @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, VisorTaskArgument<A> arg) { assert arg != null; start = U.currentTimeMillis(); debug = arg.isDebug(); taskArg = arg.getArgument(); if (debug) logStart(ignite.log(), getClass(), start); return map0(subgrid, arg); }
/** * @return logger. */ protected IgniteLogger log() { if (isRemoteJvm()) return IgniteNodeRunner.startedInstance().log(); return log; }
/** * Checks whether logger level is enabled. * * @param level Level. * @return Result. */ private boolean loggerIsLevelEnabled(int level) { IgniteLogger log = ctx.grid().log(); switch (level) { case PlatformLogger.LVL_TRACE: return log.isTraceEnabled(); case PlatformLogger.LVL_DEBUG: return log.isDebugEnabled(); case PlatformLogger.LVL_INFO: return log.isInfoEnabled(); case PlatformLogger.LVL_WARN: return true; case PlatformLogger.LVL_ERROR: return true; default: assert false; } return false; }
/** * Stop the process for the Grid at the given index. * * @param idx Index of Grid to stop. * @see GridRollingRestartAbstractTest#grid(int) */ protected void stopGrid(int idx) { Ignite remote = grid(idx); assert remote instanceof IgniteProcessProxy : remote; IgniteProcessProxy proc = (IgniteProcessProxy) remote; int pid = proc.getProcess().getPid(); try { grid(0).log().info(String.format("Killing grid id %d with PID %d", idx, pid)); IgniteProcessProxy.kill(proc.name()); grid(0).log().info(String.format("Grid id %d with PID %d stopped", idx, pid)); } catch (Exception e) { throw new RuntimeException(e); } } }
start0 = log(ignite.log(), "Collected events", getClass(), start0); start0 = log(ignite.log(), "Collected memory metrics", getClass(), start0); start0 = log(ignite.log(), "Collected caches", getClass(), start0); start0 = log(ignite.log(), "Collected igfs", getClass(), start0); log(ignite.log(), "Collected persistence metrics", getClass(), start0);
/** Check that dev-only messages appear in the log. */ @Test public void testDevOnlyVerboseMessage() throws Exception { additionalArgs = Collections.singletonList("-D" + IgniteSystemProperties.IGNITE_QUIET + "=false"); log = new GridStringLogger(false, grid(0).log()); Ignite ignite = startGrid(1); String msg = getMessage(ignite); warnDevOnly(msg); assertTrue(log.toString().contains(msg)); }
/** {@inheritDoc} */ @Override public boolean evict() { GridCacheContext<K, V> ctx = cached.context(); try { assert ctx != null; CacheEvictionManager mgr = ctx.evicts(); if (mgr == null) { assert ctx.kernalContext().isStopping(); return false; } return mgr.evict(cached, null, false, null); } catch (IgniteCheckedException e) { U.error(ctx.grid().log(), "Failed to evict entry from cache: " + cached, e); return false; } }
/** Check that dev-only messages appear in the log. */ @Ignore("https://issues.apache.org/jira/browse/IGNITE-9328") @Test public void testDevOnlyQuietMessage() throws Exception { additionalArgs = Collections.singletonList("-D" + IgniteSystemProperties.IGNITE_QUIET + "=true"); log = new GridStringLogger(false, grid(0).log()); Ignite ignite = startGrid(1); String msg = getMessage(ignite); warnDevOnly(msg); assertTrue(log.toString().contains(msg)); }
/** * Check that {@link IgniteUtils#warnDevOnly(IgniteLogger, Object)} * doesn't print anything if {@link org.apache.ignite.IgniteSystemProperties#IGNITE_DEV_ONLY_LOGGING_DISABLED} * is set to {@code true}. */ @Test public void testDevOnlyDisabledProperty() throws Exception { additionalArgs = Collections.singletonList("-D" + IgniteSystemProperties.IGNITE_DEV_ONLY_LOGGING_DISABLED + "=true"); log = new GridStringLogger(false, grid(0).log()); Ignite ignite = startGrid(1); String msg = getMessage(ignite); warnDevOnly(msg); assertFalse(log.toString().contains(msg)); }
/** {@inheritDoc} */ @Override protected VisorEither<VisorQueryResult> run(VisorQueryNextPageTaskArg arg) { String qryId = arg.getQueryId(); long start = U.currentTimeMillis(); if (debug) start = log(ignite.log(), "Fetch query first page started: " + qryId, getClass(), start); VisorQueryHolder holder = getQueryHolder(ignite, qryId); if (holder.getErr() != null) return new VisorEither<>(new VisorExceptionWrapper(holder.getErr())); List<Object[]> rows = null; List<VisorQueryField> cols = holder.getColumns(); boolean hasMore = cols == null; if (cols != null) { Iterator itr = holder.getIterator(); rows = fetchQueryRows(itr, qryId, arg.getPageSize()); hasMore = itr.hasNext(); } if (hasMore) holder.setAccessed(true); else removeQueryHolder(ignite, qryId); if (debug) log(ignite.log(), "Fetch query first page finished: " + qryId, getClass(), start); return new VisorEither<>( new VisorQueryResult(ignite.localNode().id(), qryId, cols, rows, hasMore, holder.duration())); }
/** * Tests marshal {@link org.apache.ignite.IgniteLogger} instance. * * @throws Exception If test failed. */ @Test public void testLoggerMarshalling() throws Exception { GridMarshallerTestBean inBean = newTestBean(grid().log()); byte[] buf = marshal(inBean); GridMarshallerTestBean outBean = unmarshal(buf); assert inBean.getObjectField() != null; assert outBean.getObjectField() != null; assert IgniteLogger.class.isAssignableFrom(inBean.getObjectField().getClass()); assert IgniteLogger.class.isAssignableFrom(outBean.getObjectField().getClass()); assert inBean != outBean; assert inBean.equals(outBean); outBean.checkNullResources(); }
IgniteLogger log = ctx.grid().log();
log(ignite.log(), "Collected IGFS: " + igfs.name(), getClass(), start0);
/** * Assert that specified explain slq query is not supported due to it explains update (update, delete, insert, * etc.). operation. * * @param explainQry explain query of update operation. * @param local whether or not query to be executed should be local. */ private void assertNotSupported(String explainQry, boolean local) { Throwable exc = GridTestUtils.assertThrows( ignite.log(), () -> cache.query(new SqlFieldsQuery(explainQry).setLocal(local)).getAll(), IgniteSQLException.class, "Explains of update queries are not supported."); IgniteSQLException sqlExc = ((IgniteSQLException)exc); assertEquals("Operation error code is not correct.", IgniteQueryErrorCode.UNSUPPORTED_OPERATION, sqlExc.statusCode()); } }