APISonar


org.infinispan.util.TimeService.time

> org > infinispan > util > TimeService > time
org APIs infinispan APIs util APIs TimeService APIs time APIs

Example 1
private TimeService ts;

   protected synchronized void fetchClusterWideStatsIfNeeded() {
      if (launchNewDistTask()) {
         List<CompletableFuture<Map<String, Number>>> responseList = Collections.emptyList();
         try {
            responseList = des.submitEverywhere(new DistributedCacheStatsCallable());
            updateFieldsFromResponseMap(responseList);
         } catch (Exception e) {
            log.warn("Could not execute cluster wide cache stats operation ", e);
         } finally {
            statsUpdateTimestamp = ts.time();
         }
      }
   }
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 unlock(Collection<Object> lockedKeys, Object lockOwner) {
      final long timestamp = timeService.time();

      for (Object key : lockedKeys) {
         LockInfo lockInfo = lockInfoMap.get(key);
         if (lockInfo != null && lockInfo.owner.equals(lockOwner)) {
            lockInfo.updateStats(timestamp);
            lockInfoMap.remove(key);
         }
      }
      actual.unlock(lockedKeys, lockOwner);
   }
Example 4
private TimeService timeService;

   public void resetStatistics() {
      if (getStatisticsEnabled()) {
         for (String cn : cm.getCacheNames()) {
            if (cm.cacheExists(cn)) {
               cm.getCache(cn).getAdvancedCache().getStats().reset();
            }
         }
         resetNanoseconds.set(timeService.time());
      }
   }
Example 5
private TimeService ts;

   public void resetStatistics() {
      if (isStatisticsEnabled()) {
         reset();
         resetNanoseconds.set(ts.time());
      }
   }
Example 6
private final TimeService timeService;

   public void reset() {
      if (cacheManager.getCacheManagerConfiguration().defaultCacheName().isPresent())
         resetCache(cacheManager.getCache());
      for (String cacheName : cacheManager.getCacheNames()) {
         resetCache(cacheManager.getCache(cacheName));
      }
      timestamp = timeService.time();
   }
Example 7
@Inject private 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 8
private TimeService ts;

   protected boolean launchNewDistTask() {
      long duration = ts.timeDuration(statsUpdateTimestamp, ts.time(), TimeUnit.MILLISECONDS);
      return duration > staleStatsTreshold;
   }
Example 9
public ConcurrentGlobalContainer(TimeService timeService) {
      this.timeService = timeService;
      flushing = new AtomicBoolean(false);
      queue = new LinkedBlockingQueue<Mergeable>();
      values = create();
      values[0] = timeService.time();
   }
Example 10
private final TimeService timeService;

   public JGroupsBackupResponse(Map<XSiteBackup, Future<Response>> syncBackupCalls, TimeService timeService) {
      this.syncBackupCalls = syncBackupCalls;
      this.timeService = timeService;
      sendTimeNanos = timeService.time();
   }
Example 11
@Inject private 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 12
private TimeService timeService;

   public long synchronizeData(@Parameter(name = "migratorName", description = "The name of the migrator to use") String migratorName,
                               @Parameter(name = "readBatch", description = "Numbers of entries transferred at a time from the old cluster") int readBatch,
                               @Parameter(name = "threads", description = "Number of threads per node used to write data to the new cluster") int threads) throws Exception {
      TargetMigrator migrator = getMigrator(migratorName);
      long start = timeService.time();
      long count = migrator.synchronizeData(cache, readBatch, threads);
      log.entriesMigrated(count, cache.getName(), Util.prettyPrintTime(timeService.timeDuration(start, TimeUnit.MILLISECONDS)));
      return count;
   }
Example 13
private TimeService timeService;

   private void mergeMetadata(EntityManager em, MetadataEntity metadata) {
      long begin = timeService.time();
      try {
         em.merge(metadata);
      } finally {
         stats.addMetadataMerge(timeService.time() - begin);
      }
   }
Example 14
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 15
private 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 16
@Inject private TimeService timeService;

   public void resetStatistics() {
      if (getStatisticsEnabled()) {
         getEnabledStats().forEach( stats -> stats.reset());
         resetNanoseconds.set(timeService.time());
      }
   }
Example 17
private TimeService timeService;

   public void start() {
      startNanoseconds.set(timeService.time());
      resetNanoseconds.set(startNanoseconds.get());
   }
Example 18
private final TimeService timeService;

   public <T> CompletionStage<T> invokeCommands(Collection<Address> targets,
                                                Function<Address, ReplicableCommand> commandGenerator,
                                                ResponseCollector<T> collector, RpcOptions rpcOptions) {
      long start = timeService.time();
      CompletionStage<T> request = actual.invokeCommands(targets, commandGenerator, collector, rpcOptions);
      return request.thenApply(responseMap -> {
         targets.forEach(
               target -> updateStats(commandGenerator.apply(target), true, timeService.timeDuration(start, NANOSECONDS),
                                     Collections.singleton(target)));
         return responseMap;
      });
   }
Example 19
private TimeService timeService;

   public void passivateAll() throws PersistenceException {
      if (enabled && !skipOnStop) {
         long start = timeService.time();
         log.passivatingAllEntries();
         for (InternalCacheEntry e : container) {
            if (trace) log.tracef("Passivating %s", e.getKey());
            persistenceManager.writeToAllStores(marshalledEntryFactory.newMarshalledEntry(e.getKey(), e.getValue(),
                                                                        internalMetadata(e)), BOTH);
         }
         log.passivatedEntries(container.size(),
                               Util.prettyPrintTime(timeService.timeDuration(start, TimeUnit.MILLISECONDS)));
      }
   }
Example 20
private 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 21
private 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();
      Object ret = invokeNextInterceptor(ctx, command);
      long end = timeService.time();
      updateTime(duration, counter, start, end, globalTransaction, ctx.isOriginLocal());
      cacheStatisticManager.setTransactionOutcome(commit, globalTransaction, ctx.isOriginLocal());
      cacheStatisticManager.terminateTransaction(globalTransaction, true, true);
      return ret;
   }
Example 22
@Inject private TimeService timeService;

   private Object updateStoreStatistics(InvocationContext ctx, WriteCommand command) throws Throwable {
      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 23
private final TimeService timeService;

   public Map<Address, Response> invokeRemotely(Collection<Address> recipients, ReplicableCommand rpcCommand,
                                                ResponseMode mode, long timeout, boolean usePriorityQueue) {
      long start = timeService.time();
      Map<Address, Response> ret = actual.invokeRemotely(recipients, rpcCommand, mode, timeout, usePriorityQueue);
      updateStats(rpcCommand, mode.isSynchronous(), timeService.timeDuration(start, NANOSECONDS), recipients);
      return ret;
   }
Example 24
private final TimeService timeService;

   public SessionImpl(final CodecRegistry codecRegistry, final EmbeddedCacheManager cacheManager, final String id,
                      TimeService timeService) {
      if (timeService == null) {
         throw new IllegalArgumentException("TimeService cannot be null");
      }
      this.codecRegistry = codecRegistry;
      this.cacheManager = cacheManager;
      this.timeService = timeService;
      this.id = id;
      timestamp = timeService.time();
      codec = this.codecRegistry.getCodec("none");
   }
Example 25
private final TimeService timeService;

   public void invokeRemotelyInFuture(Collection<Address> recipients, ReplicableCommand rpc, boolean usePriorityQueue,
                                      NotifyingNotifiableFuture<Object> future, long timeout) {
      long start = timeService.time();
      actual.invokeRemotelyInFuture(recipients, rpc, usePriorityQueue, future, timeout);
      updateStats(rpc, false, timeService.timeDuration(start, NANOSECONDS), recipients);
   }