@Override public boolean isEventRecordable(int... types) { for (int t : types) if (!ctx.event().isRecordable(t)) return false; return true; }
/** * @param evts Collection (created if {@code null}). * @param evt Event. * @param msg Message (optional). * @return Collection with event added. */ Collection<GridBiTuple<Integer, String>> addEvent(@Nullable Collection<GridBiTuple<Integer, String>> evts, Integer evt, @Nullable String msg) { assert ctx.event().isRecordable(evt); assert !internal; if (evts == null) evts = new ArrayList<>(); evts.add(F.t(evt, msg)); return evts; }
/** {@inheritDoc} */ @Override public void onTimeout() { if (finishing.get()) return; timedOut = true; U.warn(log, "Job has timed out: " + ses); cancel(); if (!internal && ctx.event().isRecordable(EVT_JOB_TIMEDOUT)) recordEvent(EVT_JOB_TIMEDOUT, "Job has timed out: " + job); }
/** * @param type Event type. * @return {@code True} if event is recordable. */ public boolean isRecordable(int type) { return !CU.isUtilityCache(cctx.name()) && cctx.gridEvents().isRecordable(type); }
@Override public Boolean onSuccess(Map<GridGgfsPath, GridGgfsFileInfo> infos) throws Exception { fs.mkdirs(path, props); assert !infos.isEmpty(); // Now perform synchronization again starting with the last created parent. GridGgfsPath parentPath = null; for (GridGgfsPath curPath : infos.keySet()) { if (parentPath == null || curPath.isSubDirectoryOf(parentPath)) parentPath = curPath; } assert parentPath != null; GridGgfsFileInfo parentPathInfo = infos.get(parentPath); synchronize(fs, parentPath, parentPathInfo, path, true, null); if (evts.isRecordable(EVT_GGFS_DIR_CREATED)) { GridGgfsPath evtPath = path; while (!parentPath.equals(evtPath)) { pendingEvts.addFirst(new GridGgfsEvent(evtPath, locNode, EVT_GGFS_DIR_CREATED)); evtPath = evtPath.parent(); assert evtPath != null; // If this fails, then ROOT does not exist. } } return true; }
/** {@inheritDoc} */ @SuppressWarnings("NonSynchronizedMethodOverridesSynchronizedMethod") @Override public void close() throws IOException { if (closeGuard.compareAndSet(false, true)) { super.close(); metrics.decrementFilesOpenedForRead(); if (evts.isRecordable(EVT_GGFS_FILE_CLOSED_READ)) evts.record(new GridGgfsEvent(path, localNode(), EVT_GGFS_FILE_CLOSED_READ, bytes())); } } }
/** {@inheritDoc} */ @SuppressWarnings("NonSynchronizedMethodOverridesSynchronizedMethod") @Override protected void onClose() throws IOException { if (closeGuard.compareAndSet(false, true)) { super.onClose(); metrics.decrementFilesOpenedForWrite(); if (evts.isRecordable(EVT_GGFS_FILE_CLOSED_WRITE)) evts.record(new GridGgfsEvent(path, localNode(), EVT_GGFS_FILE_CLOSED_WRITE, bytes())); } } }
/** {@inheritDoc} */ @SuppressWarnings("NonSynchronizedMethodOverridesSynchronizedMethod") @Override protected void onClose() throws IOException { if (closeGuard.compareAndSet(false, true)) { super.onClose(); metrics.decrementFilesOpenedForWrite(); if (evts.isRecordable(EVT_GGFS_FILE_CLOSED_WRITE)) evts.record(new GridGgfsEvent(path, localNode(), EVT_GGFS_FILE_CLOSED_WRITE, bytes())); } } }
/** {@inheritDoc} */ @SuppressWarnings("NonSynchronizedMethodOverridesSynchronizedMethod") @Override public void close() throws IOException { if (closeGuard.compareAndSet(false, true)) { super.close(); metrics.decrementFilesOpenedForRead(); if (evts.isRecordable(EVT_GGFS_FILE_CLOSED_READ)) evts.record(new GridGgfsEvent(path, localNode(), EVT_GGFS_FILE_CLOSED_READ, bytes())); } } }
/** {@inheritDoc} */ @Override protected void body() { assert job != null; startTime = U.currentTimeMillis(); isStarted = true; // Event notification. evtLsnr.onJobStarted(this); if (!internal && ctx.event().isRecordable(EVT_JOB_STARTED)) recordEvent(EVT_JOB_STARTED, /*no message for success*/null); execute0(true); }
@Override public void recordEvent(GridEvent evt) { A.notNull(evt, "evt"); if (ctx.event().isRecordable(evt.type())) ctx.event().record(evt); }
@Override public void onEvent(GridEvent evt) { GridDiscoveryEvent discoEvt = (GridDiscoveryEvent)evt; for (String cacheName : nearOrClientCaches) { if (ctx.discovery().cacheAffinityNodes(cacheName, discoEvt.topologyVersion()).isEmpty()) { if (ctx.event().isRecordable(GridEventType.EVT_CACHE_DATA_LOST)) { ctx.event().record(new GridCacheEvent(cacheName, ctx.discovery().localNode(), discoEvt.eventNode(), "All data nodes left", GridEventType.EVT_CACHE_DATA_LOST, 0, false, null, null, null, null, false, null, false, null, null, null)); } } } } }, GridEventType.EVT_NODE_LEFT, GridEventType.EVT_NODE_FAILED);
/** * @param type Event type. * @param key Checkpoint key. */ private void record(int type, String key) { if (ctx.event().isRecordable(type)) { String msg; if (type == EVT_CHECKPOINT_SAVED) msg = "Checkpoint saved: " + key; else if (type == EVT_CHECKPOINT_LOADED) msg = "Checkpoint loaded: " + key; else { assert type == EVT_CHECKPOINT_REMOVED : "Invalid event type: " + type; msg = "Checkpoint removed: " + key; } ctx.event().record(new GridCheckpointEvent(ctx.discovery().localNode(), msg, type, key)); } }
@Override public void onExecution() { if (ctx.event().isRecordable(EVT_CACHE_QUERY_EXECUTED)) { ctx.event().record(new GridCacheQueryExecutedEvent<>( ctx.discovery().localNode(), "Continuous query executed.", EVT_CACHE_QUERY_EXECUTED, GridCacheQueryType.CONTINUOUS, cacheName, null, null, null, filter, null, nodeId, taskName() )); } }
/** * Records undeploy event. * * @param dep Undeployed class loader. */ private void recordUndeploy(GridDeployment dep) { assert dep.undeployed(); if (ctx.event().isRecordable(EVT_TASK_UNDEPLOYED) || ctx.event().isRecordable(EVT_CLASS_UNDEPLOYED)) { for (Class<?> cls : dep.deployedClasses()) { boolean isTask = isTask(cls); String msg = isTask ? "Task locally undeployed: " + cls : "Class locally undeployed: " + cls; if (ctx.event().isRecordable(isTask ? EVT_TASK_UNDEPLOYED : EVT_CLASS_UNDEPLOYED)) { GridDeploymentEvent evt = new GridDeploymentEvent(); evt.message(msg); evt.node(ctx.discovery().localNode()); evt.type(isTask ? EVT_TASK_UNDEPLOYED : EVT_CLASS_UNDEPLOYED); evt.alias(getAlias(dep, cls)); ctx.event().record(evt); } if (log.isInfoEnabled()) log.info(msg); } } }
/** {@inheritDoc} */ @Override public void onDeployed(Class<?> cls) { assert !Thread.holdsLock(mux); boolean isTask = isTask(cls); String msg = (isTask ? "Task" : "Class") + " was deployed in SHARED or CONTINUOUS mode: " + cls; int type = isTask ? EVT_TASK_DEPLOYED : EVT_CLASS_DEPLOYED; if (ctx.event().isRecordable(type)) { GridDeploymentEvent evt = new GridDeploymentEvent(); evt.node(ctx.discovery().localNode()); evt.message(msg); evt.type(type); evt.alias(cls.getName()); ctx.event().record(evt); } if (log.isInfoEnabled()) log.info(msg); }
/** * Called for every deployed class. * * @param cls Deployed class. * @param recordEvt Flag indicating whether to record events. */ void recordDeployed(Class<?> cls, boolean recordEvt) { assert !Thread.holdsLock(mux); boolean isTask = isTask(cls); String msg = (isTask ? "Task" : "Class") + " was deployed in Private or Isolated mode: " + cls; if (recordEvt && ctx.event().isRecordable(isTask(cls) ? EVT_TASK_DEPLOYED : EVT_CLASS_DEPLOYED)) { GridDeploymentEvent evt = new GridDeploymentEvent(); // Record task event. evt.type(isTask ? EVT_TASK_DEPLOYED : EVT_CLASS_DEPLOYED); evt.node(sndNode); evt.message(msg); evt.alias(cls.getName()); ctx.event().record(evt); } if (log.isInfoEnabled()) log.info(msg); }
/** * @param evtType Event type. * @param msg Event message. */ private void recordTaskEvent(int evtType, String msg) { if (!internal && ctx.event().isRecordable(evtType)) { GridEvent evt = new GridTaskEvent( ctx.discovery().localNode(), msg, evtType, ses.getId(), ses.getTaskName(), ses.getTaskClassName(), internal, subjId); ctx.event().record(evt); } }
/** * @param evtType Event type. * @param msg Message. */ private void recordEvent(int evtType, @Nullable String msg) { assert ctx.event().isRecordable(evtType); assert !internal; GridJobEvent evt = new GridJobEvent(); evt.jobId(ses.getJobId()); evt.message(msg); evt.node(ctx.discovery().localNode()); evt.taskName(ses.getTaskName()); evt.taskClassName(ses.getTaskClassName()); evt.taskSessionId(ses.getId()); evt.type(evtType); evt.taskNode(taskNode); evt.taskSubjectId(ses.subjectId()); ctx.event().record(evt); }
/** * @param evtType Event type. * @param jobId Job ID. * @param evtNode Event node. * @param msg Event message. */ private void recordJobEvent(int evtType, GridUuid jobId, GridNode evtNode, String msg) { if (ctx.event().isRecordable(evtType)) { GridJobEvent evt = new GridJobEvent(); evt.message(msg); evt.node(ctx.discovery().localNode()); evt.taskName(ses.getTaskName()); evt.taskClassName(ses.getTaskClassName()); evt.taskSessionId(ses.getId()); evt.taskNode(evtNode); evt.jobId(jobId); evt.type(evtType); evt.taskSubjectId(ses.subjectId()); ctx.event().record(evt); } }