public static Profiler createIfTrace(Logger logger) { if (logger.isTraceEnabled()) { return create(logger); } return NullProfiler.NULL_INSTANCE; }
public static Profiler createIfDebug(Logger logger) { if (logger.isDebugEnabled()) { return create(logger); } return NullProfiler.NULL_INSTANCE; }
@Override public void execute(List<RegisteredMigrationStep> steps) { Profiler globalProfiler = Profiler.create(LOGGER); globalProfiler.startInfo(GLOBAL_START_MESSAGE); boolean allStepsExecuted = false; try { steps.forEach(this::execute); allStepsExecuted = true; } finally { if (allStepsExecuted) { globalProfiler.stopInfo(GLOBAL_END_MESSAGE, "success"); } else { globalProfiler.stopError(GLOBAL_END_MESSAGE, "failure"); } } }
public void execute() { Profiler stepProfiler = Profiler.create(LOGGER).logTimeLast(true); boolean allStepsExecuted = false; try { executeSteps(stepProfiler); allStepsExecuted = true; } finally { if (listener != null) { executeListener(allStepsExecuted); } } }
private static Profiler startLogProfiler(CeTask task) { Profiler profiler = Profiler.create(LOG) .logTimeLast(true) .addContext("project", task.getMainComponent().flatMap(CeTask.Component::getKey).orElse(null)) .addContext("type", task.getType()); for (Map.Entry<String, String> characteristic : task.getCharacteristics().entrySet()) { profiler.addContext(characteristic.getKey(), characteristic.getValue()); } return profiler .addContext("id", task.getUuid()) .addContext("submitter", submitterOf(task)) .startInfo("Execute task"); }
@Test public void create() { Profiler profiler = Profiler.create(Loggers.get("foo")); assertThat(profiler).isInstanceOf(DefaultProfiler.class); }
private void execute(RegisteredMigrationStep step, MigrationStep migrationStep) { Profiler stepProfiler = Profiler.create(LOGGER); stepProfiler.startInfo(STEP_START_PATTERN, step); boolean done = false; try { migrationStep.execute(); migrationHistory.done(step); done = true; } catch (Exception e) { throw new MigrationStepExecutionException(step, e); } finally { if (done) { stepProfiler.stopInfo(STEP_STOP_PATTERN, step, "success"); } else { stepProfiler.stopError(STEP_STOP_PATTERN, step, "failure"); } } } }
private void doDatabaseMigration() { migrationState.setStatus(Status.RUNNING); migrationState.setStartedAt(new Date()); migrationState.setError(null); Profiler profiler = Profiler.create(LOGGER); try { profiler.startInfo("Starting DB Migration and container restart"); doUpgradeDb(); doRestartContainer(); migrationState.setStatus(Status.SUCCEEDED); profiler.stopInfo("DB Migration and container restart: success"); } catch (MigrationStepExecutionException e) { profiler.stopError("DB migration failed"); LOGGER.error("DB migration ended with an exception", e); saveStatus(e); } catch (Throwable t) { profiler.stopError("Container restart failed"); LOGGER.error("Container restart failed", t); saveStatus(t); } finally { semaphore.release(); } }
private void visitNode(Component component, VisitorWrapper visitor) { Profiler profiler = Profiler.create(Loggers.get(visitor.getWrappedVisitor().getClass())) .startTrace("Visiting component {}", component.getDbKey()); visitor.visitAny(component); switch (component.getType()) { case PROJECT: visitor.visitProject(component); break; case DIRECTORY: visitor.visitDirectory(component); break; case FILE: visitor.visitFile(component); break; case VIEW: visitor.visitView(component); break; case SUBVIEW: visitor.visitSubView(component); break; case PROJECT_VIEW: visitor.visitProjectView(component); break; default: throw new IllegalStateException(String.format("Unknown type %s", component.getType().name())); } long duration = profiler.stopTrace(); incrementDuration(visitor, duration); }
public static Profiler createIfDebug(Logger logger) { if (logger.isDebugEnabled()) { return create(logger); } return NullProfiler.NULL_INSTANCE; }
public static Profiler createIfTrace(Logger logger) { if (logger.isTraceEnabled()) { return create(logger); } return NullProfiler.NULL_INSTANCE; }
private static Profiler startActivityProfiler(CeTask task) { Profiler profiler = Profiler.create(LOG); addContext(profiler, task); return profiler.startInfo("Execute task"); }
public void execute() { Profiler stepProfiler = Profiler.create(LOGGER); boolean allStepsExecuted = false; try { executeSteps(stepProfiler); allStepsExecuted = true; } finally { if (listener != null) { executeListener(allStepsExecuted); } } }
@Override public void execute(Stream<RegisteredMigrationStep> steps) { Profiler globalProfiler = Profiler.create(LOGGER); globalProfiler.startInfo(GLOBAL_START_MESSAGE); boolean allStepsExecuted = false; try { steps.forEachOrdered(this::execute); allStepsExecuted = true; } finally { if (allStepsExecuted) { globalProfiler.stopInfo(GLOBAL_END_MESSAGE, "success"); } else { globalProfiler.stopError(GLOBAL_END_MESSAGE, "failure"); } } }
private void execute(RegisteredMigrationStep step, MigrationStep migrationStep) { Profiler stepProfiler = Profiler.create(LOGGER); stepProfiler.startInfo(STEP_START_PATTERN, step); boolean done = false; try { migrationStep.execute(); migrationHistory.done(step); done = true; } catch (Exception e) { throw new MigrationStepExecutionException(step, e); } finally { if (done) { stepProfiler.stopInfo(STEP_STOP_PATTERN, step, "success"); } else { stepProfiler.stopError(STEP_STOP_PATTERN, step, "failure"); } } } }
private void doDatabaseMigration() { migrationState.setStatus(Status.RUNNING); migrationState.setStartedAt(new Date()); migrationState.setError(null); Profiler profiler = Profiler.create(LOGGER); try { profiler.startInfo("Starting DB Migration and container restart"); doUpgradeDb(); doRestartContainer(); migrationState.setStatus(Status.SUCCEEDED); profiler.stopInfo("DB Migration and container restart: success"); } catch (MigrationStepExecutionException e) { profiler.stopError("DB migration failed"); LOGGER.error("DB migration ended with an exception", e); saveStatus(e); } catch (Throwable t) { profiler.stopError("Container restart failed"); LOGGER.error("Container restart failed", t); saveStatus(t); } finally { semaphore.release(); } }
private void visitNode(Component component, VisitorWrapper visitor) { Profiler profiler = Profiler.create(Loggers.get(visitor.getWrappedVisitor().getClass())) .startTrace("Visiting component {}", component.getKey()); visitor.visitAny(component);