APISonar


org.infinispan.commons.time.TimeService.time

> org > infinispan > commons > time > TimeService > time
org APIs infinispan APIs commons APIs time APIs TimeService APIs time APIs

Example 1
private TimeService timeService;

   private void mergeEntity(EntityManager em, Object entity) {
      long begin = timeService.time();
      try {
         em.merge(entity);
      } finally {
         stats.addEntityMerge(timeService.time() - begin);
      }
   }
Example 2
private final TimeService timeService;

   public void unlockAll(Collection<?> keys, Object lockOwner) {
      final long timestamp = timeService.time();

      for (Object key : keys) {
         onUnlock(key, lockOwner, timestamp);
      }
      actual.unlockAll(keys, lockOwner);
   }
Example 3
private final TimeService timeService;

   public void reset() {
      if (configurationManager.getGlobalConfiguration().defaultCacheName().isPresent())
         resetCache(cacheManager.getCache());
      for (String cacheName : cacheManager.getCacheNames()) {
         resetCache(cacheManager.getCache(cacheName));
      }
      timestamp = timeService.time();
   }
Example 4
@Inject TimeService timeService;

   public Map<K, V> getAndPutAll(Map<? extends K, ? extends V> entries) {
      boolean statisticsEnabled = statsCollector.getStatisticsEnabled();
      long start = 0;
      if (statisticsEnabled) {
         start = timeService.time();
      }
      Map<K, V> map = super.getAndPutAll(entries);
      if (statisticsEnabled) {
         long end = timeService.time();
         statsCollector.recordStores(entries.size(), end - start);
      }
      return map;
   }
Example 5
public ConcurrentGlobalContainer(TimeService timeService) {
      this.timeService = timeService;
      flushing = new AtomicBoolean(false);
      queue = new LinkedBlockingQueue<Mergeable>();
      values = create();
      values[0] = timeService.time();
   }
Example 6
@Inject TimeService timeService;

   synchronized void fetchClusterWideStatsIfNeeded() {
      long duration = timeService.timeDuration(statsUpdateTimestamp, timeService.time(), TimeUnit.MILLISECONDS);
      if (duration > DEFAULT_STALE_STATS_THRESHOLD) {
         try {
            updateStats();
         } catch (Exception e) {
            log.error("Could not execute cluster wide cache stats operation ", e);
            throw new CacheException("Could not execute cluster wide cache stats operation", e);
         } finally {
            statsUpdateTimestamp = timeService.time();
         }
      }
   }
Example 7
private final TimeService timeService;

   public JGroupsBackupResponse(Map<XSiteBackup, CompletableFuture<ValidResponse>> backupCalls,
         TimeService timeService) {
      this.backupCalls = Objects.requireNonNull(backupCalls);
      this.timeService = timeService;
      sendTimeNanos = timeService.time();
   }
Example 8
private final TimeService timeService;

   public Map<Address, Response> invokeRemotely(Map<Address, ReplicableCommand> rpcs, RpcOptions options) {
      long start = timeService.time();
      Map<Address, Response> responseMap = actual.invokeRemotely(rpcs, options);
      for (Entry<Address, ReplicableCommand> entry : rpcs.entrySet()) {
         // TODO: This is giving a time for all rpcs combined...
         updateStats(entry.getValue(), options.responseMode().isSynchronous(),
                     timeService.timeDuration(start, NANOSECONDS), Collections.singleton(entry.getKey()));
      }
      return responseMap;
   }
Example 9
@Inject TimeService timeService;

   public long synchronizeData(@Parameter(name="migratorName", description="The name of the migrator to use") String migratorName) throws Exception {
      TargetMigrator migrator = getMigrator(migratorName);
      long start = timeService.time();
      long count = migrator.synchronizeData(cache);
      log.entriesMigrated(count, cache.getName(), Util.prettyPrintTime(timeService.timeDuration(start, TimeUnit.MILLISECONDS)));
      return count;

   }
Example 10
@Inject TimeService timeService;

   public void resetStatistics() {
      if (getStatisticsEnabled()) {
         getEnabledStats().forEach(Stats::reset);
         resetNanoseconds.set(timeService.time());
      }
   }
Example 11
public TxState setStatus(Status newStatus, boolean cleanupModification, TimeService timeService) {
      return new TxState(globalTransaction, newStatus, cleanupModification ? null : modifications, recoverable, timeout,
            timeService.time());
   }
Example 12
@Inject TimeService timeService;

   void expireSessions() {
      long timeBoundary = timeService.time() - sessionTimeout * 1000000l;
      for (Iterator<Session> i = sessions.values().iterator(); i.hasNext(); ) {
         Session session = i.next();
         if (timeBoundary - session.getTimestamp() > 0) {
            i.remove();
            if (log.isDebugEnabled()) {
               log.debugf("Removed expired interpreter session %s", session.getId());
            }
         }
      }
   }
Example 13
@Inject TimeService timeService;

   protected V getAndPutInternal(K key, V value, Metadata metadata) {
      boolean statisticsEnabled = statsCollector.getStatisticsEnabled();
      long start = 0;
      if (statisticsEnabled) {
         start = timeService.time();
      }
      V ret = super.getAndPutInternal(key, value, metadata);
      if (statisticsEnabled) {
         long end = timeService.time();
         statsCollector.recordStores(1, end - start);
      }
      return ret;
   }
Example 14
private final TimeService timeService;

   public Map<Address, Response> invokeRemotely(Collection<Address> recipients, ReplicableCommand rpc, RpcOptions options) {
      long start = timeService.time();
      Map<Address, Response> responseMap = actual.invokeRemotely(recipients, rpc, options);
      updateStats(rpc, options.responseMode().isSynchronous(), timeService.timeDuration(start, NANOSECONDS), recipients);
      return responseMap;
   }
Example 15
@Inject TimeService timeService;

   private Object visitSecondPhaseCommand(TxInvocationContext ctx, TransactionBoundaryCommand command, boolean commit,
                                          ExtendedStatistic duration, ExtendedStatistic counter) throws Throwable {
      GlobalTransaction globalTransaction = command.getGlobalTransaction();
      if (trace) {
         log.tracef("Visit 2nd phase command %s. Is it local? %s. Transaction is %s", command,
                    ctx.isOriginLocal(), globalTransaction.globalId());
      }
      long start = timeService.time();
      return invokeNextThenAccept(ctx, command, (rCtx, rCommand, rv) -> {
         long end = timeService.time();
         updateTime(duration, counter, start, end, globalTransaction, rCtx.isOriginLocal());
         cacheStatisticManager.setTransactionOutcome(commit, globalTransaction, rCtx.isOriginLocal());
         cacheStatisticManager.terminateTransaction(globalTransaction, true, true);
      });
   }
Example 16
@Inject TimeService timeService;

   public void passivateAll() throws PersistenceException {
      if (enabled && !skipOnStop) {
         long start = timeService.time();
         CONTAINER.passivatingAllEntries();

         int count = container.sizeIncludingExpired();
         Iterable<MarshallableEntry> iterable = () -> new IteratorMapper<>(container.iterator(), e ->
            marshalledEntryFactory.create(e.getKey(), e.getValue(), e.getMetadata(), e.getExpiryTime(), e.getLastUsed()));
         CompletionStages.join(persistenceManager.writeBatchToAllNonTxStores(iterable, BOTH, 0));
         CONTAINER.passivatedEntries(count, Util.prettyPrintTime(timeService.timeDuration(start, TimeUnit.MILLISECONDS)));
      }
   }
Example 17
private final TimeService timeService;

   public <T> CompletionStage<T> invokeCommand(Collection<Address> targets, ReplicableCommand command,
                                               ResponseCollector<T> collector, RpcOptions rpcOptions) {
      long start = timeService.time();
      CompletionStage<T> request = actual.invokeCommand(targets, command, collector, rpcOptions);
      return request.thenApply(responseMap -> {
         updateStats(command, true, timeService.timeDuration(start, NANOSECONDS), targets);
         return responseMap;
      });
   }
Example 18
public SessionImpl(final CodecRegistry codecRegistry, final EmbeddedCacheManager cacheManager, final String id,
                      TimeService timeService, ConfigurationManager configurationManager) {
      if (timeService == null) {
         throw new IllegalArgumentException("TimeService cannot be null");
      }
      this.codecRegistry = codecRegistry;
      this.cacheManager = cacheManager;
      this.timeService = timeService;
      this.configurationManager = configurationManager;
      this.id = id;
      timestamp = timeService.time();
      codec = this.codecRegistry.getCodec("none");
   }
Example 19
@Inject TimeService timeService;

   private Object updateStoreStatistics(InvocationContext ctx, WriteCommand command) {
      boolean statisticsEnabled = getStatisticsEnabled(command);
      if (!statisticsEnabled || !ctx.isOriginLocal())
         return invokeNext(ctx, command);

      long start = timeService.time();
      return invokeNextAndFinally(ctx, command, (rCtx, rCommand, rv, t) -> {
         if (rCommand.isSuccessful()) {
            long intervalNanoseconds = timeService.timeDuration(start, TimeUnit.NANOSECONDS);
            StripeB stripe = counters.stripeForCurrentThread();
            counters.add(StripeB.storeTimesFieldUpdater, stripe, intervalNanoseconds);
            counters.increment(StripeB.storesFieldUpdater, stripe);
         }
      });
   }
Example 20
private final TimeService timeService;

   public void documentsAdded(long increment) {
      long current = documentsDoneCounter.addAndGet(increment);
      if (current == increment) {
         startTime = timeService.time();
      }
      if (current % getStatusMessagePeriod() == 0) {
         printStatusMessage(startTime, current);
      }
   }
Example 21
@Inject TimeService timeService;

   public void resetStatistics() {
      hits.reset();
      misses.reset();
      stores.reset();
      evictions.reset();
      hitTimes.reset();
      missTimes.reset();
      storeTimes.reset();
      removeHits.reset();
      removeTimes.reset();
      removeMisses.reset();
      resetNanoseconds.set(timeService.time());
   }
Example 22
protected TransactionStatistics(ExtendedStatisticsContainer container, TimeService timeService) {
      this.timeService = timeService;
      this.initTime = timeService.time();
      this.readOnly = true; //as far as it does not tries to perform a put operation
      this.container = container;
      if (trace) {
         log.tracef("Created transaction statistics. Start time=%s", initTime);
      }
   }
Example 23
@Inject TimeService timeService;

   public void setStatisticsEnabled(boolean enabled) {
      this.statisticsEnabled = enabled;
      if (enabled) {
         //yes technically we do not reset stats but we initialize them
         resetNanoseconds.set(timeService.time());
      }
   }
Example 24
public void testMonotonicIncrement() {
      TimeService timeService = TIME_SERVICE;
      //less or equals in all the cases because the system may not have enough precision and the methods may return
      // the same value.
      assertTrue(timeService.time() <= timeService.time());
      assertTrue(timeService.wallClockTime() <= timeService.wallClockTime());
   }
Example 25
@Inject TimeService timeService;

   public void resetStatistics() {
      counters.reset(StripeB.hitsFieldUpdater);
      counters.reset(StripeB.missesFieldUpdater);
      counters.reset(StripeB.storesFieldUpdater);
      counters.reset(StripeB.evictionsFieldUpdater);
      counters.reset(StripeB.hitTimesFieldUpdater);
      counters.reset(StripeB.missTimesFieldUpdater);
      counters.reset(StripeB.storeTimesFieldUpdater);
      counters.reset(StripeB.removeHitsFieldUpdater);
      counters.reset(StripeB.removeTimesFieldUpdater);
      counters.reset(StripeB.removeMissesFieldUpdater);
      resetNanoseconds.set(timeService.time());
   }