public void change(final Object iCurrentValue, final Object iNewValue) { Orient.instance().getProfiler().configure(iNewValue.toString()); } }),
/** * All operations running at cache destruction stage */ public void shutdown() { underlying.shutdown(); if (Orient.instance().getProfiler() != null) { Orient.instance().getProfiler().unregisterHookValue(profilerPrefix + "enabled"); Orient.instance().getProfiler().unregisterHookValue(profilerPrefix + "current"); Orient.instance().getProfiler().unregisterHookValue(profilerPrefix + "max"); } } }
public void change(final Object iCurrentValue, final Object iNewValue) { Orient.instance().getProfiler().setAutoDump((Integer) iNewValue); } }),
/** * Report the tip to the profiler and collect it in context to be reported by tools like Studio */ protected void reportTip(final String iMessage) { Orient.instance().getProfiler().reportTip(iMessage); List<String> tips = (List<String>) context.getVariable("tips"); if (tips == null) { tips = new ArrayList<String>(3); context.setVariable("tips", tips); } tips.add(iMessage); }
@ConsoleCommand(description = "Execute a command against the profiler") public void profiler( @ConsoleParameter(name = "profiler command", description = "command to execute against the profiler") final String iCommandName) { if (iCommandName.equalsIgnoreCase("on")) { Orient.instance().getProfiler().startRecording(); message("\nProfiler is ON now, use 'profiler off' to turn off."); } else if (iCommandName.equalsIgnoreCase("off")) { Orient.instance().getProfiler().stopRecording(); message("\nProfiler is OFF now, use 'profiler on' to turn on."); } else if (iCommandName.equalsIgnoreCase("dump")) { out.println(Orient.instance().getProfiler().dump()); } }
/** * All operations running at cache initialization stage */ public void startup() { underlying.startup(); Orient.instance().getProfiler() .registerHookValue(profilerPrefix + "current", "Number of entries in cache", METRIC_TYPE.SIZE, new OProfilerHookValue() { public Object getValue() { return getSize(); } }, profilerMetadataPrefix + "current"); }
public void change(final Object iCurrentValue, final Object iNewValue) { Orient instance = Orient.instance(); if (instance != null) { final OProfiler prof = instance.getProfiler(); if (prof != null) if ((Boolean) iNewValue) prof.startRecording(); else prof.stopRecording(); } } }),
/** * Looks up for record in cache by it's identifier. Optionally look up in secondary cache and update primary with found record * * @param rid * unique identifier of record * @return record stored in cache if any, otherwise - {@code null} */ public ORecord findRecord(final ORID rid) { ORecord record; record = underlying.get(rid); if (record != null) Orient.instance().getProfiler().updateCounter(CACHE_HIT, "Record found in Level1 Cache", 1L, "db.*.cache.level1.cache.found"); else Orient.instance().getProfiler().updateCounter(CACHE_MISS, "Record not found in Level1 Cache", 1L, "db.*.cache.level1.cache.notFound"); return record; }
public void handle(final Signal signal) { OLogManager.instance().warn(this, "Received signal: %s", signal); final String s = signal.toString().trim(); if (Orient.instance().isSelfManagedShutdown() && (s.equals("SIGKILL") || s.equals("SIGHUP") || s.equals("SIGINT") || s .equals("SIGTERM"))) { Orient.instance().shutdown(); System.exit(1); } else if (s.equals("SIGTRAP")) { System.out.println(); OGlobalConfiguration.dumpConfiguration(System.out); System.out.println(); Orient.instance().getProfiler().dump(System.out); System.out.println(); System.out.println(Orient.instance().getProfiler().threadDump()); } else { SignalHandler redefinedHandler = redefinedHandlers.get(signal); if (redefinedHandler != null) { redefinedHandler.handle(signal); } } for (OSignalListener l : listeners) l.onSignal(signal); }
private void logProfiling() { if (executionPlan.getStatement() != null && Orient.instance().getProfiler().isRecording()) { final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (db != null) { final OSecurityUser user = db.getUser(); final String userString = user != null ? user.toString() : null; Orient.instance().getProfiler() .stopChrono("db." + ODatabaseRecordThreadLocal.instance().get().getName() + ".command.sql." + executionPlan.getStatement(), "Command executed against the database", System.currentTimeMillis() - totalExecutionTime, "db.*.command.*", null, userString); } } }
protected void revertSubclassesProfiler(final OCommandContext iContext, int num) { final OProfiler profiler = Orient.instance().getProfiler(); if (profiler.isRecording()) { profiler.updateCounter(profiler.getDatabaseMetric(getDatabase().getName(), "query.indexUseAttemptedAndReverted"), "Reverted index usage in query", num); } }
private void evict() { final long start = Orient.instance().getProfiler().startChrono(); final int initialSize = lruList.size(); int closedFiles = 0; while (lruList.size() > openLimit) { //we may only close items in open state so we "peek" them first Iterator<OClosableEntry<K, V>> iterator = lruList.iterator(); boolean entryClosed = false; while (iterator.hasNext()) { OClosableEntry<K, V> entry = iterator.next(); if (entry.makeClosed()) { closedFiles++; iterator.remove(); entryClosed = true; countClosedFiles(); break; } } //there are no items in open state stop eviction if (!entryClosed) break; } if (closedFiles > 0) { OLogManager.instance().debug(this, "Reached maximum of opened files %d (max=%d), closed %d files. Consider to raise this limit by increasing the global setting '%s' and the OS limit on opened files per processor", initialSize, openLimit, closedFiles, OGlobalConfiguration.OPEN_FILES_LIMIT.getKey()); } Orient.instance().getProfiler() .stopChrono("disk.closeFiles", "Close the opened files because reached the configured limit", start); }
@Deprecated public Object execute(final Map<Object, Object> iArgs) { final long start = Orient.instance().getProfiler().startChrono(); Object result; while (true) { try { if (callback != null) return callback.call(iArgs); final OCommandExecutorScript command = new OCommandExecutorScript(); command.parse(new OCommandScript(getLanguage(), getCode())); result = command.execute(iArgs); break; } catch (ONeedRetryException | ORetryQueryException ignore) { } } if (Orient.instance().getProfiler().isRecording()) Orient.instance().getProfiler().stopChrono("db." + ODatabaseRecordThreadLocal.instance().get().getName() + ".function.execute", "Time to execute a function", start, "db.*.function.execute"); return result; }
/** * {@inheritDoc} */ @Override public void freeze(final boolean throwException) { checkOpenness(); if (!(getStorage() instanceof OFreezableStorageComponent)) { OLogManager.instance().error(this, "Only local paginated storage supports freeze. If you are using remote client please use OServerAdmin instead", null); return; } final long startTime = Orient.instance().getProfiler().startChrono(); final OFreezableStorageComponent storage = getFreezableStorage(); if (storage != null) { storage.freeze(throwException); } Orient.instance().getProfiler() .stopChrono("db." + getName() + ".freeze", "Time to freeze the database", startTime, "db.*.freeze"); }
/** * {@inheritDoc} */ @Override public void freeze() { checkOpenness(); if (!(getStorage() instanceof OFreezableStorageComponent)) { OLogManager.instance().error(this, "Only local paginated storage supports freeze. " + "If you use remote client please use OServerAdmin instead", null); return; } final long startTime = Orient.instance().getProfiler().startChrono(); final OFreezableStorageComponent storage = getFreezableStorage(); if (storage != null) { storage.freeze(false); } Orient.instance().getProfiler() .stopChrono("db." + getName() + ".freeze", "Time to freeze the database", startTime, "db.*.freeze"); }
/** * {@inheritDoc} */ @Override public void release() { checkOpenness(); if (!(getStorage() instanceof OFreezableStorageComponent)) { OLogManager.instance().error(this, "Only local paginated storage supports release. If you are using remote client please use OServerAdmin instead", null); return; } final long startTime = Orient.instance().getProfiler().startChrono(); final OFreezableStorageComponent storage = getFreezableStorage(); if (storage != null) { storage.release(); } Orient.instance().getProfiler() .stopChrono("db." + getName() + ".release", "Time to release the database", startTime, "db.*.release"); }
/** * Register statistic information about usage of index in {@link OProfilerStub}. * * @param index which usage is registering. */ private void updateStatistic(OIndex<?> index) { final OProfiler profiler = Orient.instance().getProfiler(); if (profiler.isRecording()) { Orient.instance().getProfiler() .updateCounter(profiler.getDatabaseMetric(index.getDatabaseName(), "query.indexUsed"), "Used index in query", +1); final int paramCount = index.getDefinition().getParamCount(); if (paramCount > 1) { final String profiler_prefix = profiler.getDatabaseMetric(index.getDatabaseName(), "query.compositeIndexUsed"); profiler.updateCounter(profiler_prefix, "Used composite index in query", +1); profiler .updateCounter(profiler_prefix + "." + paramCount, "Used composite index in query with " + paramCount + " params", +1); } } }
protected void updateProfiler(final OCommandContext iContext, final OIndex<?> index, final List<Object> keyParams, final OIndexDefinition indexDefinition) { if (iContext.isRecordingMetrics()) iContext.updateMetric("compositeIndexUsed", +1); final OProfiler profiler = Orient.instance().getProfiler(); if (profiler.isRecording()) { profiler.updateCounter(profiler.getDatabaseMetric(index.getDatabaseName(), "query.indexUsed"), "Used index in query", +1); int params = indexDefinition.getParamCount(); if (params > 1) { final String profiler_prefix = profiler.getDatabaseMetric(index.getDatabaseName(), "query.compositeIndexUsed"); profiler.updateCounter(profiler_prefix, "Used composite index in query", +1); profiler.updateCounter(profiler_prefix + "." + params, "Used composite index in query with " + params + " params", +1); profiler.updateCounter(profiler_prefix + "." + params + '.' + keyParams.size(), "Used composite index in query with " + params + " params and " + keyParams.size() + " keys", +1); } } }
protected void revertProfiler(final OCommandContext iContext, final OIndex<?> index, final List<Object> keyParams, final OIndexDefinition indexDefinition) { if (iContext.isRecordingMetrics()) { iContext.updateMetric("compositeIndexUsed", -1); } final OProfiler profiler = Orient.instance().getProfiler(); if (profiler.isRecording()) { profiler.updateCounter(profiler.getDatabaseMetric(index.getDatabaseName(), "query.indexUsed"), "Used index in query", -1); int params = indexDefinition.getParamCount(); if (params > 1) { final String profiler_prefix = profiler.getDatabaseMetric(index.getDatabaseName(), "query.compositeIndexUsed"); profiler.updateCounter(profiler_prefix, "Used composite index in query", -1); profiler.updateCounter(profiler_prefix + "." + params, "Used composite index in query with " + params + " params", -1); profiler.updateCounter(profiler_prefix + "." + params + '.' + keyParams.size(), "Used composite index in query with " + params + " params and " + keyParams.size() + " keys", -1); } } }
@Override public final void delete() { try { final long timer = Orient.instance().getProfiler().startChrono(); stateLock.releaseWriteLock(); Orient.instance().getProfiler().stopChrono("db." + name + ".drop", "Drop a database", timer, "db.*.drop");