public static String toString(final Metric[] metrics) { final StringBuilder builder = new StringBuilder(); final int length = metrics.length; if (metrics != null && length > 0) { for (int i = 0; i < length; i++) { builder.append(metrics[i].getType().name().replace("_COUNT", "")).append(" = ").append(metrics[i].getValue()); if (i < length - 1) { builder.append(", "); } } } return builder.toString(); } }
public MetricImpl getMetric(MetricImpl.MetricType metricType) { return (MetricImpl)metrics.get(metricType.name()); }
private MetricImpl getCommittedMetric(MetricImpl.MetricType metricType) { return (MetricImpl)committedMetrics.get(metricType.name()); }
@Override public StepExecutionImpl createStepExecution(final long jobExecId, final StepContextImpl stepContext) { final StepExecutionEntity entity = new StepExecutionEntity(); final EntityManager em = emProvider.newEntityManager(); try { setStepData(em, jobExecId, stepContext, stepContext.metricsAsMap().get(Metric.MetricType.READ_COUNT.name()).getValue(), stepContext.metricsAsMap().get(Metric.MetricType.WRITE_COUNT.name()).getValue(), stepContext.metricsAsMap().get(Metric.MetricType.COMMIT_COUNT.name()).getValue(), stepContext.metricsAsMap().get(Metric.MetricType.ROLLBACK_COUNT.name()).getValue(), stepContext.metricsAsMap().get(Metric.MetricType.READ_SKIP_COUNT.name()).getValue(), stepContext.metricsAsMap().get(Metric.MetricType.PROCESS_SKIP_COUNT.name()).getValue(), stepContext.metricsAsMap().get(Metric.MetricType.FILTER_COUNT.name()).getValue(), stepContext.metricsAsMap().get(Metric.MetricType.WRITE_SKIP_COUNT.name()).getValue(), entity); final Object tx = txProvider.start(em); try { em.persist(entity); txProvider.commit(tx); final StepExecutionImpl stepExecution = new StepExecutionImpl(jobExecId, entity.getId()); stepExecution.setStepName(stepContext.getStepName()); return stepExecution; } catch (final Exception e) { throw new BatchContainerRuntimeException(performRollback(tx, e)); } } finally { emProvider.release(em); } }
@Override public void updateStepExecution(final long jobExecId, final StepContextImpl stepContext) { final EntityManager em = emProvider.newEntityManager(); try { final Object tx = txProvider.start(em); try { final StepExecutionEntity entity = em.find(StepExecutionEntity.class, stepContext.getStepInternalExecID()); setStepData(em, jobExecId, stepContext, stepContext.metricsAsMap().get(Metric.MetricType.READ_COUNT.name()).getValue(), stepContext.metricsAsMap().get(Metric.MetricType.WRITE_COUNT.name()).getValue(), stepContext.metricsAsMap().get(Metric.MetricType.COMMIT_COUNT.name()).getValue(), stepContext.metricsAsMap().get(Metric.MetricType.ROLLBACK_COUNT.name()).getValue(), stepContext.metricsAsMap().get(Metric.MetricType.READ_SKIP_COUNT.name()).getValue(), stepContext.metricsAsMap().get(Metric.MetricType.PROCESS_SKIP_COUNT.name()).getValue(), stepContext.metricsAsMap().get(Metric.MetricType.FILTER_COUNT.name()).getValue(), stepContext.metricsAsMap().get(Metric.MetricType.WRITE_SKIP_COUNT.name()).getValue(), entity); txProvider.commit(tx); } catch (final Exception e) { throw new BatchContainerRuntimeException(performRollback(tx, e)); } } finally { emProvider.release(em); } }
@Override public void execute() throws MojoExecutionException, MojoFailureException { final List<StepExecution> executions = getOrCreateOperator().getStepExecutions(executionId); getLog().info("Step executions for job execution #" + executionId + ":"); for (final StepExecution exec : executions) { getLog().info(" - id = " + exec.getStepExecutionId()); getLog().info(" + step = " + exec.getStepName()); getLog().info(" + batch status = " + exec.getBatchStatus()); getLog().info(" + exit status = " + exec.getExitStatus()); getLog().info(" + start time = " + exec.getStartTime()); getLog().info(" + end time = " + exec.getEndTime()); getLog().info(" + metrics"); if (exec.getMetrics() != null) { for (final Metric m : exec.getMetrics()) { getLog().info(" > " + m.getType().name().replace("COUNT", "").replace("_", " ").toLowerCase(Locale.ENGLISH) + " = " + m.getValue()); } } } } }
public static StepExecutionEntity create(final StepExecution stepExecution) { final StepExecutionEntity result = new StepExecutionEntity(); result.id = stepExecution.getStepExecutionId(); result.name = stepExecution.getStepName(); result.status = stepExecution.getBatchStatus(); result.exitStatus = stepExecution.getExitStatus(); result.endTime = stepExecution.getEndTime(); result.startTime = stepExecution.getStartTime(); // metrics result.metrics = new HashMap<>(); final Metric[] metricArr = stepExecution.getMetrics(); for (Metric m : metricArr) { result.metrics.put(m.getType().name().toLowerCase(), m.getValue()); } if (stepExecution.getPersistentUserData() != null) { result.setPersistentUserData(stepExecution.getPersistentUserData().toString()); } return result; }
public void addMetric(MetricImpl.MetricType metricType, long value) { metrics.putIfAbsent(metricType.name(), new MetricImpl(metricType, value)); }
public MetricImpl getMetric(MetricImpl.MetricType metricType) { return (MetricImpl)metrics.get(metricType.name()); }
public MetricImpl getMetric(MetricImpl.MetricType metricType) { return (MetricImpl) metrics.get(metricType.name()); }
public void addMetric(MetricImpl.MetricType metricType, long value) { metrics.putIfAbsent(metricType.name(), new MetricImpl(metricType, value)); }
public MetricImpl getMetric(MetricImpl.MetricType metricType) { return (MetricImpl)metrics.get(metricType.name()); }
public void addMetric(MetricImpl.MetricType metricType, long value) { metrics.putIfAbsent(metricType.name(), new MetricImpl(metricType, value)); }
public void addMetric(MetricImpl.MetricType metricType, long value) { metrics.putIfAbsent(metricType.name(), new MetricImpl(metricType, value)); }
public Map<String, Metric> metricsAsMap() { for (final Metric.MetricType type : Metric.MetricType.values()) { metrics.putIfAbsent(type.name(), new MetricImpl(type, 0)); } return Collections.unmodifiableMap(metrics); }
public void rollBackMetrics(){ for (MetricImpl.MetricType metricType : this.tranCoordinatedMetricTypes) { metrics.put(metricType.name(), new MetricImpl(metricType, this.getCommittedMetric(metricType).getValue())); } }
/** * Creates/Updates the committedMetrics variable using the passed in metric types */ public void setCommittedMetrics() { for (MetricImpl.MetricType metricType : this.tranCoordinatedMetricTypes) { committedMetrics.put(metricType.name(), new MetricImpl(metricType, this.getMetric(metricType).getValue())); } }