List of usage examples for org.apache.commons.lang.time StopWatch start
public void start()
Start the stopwatch.
This method starts a new timing session, clearing any previous values.
From source file:com.liferay.portal.lar.PermissionExporter.java
protected void exportUserPermissions(LayoutCache layoutCache, long companyId, long groupId, String resourceName, String resourcePrimKey, Element parentElement) throws Exception { StopWatch stopWatch = null; if (_log.isDebugEnabled()) { stopWatch = new StopWatch(); stopWatch.start(); }//from w w w.j a v a2s .c o m Element userPermissionsElement = SAXReaderUtil.createElement("user-permissions"); List<User> users = layoutCache.getGroupUsers(groupId); for (User user : users) { String uuid = user.getUuid(); Element userActionsElement = SAXReaderUtil.createElement("user-actions"); List<Permission> permissions = PermissionLocalServiceUtil.getUserPermissions(user.getUserId(), companyId, resourceName, ResourceConstants.SCOPE_INDIVIDUAL, resourcePrimKey); List<String> actions = ResourceActionsUtil.getActions(permissions); for (String action : actions) { Element actionKeyElement = userActionsElement.addElement("action-key"); actionKeyElement.addText(action); } if (!userActionsElement.elements().isEmpty()) { userActionsElement.addAttribute("uuid", uuid); userPermissionsElement.add(userActionsElement); } } if (!userPermissionsElement.elements().isEmpty()) { parentElement.add(userPermissionsElement); } if (_log.isDebugEnabled()) { _log.debug("Export user permissions for {" + resourceName + ", " + resourcePrimKey + "} with " + users.size() + " users takes " + stopWatch.getTime() + " ms"); } }
From source file:eagle.service.generic.GenericEntityServiceResource.java
/** * * @param query/*from w w w. j a v a 2 s . c o m*/ * @param startTime * @param endTime * @param pageSize * @param startRowkey * @param treeAgg * @param timeSeries * @param intervalmin * @param top * @param filterIfMissing * @param parallel * @param metricName * @param verbose * @return */ @GET @Produces(MediaType.APPLICATION_JSON) @SuppressWarnings("unchecked") public GenericServiceAPIResponseEntity search(@QueryParam("query") String query, @QueryParam("startTime") String startTime, @QueryParam("endTime") String endTime, @QueryParam("pageSize") int pageSize, @QueryParam("startRowkey") String startRowkey, @QueryParam("treeAgg") boolean treeAgg, @QueryParam("timeSeries") boolean timeSeries, @QueryParam("intervalmin") long intervalmin, @QueryParam("top") int top, @QueryParam("filterIfMissing") boolean filterIfMissing, @QueryParam("parallel") int parallel, @QueryParam("metricName") String metricName, @QueryParam("verbose") Boolean verbose) { RawQuery rawQuery = RawQuery.build().query(query).startTime(startTime).endTime(endTime).pageSize(pageSize) .startRowkey(startRowkey).treeAgg(treeAgg).timeSeries(timeSeries).intervalMin(intervalmin).top(top) .filerIfMissing(filterIfMissing).parallel(parallel).metricName(metricName).verbose(verbose).done(); QueryStatement queryStatement = new QueryStatement(rawQuery); GenericServiceAPIResponseEntity response = new GenericServiceAPIResponseEntity(); Map<String, Object> meta = new HashMap<>(); DataStorage dataStorage; StopWatch stopWatch = new StopWatch(); try { stopWatch.start(); dataStorage = DataStorageManager.getDataStorageByEagleConfig(); if (dataStorage == null) { LOG.error("Data storage is null"); throw new IllegalDataStorageException("data storage is null"); } QueryResult<?> result = queryStatement.execute(dataStorage); if (result.isSuccess()) { meta.put(FIRST_TIMESTAMP, result.getFirstTimestamp()); meta.put(LAST_TIMESTAMP, result.getLastTimestamp()); meta.put(TOTAL_RESULTS, result.getSize()); meta.put(ELAPSEDMS, stopWatch.getTime()); response.setObj(result.getData()); response.setType(result.getEntityType()); response.setSuccess(true); response.setMeta(meta); return response; } } catch (Exception e) { response.setException(e); LOG.error(e.getMessage(), e); } finally { stopWatch.stop(); } return response; }
From source file:eagle.service.generic.GenericEntityServiceResource.java
/** * * Delete by entity lists//ww w . ja va 2s. co m * * Use "POST /entities/delete" instead of "DELETE /entities" to walk around jersey DELETE issue for request with body * * @param inputStream * @param serviceName * @return */ @POST @Path(DELETE_ENTITIES_PATH) @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public GenericServiceAPIResponseEntity deleteEntities(InputStream inputStream, @QueryParam("serviceName") String serviceName, @QueryParam("byId") Boolean deleteById) { GenericServiceAPIResponseEntity<String> response = new GenericServiceAPIResponseEntity<String>(); DataStorage dataStorage = null; Map<String, Object> meta = new HashMap<String, Object>(); if (deleteById == null) deleteById = false; StopWatch stopWatch = new StopWatch(); try { stopWatch.start(); dataStorage = DataStorageManager.getDataStorageByEagleConfig(); DeleteStatement statement = new DeleteStatement(serviceName); if (deleteById) { LOG.info("Deleting " + serviceName + " by ids"); List<String> deleteIds = unmarshalAsStringlist(inputStream); statement.setIds(deleteIds); } else { LOG.info("Deleting " + serviceName + " by entities"); EntityDefinition entityDefinition = EntityDefinitionManager.getEntityByServiceName(serviceName); if (entityDefinition == null) { throw new IllegalArgumentException( "Entity definition of service " + serviceName + " not found"); } List<? extends TaggedLogAPIEntity> entities = unmarshalEntitiesByServie(inputStream, entityDefinition); statement.setEntities(entities); } ModifyResult<String> result = statement.execute(dataStorage); if (result.isSuccess()) { List<String> keys = result.getIdentifiers(); if (keys != null) { response.setObj(keys, String.class); meta.put(TOTAL_RESULTS, keys.size()); } else { meta.put(TOTAL_RESULTS, 0); } meta.put(ELAPSEDMS, stopWatch.getTime()); response.setMeta(meta); response.setSuccess(true); } } catch (Exception e) { LOG.error(e.getMessage(), e); response.setException(e); } finally { stopWatch.stop(); } return response; }
From source file:com.redhat.rhn.manager.errata.test.ErrataManagerTest.java
public void xxxxLookupErrataByAdvisoryType() throws IOException { String bugfix = "Bug Fix Advisory"; String pea = "Product Enhancement Advisory"; String security = "Security Advisory"; StopWatch st = new StopWatch(); st.start(); List erratas = ErrataManager.lookupErrataByType(bugfix); outputErrataList(erratas);//w ww. j av a 2 s . co m System.out.println("Got bugfixes: " + erratas.size() + " time: " + st); assertTrue(erratas.size() > 0); erratas = ErrataManager.lookupErrataByType(pea); outputErrataList(erratas); System.out.println("Got pea enhancments: " + erratas.size() + " time: " + st); assertTrue(erratas.size() > 0); erratas = ErrataManager.lookupErrataByType(security); outputErrataList(erratas); assertTrue(erratas.size() > 0); System.out.println("Got security advisories: " + erratas.size() + " time: " + st); st.stop(); System.out.println("TIME: " + st.getTime()); }
From source file:net.nan21.dnet.core.web.controller.data.AbstractAsgnController.java
/** * //w w w . j av a 2 s . co m * @param resourceName * @param dataFormat * @param selectionId * @param request * @param response * @return * @throws Exception */ @RequestMapping(method = RequestMethod.POST, params = Constants.REQUEST_PARAM_ACTION + "=" + Constants.ASGN_ACTION_CLEANUP) @ResponseBody public String delete(@PathVariable String resourceName, @PathVariable String dataFormat, @RequestParam(value = Constants.REQUEST_PARAM_ASGN_SELECTION_ID, required = true) String selectionId, HttpServletRequest request, HttpServletResponse response) throws Exception { try { StopWatch stopWatch = new StopWatch(); stopWatch.start(); if (logger.isInfoEnabled()) { logger.info("Processing request: {}.{} -> action = {} ", new String[] { resourceName, dataFormat, Constants.ASGN_ACTION_CLEANUP }); } if (logger.isDebugEnabled()) { logger.debug(" --> request-filter: selectionId={} ", new String[] { selectionId }); } this.prepareRequest(request, response); IAsgnService<M, F, P> service = this.findAsgnService(this.serviceNameFromResourceName(resourceName)); service.cleanup(selectionId); stopWatch.stop(); return ""; } catch (Exception e) { return this.handleException(e, response); } finally { this.finishRequest(); } }
From source file:net.nan21.dnet.core.web.controller.data.AbstractAsgnController.java
/** * Cancel changes/* w w w. j a va 2s.c om*/ * * @param resourceName * @param dataFormat * @param objectId * @param selectionId * @param request * @param response * @return * @throws Exception */ @RequestMapping(method = RequestMethod.POST, params = Constants.REQUEST_PARAM_ACTION + "=" + Constants.ASGN_ACTION_RESET) @ResponseBody public String reset(@PathVariable String resourceName, @PathVariable String dataFormat, @RequestParam(value = Constants.REQUEST_PARAM_ASGN_OBJECT_ID, required = true) String objectId, @RequestParam(value = Constants.REQUEST_PARAM_ASGN_SELECTION_ID, required = true) String selectionId, HttpServletRequest request, HttpServletResponse response) throws Exception { try { StopWatch stopWatch = new StopWatch(); stopWatch.start(); if (logger.isInfoEnabled()) { logger.info("Processing request: {}.{} -> action = {} ", new String[] { resourceName, dataFormat, Constants.ASGN_ACTION_RESET }); } if (logger.isDebugEnabled()) { logger.debug(" --> request-filter: objectId={}, selectionId={} ", new String[] { objectId, selectionId }); } this.prepareRequest(request, response); IAsgnService<M, F, P> service = this.findAsgnService(this.serviceNameFromResourceName(resourceName)); service.reset(selectionId, objectId); stopWatch.stop(); return ""; } catch (Exception e) { return this.handleException(e, response); } finally { this.finishRequest(); } }
From source file:net.nan21.dnet.core.web.controller.data.AbstractAsgnController.java
/** * Save changes// ww w. j a va 2s. co m * * @param resourceName * @param dataFormat * @param objectId * @param selectionId * @param request * @param response * @return * @throws Exception */ @RequestMapping(method = RequestMethod.POST, params = Constants.REQUEST_PARAM_ACTION + "=" + Constants.ASGN_ACTION_SAVE) @ResponseBody public String save(@PathVariable String resourceName, @PathVariable String dataFormat, @RequestParam(value = Constants.REQUEST_PARAM_ASGN_OBJECT_ID, required = true) String objectId, @RequestParam(value = Constants.REQUEST_PARAM_ASGN_SELECTION_ID, required = true) String selectionId, HttpServletRequest request, HttpServletResponse response) throws Exception { try { StopWatch stopWatch = new StopWatch(); stopWatch.start(); if (logger.isInfoEnabled()) { logger.info("Processing request: {}.{} -> action = {} ", new String[] { resourceName, dataFormat, Constants.ASGN_ACTION_SAVE }); } if (logger.isDebugEnabled()) { logger.debug(" --> request-filter: objectId={}, selectionId={} ", new String[] { objectId, selectionId }); } this.prepareRequest(request, response); this.authorizeAsgnAction(resourceName, "update"); IAsgnService<M, F, P> service = this.findAsgnService(this.serviceNameFromResourceName(resourceName)); service.save(selectionId, objectId); stopWatch.stop(); return ""; } catch (Exception e) { return this.handleException(e, response); } finally { this.finishRequest(); } }
From source file:net.nan21.dnet.core.web.controller.data.AbstractAsgnController.java
/** * /*w ww. j a v a2 s . co m*/ * @param resourceName * @param dataFormat * @param objectId * @param selectionId * @param response * @return * @throws Exception */ @RequestMapping(method = RequestMethod.POST, params = Constants.REQUEST_PARAM_ACTION + "=" + Constants.ASGN_ACTION_MOVE_RIGHT) @ResponseBody public String moveRight(@PathVariable String resourceName, @PathVariable String dataFormat, @RequestParam(value = Constants.REQUEST_PARAM_ASGN_OBJECT_ID, required = true) String objectId, @RequestParam(value = Constants.REQUEST_PARAM_ASGN_SELECTION_ID, required = true) String selectionId, @RequestParam(value = "p_selected_ids", required = true) String selectedIds, HttpServletRequest request, HttpServletResponse response) throws Exception { try { StopWatch stopWatch = new StopWatch(); stopWatch.start(); if (logger.isInfoEnabled()) { logger.info("Processing request: {}.{} -> action = {} ", new String[] { resourceName, dataFormat, Constants.ASGN_ACTION_MOVE_RIGHT }); } if (logger.isDebugEnabled()) { logger.debug(" --> request-filter: objectId={}, selectionId={}, selectedIds={} ", new String[] { objectId, selectionId, selectedIds }); } this.prepareRequest(request, response); this.authorizeAsgnAction(resourceName, "update"); IAsgnService<M, F, P> service = this.findAsgnService(this.serviceNameFromResourceName(resourceName)); service.moveRight(selectionId, this.selectedIdsAsList(selectedIds)); stopWatch.stop(); return ""; } catch (Exception e) { return this.handleException(e, response); } finally { this.finishRequest(); } }
From source file:net.nan21.dnet.core.web.controller.data.AbstractAsgnController.java
/** * //w w w . j av a 2 s .c o m * @param resourceName * @param dataFormat * @param objectId * @param selectionId * @param response * @return * @throws Exception */ @RequestMapping(method = RequestMethod.POST, params = Constants.REQUEST_PARAM_ACTION + "=" + Constants.ASGN_ACTION_MOVE_LEFT) @ResponseBody public String moveLeft(@PathVariable String resourceName, @PathVariable String dataFormat, @RequestParam(value = Constants.REQUEST_PARAM_ASGN_OBJECT_ID, required = true) String objectId, @RequestParam(value = Constants.REQUEST_PARAM_ASGN_SELECTION_ID, required = true) String selectionId, @RequestParam(value = "p_selected_ids", required = true) String selectedIds, HttpServletRequest request, HttpServletResponse response) throws Exception { try { StopWatch stopWatch = new StopWatch(); stopWatch.start(); if (logger.isInfoEnabled()) { logger.info("Processing request: {}.{} -> action = {} ", new String[] { resourceName, dataFormat, Constants.ASGN_ACTION_MOVE_LEFT }); } if (logger.isDebugEnabled()) { logger.debug(" --> request-filter: objectId={}, selectionId={}, selectedIds={} ", new String[] { objectId, selectionId, selectedIds }); } this.prepareRequest(request, response); this.authorizeAsgnAction(resourceName, "update"); IAsgnService<M, F, P> service = this.findAsgnService(this.serviceNameFromResourceName(resourceName)); service.moveLeft(selectionId, this.selectedIdsAsList(selectedIds)); stopWatch.stop(); return ""; } catch (Exception e) { return this.handleException(e, response); } finally { this.finishRequest(); } }
From source file:com.qualogy.qafe.gwt.server.RPCServiceImpl.java
public GEventItemDataObject executeEventItem(EventItemDataGVO eventItem) throws GWTServiceException, GWTApplicationStoreException { StopWatch stopWatch = new StopWatch(); logger.info("Event started[thread id=" + Thread.currentThread().getId() + "]"); stopWatch.start(); try {//w w w . j a v a 2s . c om EventItemProcessor eventItemProcessor = new EventItemProcessorImpl(); Map<String, Object> outputValues = eventItemProcessor.execute(eventItem); GEventItemDataObject gEventItemDataObject = new GEventItemDataObject(); gEventItemDataObject.setOutputValues(outputValues); stopWatch.stop(); return gEventItemDataObject; } catch (Exception e) { GWTServiceException gWTServiceException = handleException(e); //gWTServiceException.setGDataObject(ExceptionProcessor.handle(eventData, e)); stopWatch.stop(); if (gWTServiceException.getGDataObject() != null) { gWTServiceException.getGDataObject().setTime(Long.valueOf(stopWatch.getTime())); } logger.info("Event ends[thread id=" + Thread.currentThread().getId() + "]"); throw gWTServiceException; } }