Examples of TimeUnit


Examples of java.util.concurrent.TimeUnit

        @SuppressWarnings("rawtypes")
        ScheduledFuture expected = mock(ScheduledFuture.class);
        Runnable task = mock(Runnable.class);
        long delay = 10L;
        long period = 20L;
        TimeUnit unit = TimeUnit.SECONDS;

        when(this.executor.scheduleWithFixedDelay(task, delay, period, unit)).thenReturn(expected);

        ScheduledFuture<?> result = this.subject.scheduleWithFixedDelay(task, delay, period, unit);
View Full Code Here

Examples of java.util.concurrent.TimeUnit

        Lock lock = getLock(lockableComponent, invokedMethod);
        // the default access timeout (will be used in the absence of any explicit access timeout value for the invoked method)
        AccessTimeoutDetails defaultAccessTimeout = lockableComponent.getDefaultAccessTimeout();
        // set to the default values
        long time = defaultAccessTimeout.getValue();
        TimeUnit unit = defaultAccessTimeout.getTimeUnit();

        AccessTimeoutDetails accessTimeoutOnMethod = lockableComponent.getAccessTimeout(invokedMethod);
        if (accessTimeoutOnMethod != null) {
            if (accessTimeoutOnMethod.getValue() < 0) {
                // for any negative value of timeout, we just default to max timeout val and max timeout unit.
                // violation of spec! But we don't want to wait indefinitely.

                ROOT_LOGGER.debug("Ignoring a negative @AccessTimeout value: " + accessTimeoutOnMethod.getValue() + " and timeout unit: "
                        + accessTimeoutOnMethod.getTimeUnit().name() + ". Will default to timeout value: " + defaultAccessTimeout.getValue()
                        + " and timeout unit: " + defaultAccessTimeout.getTimeUnit().name());
            } else {
                // use the explicit access timeout values specified on the method
                time = accessTimeoutOnMethod.getValue();
                unit = accessTimeoutOnMethod.getTimeUnit();
            }
        }
        // try getting the lock
        boolean success = lock.tryLock(time, unit);
        if (!success) {
            throw MESSAGES.concurrentAccessTimeoutException(invocationContext,time + unit.name());
        }
        try {
            // lock obtained. now proceed!
            return invocationContext.proceed();
        } finally {
View Full Code Here

Examples of java.util.concurrent.TimeUnit

      // This is linked to keep insertion order
      Set<CacheEntry<Object, String>> valuesInserted = new HashSet<>();
      Cache<Object, String> cache = cache(0, CACHE_NAME);
      for (int i = 0; i < 3; ++i) {
         Object key = getKeyTiedToCache(cache);
         TimeUnit unit = TimeUnit.MINUTES;
         cache.put(key, key.toString(), 10, unit, i + 1, unit);

         valuesInserted.add(new TransientMortalCacheEntry(key, key.toString(), unit.toMillis(i + 1), unit.toMillis(10),
                                                          System.currentTimeMillis()));
      }

      EntryRetriever<Object, String> retriever = cache(0, CACHE_NAME).getAdvancedCache().getComponentRegistry().getComponent(
            EntryRetriever.class);
View Full Code Here

Examples of java.util.concurrent.TimeUnit

                    config.setMaxSize(maxSize);
                } else if (PassivationStoreResourceDefinition.IDLE_TIMEOUT.getName().equals(attributeName)) {
                    long timeout = PassivationStoreResourceDefinition.IDLE_TIMEOUT.resolveModelAttribute(context, model).asLong();
                    config.setIdleTimeout(timeout);
                } else if (PassivationStoreResourceDefinition.IDLE_TIMEOUT_UNIT.getName().equals(attributeName)) {
                    TimeUnit unit = TimeUnit.valueOf(PassivationStoreResourceDefinition.IDLE_TIMEOUT_UNIT.resolveModelAttribute(context, model).asString());
                    config.setIdleTimeoutUnit(unit);
                } else {
                    this.apply(config, context, attributeName, model);
                }
            }
View Full Code Here

Examples of java.util.concurrent.TimeUnit

        }
        if (data instanceof SessionBean31MetaData) {
            SessionBean31MetaData sessionBean31MetaData = (SessionBean31MetaData) data;
            final StatefulTimeoutMetaData statefulTimeout = sessionBean31MetaData.getStatefulTimeout();
            if (statefulTimeout != null) {
                TimeUnit unit = TimeUnit.MINUTES;
                if (statefulTimeout.getUnit() != null) {
                    unit = statefulTimeout.getUnit();
                }
                componentConfiguration.setStatefulTimeout(new StatefulTimeoutInfo(statefulTimeout.getTimeout(), unit));
            }
View Full Code Here

Examples of java.util.concurrent.TimeUnit

    private static Integer timeout(final ContainerTransactionMetaData containerTransaction) {
        final List<TransactionTimeoutMetaData> transactionTimeouts = containerTransaction.getAny(TransactionTimeoutMetaData.class);
        if (transactionTimeouts == null || transactionTimeouts.isEmpty())
            return null;
        final TransactionTimeoutMetaData transactionTimeout = transactionTimeouts.get(0);
        final TimeUnit unit = transactionTimeout.getUnit() == null ? TimeUnit.SECONDS : transactionTimeout.getUnit();
        return (int)unit.toSeconds(transactionTimeout.getTimeout());
    }
View Full Code Here

Examples of java.util.concurrent.TimeUnit

                            enqueueCondition.await();
                        } catch (InterruptedException e) {
                            intr = true;
                        }
                    } else {
                        final TimeUnit timeUnit = keepAliveTimeUnit;
                        final long time = keepAliveTime;
                        final long remaining = time - timeUnit.convert(elapsed, TimeUnit.MILLISECONDS);
                        if (remaining <= 0L && (allowCoreThreadTimeout || threadCount > coreThreadLimit)) {
                            // the timeout has expired
                            return pollTask();
                        }
                        try {
View Full Code Here

Examples of java.util.concurrent.TimeUnit

      }
   }

   public void testTransactionalModificationsHappenInDiffThread(Method m) throws Exception {
      final int waitTimeout = 10;
      final TimeUnit waitUnit = TimeUnit.SECONDS;
      try {
         final TransactionFactory gtf = new TransactionFactory();
         gtf.init(false, false, true, false);
         final String k1 = k(m, 1), k2 = k(m, 2), v1 = v(m, 1), v2 = v(m, 2);
         final ConcurrentMap<Object, Modification> localMods = new ConcurrentHashMap<Object, Modification>();
View Full Code Here

Examples of java.util.concurrent.TimeUnit

      }
   }

   public void testTransactionalModificationsAreCoalesced(Method m) throws Exception {
      final int waitTimeout = 10;
      final TimeUnit waitUnit = TimeUnit.SECONDS;
      try {
         final TransactionFactory gtf = new TransactionFactory();
         gtf.init(false, false, true, false);
         final String k1 = k(m, 1), k2 = k(m, 2), k3 = k(m, 3), v1 = v(m, 1), v2 = v(m, 2), v3 = v(m, 3);
         final AtomicInteger storeCount = new AtomicInteger();
View Full Code Here

Examples of net.sf.mpxj.TimeUnit

                  }

                  case DURATION :
                  {
                     FieldType unitsType = m_type.getUnitsType();
                     TimeUnit units = (TimeUnit) getFieldData(id, unitsType, fixedData, varData);
                     if (units == null)
                     {
                        units = TimeUnit.HOURS;
                     }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.