List of usage examples for org.apache.commons.lang.time DurationFormatUtils formatDurationHMS
public static String formatDurationHMS(long durationMillis)
Formats the time gap as a string.
The format used is ISO8601-like: H:m:s.S.
From source file:org.broadleafcommerce.common.util.StopWatch.java
public String toLapString() { return DurationFormatUtils.formatDurationHMS(getLapTime()); }
From source file:org.codice.solr.factory.impl.SolrClientAdapter.java
@Override public boolean isAvailable(long timeout, TimeUnit unit) throws InterruptedException { Validate.notNull(unit, "invalid null time unit"); if (isAvailable()) { // quick check to avoid synchronization return true; }/*from ww w . ja v a 2 s . co m*/ // letting now be recomputed by the timedWait() method allows us to better control testing long now = TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis()); final long end = now + unit.toNanos(timeout); synchronized (lock) { while (true) { if (state == State.CLOSED) { return false; } final boolean available = isAvailable(); if (available) { return true; } final long timeRemaining = end - now; if (timeRemaining <= 0L) { // we timed out return false; } if (LOGGER.isDebugEnabled()) { LOGGER.debug("Solr({}): waiting {} to become available", core, DurationFormatUtils.formatDurationHMS(TimeUnit.NANOSECONDS.toMillis(timeRemaining))); } now = waiter.timedWait(lock, now, timeRemaining, TimeUnit.NANOSECONDS); } } }
From source file:org.codice.solr.factory.impl.SolrHttpRequestRetryHandler.java
@Override @SuppressWarnings("squid:S2274" /* this method is designed to be called from within a loop controlled by the HttpClient*/) public boolean retryRequest(IOException e, int retryCount, HttpContext httpContext) { LOGGER.debug("Solr({}): Http client connection #{} failed", coreName, retryCount, e); if (e instanceof InterruptedIOException) { LOGGER.debug("Solr({}): Http client connection I/O interrupted.", coreName); Thread.currentThread().interrupt(); return false; }//from ww w . j a va2 s .co m if (e instanceof UnknownHostException) { LOGGER.warn("Solr({}): Http Client unknown host.", coreName); } if (e instanceof SSLException) { LOGGER.warn("Solr({}): Http client SSL handshake exception", coreName); } if (retryCount > maxRetryCount) { return false; } try { final long waitTime = (long) Math.pow(2, retryCount) * timeFactor; if (LOGGER.isDebugEnabled()) { LOGGER.debug("Solr({}): Http client connection failed, waiting {} before retrying.", coreName, DurationFormatUtils.formatDurationHMS(waitTime)); } synchronized (this) { wait(waitTime); } } catch (InterruptedException ie) { LOGGER.debug("Solr({}): Http client interrupted while waiting.", coreName); Thread.currentThread().interrupt(); return false; } return true; }
From source file:org.codinjutsu.tools.jenkins.view.JenkinsTreeRenderer.java
public static String buildLabel(Build build) { String status = ""; if (build.isBuilding()) { status = " (running)"; }//from w w w . jav a 2s .c om return String.format("#%d (%s) duration: %s %s", build.getNumber(), DateFormatUtil.formatDateTime(build.getTimestamp()), DurationFormatUtils.formatDurationHMS(build.getDuration()), status); }
From source file:org.eclipse.jubula.client.core.businessprocess.AbstractXMLReportGenerator.java
/** * @param resultNode//from w ww . j a v a2 s . c om * TestResultNode * @param insertInto * Element */ protected void addGeneralElements(TestResultNode resultNode, Element insertInto) { Element name = insertInto.addElement("name"); //$NON-NLS-1$ final INodePO resNode = resultNode.getNode(); name.addText(resNode.getName()); if (resNode.getComment() != null) { Element comment = insertInto.addElement("comment"); //$NON-NLS-1$ comment.addText(resNode.getComment()); } Element status = insertInto.addElement("status"); //$NON-NLS-1$ status.addText(String.valueOf(resultNode.getStatus())); long durationMillis = resultNode.getDuration(getTestResult().getEndTime()); if (durationMillis != -1) { insertInto.addAttribute("duration", //$NON-NLS-1$ DurationFormatUtils.formatDurationHMS(durationMillis)); } }
From source file:org.eclipse.jubula.client.ui.provider.labelprovider.decorators.TestResultDurationDecorator.java
/** * /*from w ww .j av a2 s .com*/ * {@inheritDoc} */ public void decorate(Object element, IDecoration decoration) { if (element instanceof TestResultNode) { TestResultNode testResult = (TestResultNode) element; Object testSuiteEndTimeValue = decoration.getDecorationContext() .getProperty(TestResultViewer.DECORATION_CONTEXT_SUITE_END_TIME_ID); Date endTime = testSuiteEndTimeValue instanceof Date ? (Date) testSuiteEndTimeValue : null; long durationMillis = testResult.getDuration(endTime); if (durationMillis != -1) { // only decorate if the duration could be determined decoration.addSuffix(SUFFIX_SPACER + DurationFormatUtils.formatDurationHMS(durationMillis)); } } }
From source file:org.eclipse.skalli.services.scheduler.Task.java
@Override public String toString() { String sRunnable = runnable.getClass().getName(); String sInitialDelay = FormatUtils.formatUTCWithMillis(System.currentTimeMillis() + initialDelay); String sPeriod = DurationFormatUtils.formatDurationHMS(period); if (isOneShot()) { return MessageFormat.format("running {0} now", sRunnable); } else if (period == -1L) { return MessageFormat.format("running {0} once at {1}", sRunnable, sInitialDelay); }/*from w ww . ja v a2s . co m*/ return MessageFormat.format("running {0} every {1} first at {2}", sRunnable, sPeriod, sInitialDelay); }
From source file:org.eurekastreams.server.action.execution.gallery.UpdateGadgetDefinitionCountExecution.java
/** * Makes a call to the mapper to do the actual work. * * @param inActionContext//from w ww . j av a2s . c om * the action context * @return null */ @Override public Serializable execute(final ActionContext inActionContext) { Date start = new Date(); try { gadgetDefMapper.refreshGadgetDefinitionUserCounts(); } catch (Exception ex) { logger.error("Error occurred refreshing the Gadget Definition User Counts", ex); } Date end = new Date(); logger.info("Gadget Definition User Count Refresh Job: elapsed time: " + DurationFormatUtils.formatDurationHMS(end.getTime() - start.getTime())); return null; }
From source file:org.eurekastreams.server.service.tasks.GadgetDefinitionReindexTask.java
/** * Perform the job functionality.//from www . j a va 2s. c o m */ public void execute() { stopWatch.reset(); stopWatch.start(); try { PagedSet<GadgetDefinition> gadgetDefs = null; BasicPager pager = new BasicPager(); pager.setPageSize(PAGE_SIZE); pager.setStartItem(0); pager.setEndItem(PAGE_SIZE - 1); pager.setMaxCount(PAGE_SIZE); int indexedGadgetsCount = 0; while (true) { gadgetDefs = gadgetDefMapper.findAll(pager.getStartItem(), pager.getEndItem()); pager.setEndItem(gadgetDefs.getToIndex()); pager.setMaxCount(gadgetDefs.getTotal()); pager.setPageSize(PAGE_SIZE); for (GadgetDefinition def : gadgetDefs.getPagedSet()) { indexedGadgetsCount++; populator.populate(def, def.getUrl()); gadgetDefMapper.reindex(def); } if (pager.isNextPageable()) { pager.nextPage(); } else { break; } } logger.info("Total Gadgets indexed: " + indexedGadgetsCount); } catch (Exception ex) { logger.error("Error occurred refreshing the Gadget Definition Index", ex); } gadgetDefMapper.flush(); stopWatch.stop(); logger.info("Gadget Definition Index Refresh Job: elapsed time: " + DurationFormatUtils.formatDurationHMS(stopWatch.getTime())); }
From source file:org.eurekastreams.server.service.tasks.PluginDefinitionMetaUpdateTask.java
/** * Perform the job functionality.// www . j a va 2s .com */ public void execute() { stopWatch.reset(); stopWatch.start(); try { PagedSet<PluginDefinition> pluginDefs = null; BasicPager pager = new BasicPager(); pager.setPageSize(PAGE_SIZE); pager.setStartItem(0); pager.setEndItem(PAGE_SIZE - 1); pager.setMaxCount(PAGE_SIZE); int pluginsUpdatedCount = 0; while (true) { pluginDefs = pluginDefMapper.findAll(pager.getStartItem(), pager.getEndItem()); pager.setEndItem(pluginDefs.getToIndex()); pager.setMaxCount(pluginDefs.getTotal()); pager.setPageSize(PAGE_SIZE); for (PluginDefinition def : pluginDefs.getPagedSet()) { pluginsUpdatedCount++; try { populator.populate(def, def.getUrl()); } catch (ValidationException ve) { logger.warn("Plugin:'" + def.getUrl() + "' failed to validate and did not update.", ve); } catch (Exception ex) { logger.error("Plugin Update failures", ex); } } if (pager.isNextPageable()) { pager.nextPage(); } else { break; } } logger.info("Total Plugins updated: " + pluginsUpdatedCount); } catch (Exception ex) { logger.error("Error occurred refreshing the Plugin Definition meta data", ex); } pluginDefMapper.flush(); pluginDefMapper.refreshGadgetDefinitionUserCounts(); stopWatch.stop(); logger.info("Plugin Definition update Job: elapsed time: " + DurationFormatUtils.formatDurationHMS(stopWatch.getTime())); }