@Override public IHttpResponse execute() throws IOException { StopWatch responseStopWatch = new StopWatch(); HttpResponse httpResponse = myClient.execute(myRequest); return new ApacheHttpResponse(httpResponse, responseStopWatch); }
@Override public void rejectedExecution(Runnable theRunnable, ThreadPoolExecutor theExecutor) { ourLog.info("Note: Executor queue is full ({} elements), waiting for a slot to become available!", executorQueue.size()); StopWatch sw = new StopWatch(); try { executorQueue.put(theRunnable); } catch (InterruptedException theE) { throw new RejectedExecutionException("Task " + theRunnable.toString() + " rejected from " + theE.toString()); } ourLog.info("Slot become available after {}ms", sw.getMillis()); } };
@Override public void rejectedExecution(Runnable theRunnable, ThreadPoolExecutor theExecutor) { ourLog.info("Note: Subscription triggering queue is full ({} elements), waiting for a slot to become available!", executorQueue.size()); StopWatch sw = new StopWatch(); try { executorQueue.put(theRunnable); } catch (InterruptedException theE) { // Restore interrupted state... Thread.currentThread().interrupt(); throw new RejectedExecutionException("Task " + theRunnable.toString() + " rejected from " + theE.toString()); } ourLog.info("Slot become available after {}ms", sw.getMillis()); } };
private void ensureHaveQuery() { if (myWrap == null) { ourLog.debug("Searching for unique index matches over {} candidate query strings", myUniqueQueryStrings.size()); StopWatch sw = new StopWatch(); Collection<Long> resourcePids = myResourceIndexedCompositeStringUniqueDao.findResourcePidsByQueryStrings(myUniqueQueryStrings); ourLog.debug("Found {} unique index matches in {}ms", resourcePids.size(), sw.getMillis()); myWrap = resourcePids.iterator(); } }
private int doExpungeEverythingQuery(String theQuery) { StopWatch sw = new StopWatch(); int outcome = myEntityManager.createQuery(theQuery).executeUpdate(); if (outcome > 0) { ourLog.debug("Query affected {} rows in {}: {}", outcome, sw.toString(), theQuery); } else { ourLog.debug("Query affected {} rows in {}: {}", outcome, sw.toString(), theQuery); } return outcome; }
@Transactional(propagation = Propagation.REQUIRED) @Override public Set<TermConcept> findCodesAbove(Long theCodeSystemResourcePid, Long theCodeSystemVersionPid, String theCode) { StopWatch stopwatch = new StopWatch(); TermConcept concept = fetchLoadedCode(theCodeSystemResourcePid, theCode); if (concept == null) { return Collections.emptySet(); } Set<TermConcept> retVal = new HashSet<>(); retVal.add(concept); fetchParents(concept, retVal); ourLog.info("Fetched {} codes above code {} in {}ms", retVal.size(), theCode, stopwatch.getMillis()); return retVal; }
@Override public IHttpResponse execute() throws IOException { StopWatch responseStopWatch = new StopWatch(); myRequestBuilder.method(getHttpVerbName(), myRequestBody); Call call = myClient.newCall(myRequestBuilder.build()); return new OkHttpRestfulResponse(call.execute(), responseStopWatch); }
@Override public DaoMethodOutcome delete(IIdType theId, RequestDetails theRequestDetails) { List<DeleteConflict> deleteConflicts = new ArrayList<DeleteConflict>(); StopWatch w = new StopWatch(); DaoMethodOutcome retVal = delete(theId, deleteConflicts, theRequestDetails); validateDeleteConflictsEmptyOrThrowException(deleteConflicts); ourLog.debug("Processed delete on {} in {}ms", theId.getValue(), w.getMillisAndRestart()); return retVal; }
@Override public TagList getTags(IIdType theResourceId, RequestDetails theRequestDetails) { // Notify interceptors ActionRequestDetails requestDetails = new ActionRequestDetails(theRequestDetails, null, theResourceId); notifyInterceptors(RestOperationTypeEnum.GET_TAGS, requestDetails); StopWatch w = new StopWatch(); TagList retVal = super.getTags(myResourceType, theResourceId); ourLog.debug("Processed getTags on {} in {}ms", theResourceId, w.getMillisAndRestart()); return retVal; }
@Override public IBundleProvider history(Date theSince, Date theUntil, RequestDetails theRequestDetails) { // Notify interceptors ActionRequestDetails requestDetails = new ActionRequestDetails(theRequestDetails); notifyInterceptors(RestOperationTypeEnum.HISTORY_TYPE, requestDetails); StopWatch w = new StopWatch(); IBundleProvider retVal = super.history(myResourceName, null, theSince, theUntil); ourLog.debug("Processed history on {} in {}ms", myResourceName, w.getMillisAndRestart()); return retVal; }
@Override public IBundleProvider history(Date theSince, Date theUntil, RequestDetails theRequestDetails) { if (theRequestDetails != null) { // Notify interceptors ActionRequestDetails requestDetails = new ActionRequestDetails(theRequestDetails); notifyInterceptors(RestOperationTypeEnum.HISTORY_SYSTEM, requestDetails); } StopWatch w = new StopWatch(); IBundleProvider retVal = super.history(null, null, theSince, theUntil); ourLog.info("Processed global history in {}ms", w.getMillisAndRestart()); return retVal; }
@Override public TagList getAllResourceTags(RequestDetails theRequestDetails) { // Notify interceptors ActionRequestDetails requestDetails = new ActionRequestDetails(theRequestDetails); notifyInterceptors(RestOperationTypeEnum.GET_TAGS, requestDetails); StopWatch w = new StopWatch(); TagList tags = super.getTags(myResourceType, null); ourLog.debug("Processed getTags on {} in {}ms", myResourceName, w.getMillisAndRestart()); return tags; }
protected void flushJpaSession() { SessionImpl session = (SessionImpl) myEntityManager.unwrap(Session.class); int insertionCount = session.getActionQueue().numberOfInsertions(); int updateCount = session.getActionQueue().numberOfUpdates(); StopWatch sw = new StopWatch(); myEntityManager.flush(); ourLog.debug("Session flush took {}ms for {} inserts and {} updates", sw.getMillis(), insertionCount, updateCount); }
protected void flushJpaSession() { SessionImpl session = (SessionImpl) myEntityManager.unwrap(Session.class); int insertionCount = session.getActionQueue().numberOfInsertions(); int updateCount = session.getActionQueue().numberOfUpdates(); StopWatch sw = new StopWatch(); myEntityManager.flush(); ourLog.debug("Session flush took {}ms for {} inserts and {} updates", sw.getMillis(), insertionCount, updateCount); }
private <T> void doDelete(String theDescriptor, Supplier<Slice<T>> theLoader, Supplier<Integer> theCounter, JpaRepository<T, ?> theDao) { int count; ourLog.info(" * Deleting {}", theDescriptor); int totalCount = theCounter.get(); StopWatch sw = new StopWatch(); count = 0; while (true) { Slice<T> link = theLoader.get(); if (link.hasContent() == false) { break; } TransactionTemplate txTemplate = new TransactionTemplate(myTransactionManager); txTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); txTemplate.execute(t -> { theDao.deleteInBatch(link); return null; }); count += link.getNumberOfElements(); ourLog.info(" * {} {} deleted - {}/sec - ETA: {}", count, theDescriptor, sw.formatThroughput(count, TimeUnit.SECONDS), sw.getEstimatedTimeRemaining(count, totalCount)); } theDao.flush(); }
@Override public IBaseResource readByPid(Long thePid) { StopWatch w = new StopWatch(); Optional<ResourceTable> entity = myResourceTableDao.findById(thePid); if (!entity.isPresent()) { throw new ResourceNotFoundException("No resource found with PID " + thePid); } if (entity.get().getDeleted() != null) { throw new ResourceGoneException("Resource was deleted at " + new InstantType(entity.get().getDeleted()).getValueAsString()); } T retVal = toResource(myResourceType, entity.get(), null, false); ourLog.debug("Processed read on {} in {}ms", thePid, w.getMillis()); return retVal; }
@Override public IBundleProvider history(final IIdType theId, final Date theSince, Date theUntil, RequestDetails theRequestDetails) { // Notify interceptors ActionRequestDetails requestDetails = new ActionRequestDetails(theRequestDetails, getResourceName(), theId); notifyInterceptors(RestOperationTypeEnum.HISTORY_INSTANCE, requestDetails); StopWatch w = new StopWatch(); IIdType id = theId.withResourceType(myResourceName).toUnqualifiedVersionless(); BaseHasResource entity = readEntity(id); IBundleProvider retVal = super.history(myResourceName, entity.getId(), theSince, theUntil); ourLog.debug("Processed history on {} in {}ms", id, w.getMillisAndRestart()); return retVal; }
@Override public IHttpResponse execute() { StopWatch responseStopWatch = new StopWatch(); Invocation invocation = getRequest().build(getRequestType().name(), getEntity()); Response response = invocation.invoke(); return new JaxRsHttpResponse(response, responseStopWatch); }
@Override public void addTag(IIdType theId, TagTypeEnum theTagType, String theScheme, String theTerm, String theLabel) { StopWatch w = new StopWatch(); BaseHasResource entity = readEntity(theId); if (entity == null) { throw new ResourceNotFoundException(theId); } for (BaseTag next : new ArrayList<>(entity.getTags())) { if (ObjectUtil.equals(next.getTag().getTagType(), theTagType) && ObjectUtil.equals(next.getTag().getSystem(), theScheme) && ObjectUtil.equals(next.getTag().getCode(), theTerm)) { return; } } entity.setHasTags(true); TagDefinition def = getTagOrNull(TagTypeEnum.TAG, theScheme, theTerm, theLabel); if (def != null) { BaseTag newEntity = entity.addTag(def); if (newEntity.getTagId() == null) { myEntityManager.persist(newEntity); myEntityManager.merge(entity); } } ourLog.debug("Processed addTag {}/{} on {} in {}ms", theScheme, theTerm, theId, w.getMillisAndRestart()); }
@Override public T read(IIdType theId, RequestDetails theRequestDetails, boolean theDeletedOk) { validateResourceTypeAndThrowIllegalArgumentException(theId); // Notify interceptors if (theRequestDetails != null) { ActionRequestDetails requestDetails = new ActionRequestDetails(theRequestDetails, getResourceName(), theId); RestOperationTypeEnum operationType = theId.hasVersionIdPart() ? RestOperationTypeEnum.VREAD : RestOperationTypeEnum.READ; notifyInterceptors(operationType, requestDetails); } StopWatch w = new StopWatch(); BaseHasResource entity = readEntity(theId); validateResourceType(entity); T retVal = toResource(myResourceType, entity, null, false); if (theDeletedOk == false) { if (entity.getDeleted() != null) { throw new ResourceGoneException("Resource was deleted at " + new InstantType(entity.getDeleted()).getValueAsString()); } } ourLog.debug("Processed read on {} in {}ms", theId.getValue(), w.getMillisAndRestart()); return retVal; }