Example usage for java.util.concurrent TimeUnit DAYS

List of usage examples for java.util.concurrent TimeUnit DAYS

Introduction

In this page you can find the example usage for java.util.concurrent TimeUnit DAYS.

Prototype

TimeUnit DAYS

To view the source code for java.util.concurrent TimeUnit DAYS.

Click Source Link

Document

Time unit representing twenty four hours.

Usage

From source file:com.linkedin.pinot.query.aggregation.AggregationGroupByWithDictionaryAndTrieTreeOperatorMultiValueTest.java

private void setupSegment() throws Exception {
    final String filePath = TestUtils
            .getFileFromResourceUrl(getClass().getClassLoader().getResource(AVRO_DATA));

    if (INDEX_DIR.exists()) {
        FileUtils.deleteQuietly(INDEX_DIR);
    }// w ww.  j  a  v  a 2 s  .co  m

    final SegmentGeneratorConfig config = SegmentTestUtils.getSegmentGenSpecWithSchemAndProjectedColumns(
            new File(filePath), INDEX_DIR, "daysSinceEpoch", TimeUnit.DAYS, "test");

    final SegmentIndexCreationDriver driver = SegmentCreationDriverFactory.get(null);
    driver.init(config);
    driver.build();

    LOGGER.debug("built at : {}", INDEX_DIR.getAbsolutePath());
    final File indexSegmentDir = new File(INDEX_DIR, driver.getSegmentName());
    _indexSegment = ColumnarSegmentLoader.load(indexSegmentDir, ReadMode.heap);
    _medataMap = ((SegmentMetadataImpl) _indexSegment.getSegmentMetadata()).getColumnMetadataMap();
}

From source file:gr.cti.android.experimentation.service.ModelService.java

public String durationString(long millis) {
    long days = TimeUnit.MILLISECONDS.toDays(millis);
    millis -= TimeUnit.DAYS.toMillis(days);
    long hours = TimeUnit.MILLISECONDS.toHours(millis);
    millis -= TimeUnit.HOURS.toMillis(hours);
    long minutes = TimeUnit.MILLISECONDS.toMinutes(millis);
    millis -= TimeUnit.MINUTES.toMillis(minutes);
    long seconds = TimeUnit.MILLISECONDS.toSeconds(millis);

    return String.valueOf(days) + " Days " + hours + " Hours " + minutes + " Minutes " + seconds + " Seconds";
}

From source file:org.apache.hadoop.yarn.server.resourcemanager.quota.TestQuotaService.java

public void CheckProjectDailyCost(float used) throws IOException {

    Map<String, ProjectDailyCost> hopYarnProjectsDailyCostList;

    LightWeightRequestHandler bomb;/* ww  w . j  a  va  2  s .com*/
    bomb = new LightWeightRequestHandler(YARNOperationType.TEST) {
        @Override
        public Object performTask() throws IOException {
            connector.beginTransaction();
            connector.writeLock();

            ProjectsDailyCostDataAccess _pdcDA = (ProjectsDailyCostDataAccess) RMStorageFactory
                    .getDataAccess(ProjectsDailyCostDataAccess.class);
            Map<String, ProjectDailyCost> hopYarnProjectsDailyCostList = _pdcDA.getAll();

            connector.commit();
            return hopYarnProjectsDailyCostList;
        }
    };

    hopYarnProjectsDailyCostList = (Map<String, ProjectDailyCost>) bomb.handle();
    long _miliSec = System.currentTimeMillis();
    final long _day = TimeUnit.DAYS.convert(_miliSec, TimeUnit.MILLISECONDS);

    for (Map.Entry<String, ProjectDailyCost> _ypdc : hopYarnProjectsDailyCostList.entrySet()) {
        Assert.assertTrue(_ypdc.getValue().getProjectName().equalsIgnoreCase("Project07"));
        Assert.assertTrue(_ypdc.getValue().getProjectUser().equalsIgnoreCase("rizvi"));
        Assert.assertEquals(_day, _ypdc.getValue().getDay());
        Assert.assertEquals(used, _ypdc.getValue().getCreditsUsed(), 0);

    }
}

From source file:metlos.executors.batch.BatchCpuThrottlingExecutorTest.java

private static BatchCpuThrottlingExecutor getExecutor(int nofThreads, float cpuUsage,
        ThreadFactory threadFactory) {
    return new BatchCpuThrottlingExecutor(nofThreads, nofThreads, 0, TimeUnit.DAYS, threadFactory, cpuUsage);
}

From source file:com.aegiswallet.services.PeerBlockchainService.java

@Override
public void onCreate() {
    super.onCreate();

    nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

    application = (PayBitsApplication) getApplication();
    prefs = PreferenceManager.getDefaultSharedPreferences(this);
    final Wallet wallet = application.getWallet();

    blockChainFile = new File(getDir("blockstore", Context.MODE_PRIVATE), Constants.BLOCKCHAIN_FILENAME);

    final boolean blockChainFileExists = blockChainFile.exists();

    if (!blockChainFileExists) {
        wallet.clearTransactions(0);//from w w  w. ja  v  a 2s  .  c  om
        wallet.setLastBlockSeenHeight(-1);
        wallet.setLastBlockSeenHash(null);
    }

    try {
        blockStore = new SPVBlockStore(Constants.NETWORK_PARAMETERS, blockChainFile);
        blockStore.getChainHead(); // detect corruptions as early as possible

        long earliestKeyCreationTime = wallet.getEarliestKeyCreationTime();

        if (earliestKeyCreationTime == 0)
            earliestKeyCreationTime = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(7);

        if (!blockChainFileExists && earliestKeyCreationTime > 0) {
            Log.d(TAG, "creating blockchain from checkpoint. attmpting to at least...");
            try {
                final InputStream checkpointsInputStream = getAssets().open(Constants.CHECKPOINTS_FILENAME);
                CheckpointManager.checkpoint(Constants.NETWORK_PARAMETERS, checkpointsInputStream, blockStore,
                        earliestKeyCreationTime);
            } catch (final IOException x) {
                Log.e(TAG, "problem reading checkpoint file..." + x.getMessage());
            }
        }

    } catch (final BlockStoreException x) {
        blockChainFile.delete();

        final String msg = "blockstore cannot be created";
        throw new Error(msg, x);
    }

    try {
        blockChain = new BlockChain(Constants.NETWORK_PARAMETERS, wallet, blockStore);
    } catch (final BlockStoreException x) {
        throw new Error("blockchain cannot be created", x);
    }

    bestChainHeightEver = prefs.getInt(Constants.PREFS_KEY_BEST_CHAIN_HEIGHT_EVER, 0);

    peerConnectivityListener = new PeerConnectivityListener();
    sendBroadcastPeerState(0);

    final IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
    intentFilter.addAction(Intent.ACTION_DEVICE_STORAGE_LOW);
    intentFilter.addAction(Intent.ACTION_DEVICE_STORAGE_OK);

    registerReceiver(connectivityReceiver, intentFilter);
    registerReceiver(tickReceiver, new IntentFilter(Intent.ACTION_TIME_TICK));
    maybeRotateKeys();

    tagPrefs = application.getSharedPreferences(getString(R.string.tag_pref_filename), Context.MODE_PRIVATE);

}

From source file:com.linkedin.pinot.query.aggregation.AggregationGroupByOperatorForMultiValueTest.java

private void setupSegment() throws Exception {
    final String filePath = TestUtils
            .getFileFromResourceUrl(getClass().getClassLoader().getResource(AVRO_DATA));

    if (INDEX_DIR.exists()) {
        FileUtils.deleteQuietly(INDEX_DIR);
    }/* w  ww  . ja  v  a2  s . c om*/

    final SegmentGeneratorConfig config = SegmentTestUtils.getSegmentGenSpecWithSchemAndProjectedColumns(
            new File(filePath), INDEX_DIR, "daysSinceEpoch", TimeUnit.DAYS, "test");

    final SegmentIndexCreationDriver driver = SegmentCreationDriverFactory.get(null);
    driver.init(config);
    driver.build();

    LOGGER.info("built at : {}", INDEX_DIR.getAbsolutePath());
    final File indexSegmentDir = new File(INDEX_DIR, driver.getSegmentName());
    _indexSegment = ColumnarSegmentLoader.load(indexSegmentDir, ReadMode.heap);
    _medataMap = ((SegmentMetadataImpl) _indexSegment.getSegmentMetadata()).getColumnMetadataMap();
}

From source file:com.codebullets.sagalib.timeout.InMemoryTimeoutManagerTest.java

/**
 * <pre>//www.  j a  v a  2  s. co m
 * Given => Multiple timeout are added
 * When  => timeout is canceled by saga id
 * Then  => does not throw a concurrency exception
 * </pre>
 */
@Test
public void cancelTimeouts_multipleTimeoutHaveBeenAdded_noConcurrentViolationException() {
    // given
    String sagaId = "sagaId_" + RandomStringUtils.randomAlphanumeric(5);
    ScheduledFuture future = mock(ScheduledFuture.class);
    when(executor.schedule(any(Runnable.class), anyLong(), any(TimeUnit.class))).thenReturn(future);
    sut.requestTimeout(null, sagaId, 1, TimeUnit.DAYS, null, null);
    sut.requestTimeout(null, sagaId, 2, TimeUnit.DAYS, null, null);

    // when
    sut.cancelTimeouts(sagaId);

    // then
}

From source file:logicProteinHypernetwork.analysis.complexes.SPINComplexPrediction.java

/**
 * Refine plain network based predicted complexes based on the protein 
 * hypernetwork with a certain ComplexRefinement instance.
 * /* w  w w .j  a  v  a  2s. c o m*/
 * @param naiveComplexes the plain network based complexes
 * @param complexRefinement the instance of ComplexRefinement
 */
protected void refinement(final Collection<Complex> naiveComplexes,
        final SPINComplexRefinement complexRefinement) {

    ThreadPoolExecutor threads = (ThreadPoolExecutor) Executors.newFixedThreadPool(threadCount);

    for (final Complex c : naiveComplexes) {
        threads.submit(new RefineComplex(c, complexRefinement));
    }

    threads.shutdown();
    try {
        threads.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS);
    } catch (InterruptedException ex) {
        System.err.println(ex);
    }

    Set<Complex> unique = new HashSet<Complex>(complexes);
    complexes.clear();
    complexes.addAll(unique);

    //System.out.println("Refined to " + complexes.size() + " complexes");
}

From source file:org.apache.falcon.expression.ExpressionHelper.java

public static long days(int val) {
    return TimeUnit.DAYS.toMillis(val);
}

From source file:tools.descartes.wcf.management.timeSeries.TimeSeries.java

private TimeUnit getBiggerTimeUnit(TimeUnit timeUnit) {
    TimeUnit higherUnit = null;//w w w  . j  a  va  2s  . c om
    switch (timeUnit) {
    case NANOSECONDS:
        higherUnit = TimeUnit.MICROSECONDS;
        break;
    case MICROSECONDS:
        higherUnit = TimeUnit.MILLISECONDS;
        break;
    case MILLISECONDS:
        higherUnit = TimeUnit.SECONDS;
        break;
    case SECONDS:
        higherUnit = TimeUnit.MINUTES;
        break;
    case MINUTES:
        higherUnit = TimeUnit.HOURS;
        break;
    case HOURS:
        higherUnit = TimeUnit.DAYS;
        break;
    default:
        break;
    }
    return higherUnit;
}