Example usage for java.util.concurrent TimeUnit HOURS

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

Introduction

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

Prototype

TimeUnit HOURS

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

Click Source Link

Document

Time unit representing sixty minutes.

Usage

From source file:com.esri.geoevent.test.performance.report.AbstractFileRollOverReportWriter.java

protected String formatTime(final long timeInMillisec) {
    final long hr = TimeUnit.MILLISECONDS.toHours(timeInMillisec);
    final long min = TimeUnit.MILLISECONDS.toMinutes(timeInMillisec - TimeUnit.HOURS.toMillis(hr));
    final long sec = TimeUnit.MILLISECONDS
            .toSeconds(timeInMillisec - TimeUnit.HOURS.toMillis(hr) - TimeUnit.MINUTES.toMillis(min));
    final long ms = TimeUnit.MILLISECONDS.toMillis(timeInMillisec - TimeUnit.HOURS.toMillis(hr)
            - TimeUnit.MINUTES.toMillis(min) - TimeUnit.SECONDS.toMillis(sec));
    if (hr > 0) {
        return String.format("%02d:%02d:%02d.%03d", hr, min, sec, ms);
    } else {//from   w  w w  .j a  v a2 s  .  com
        return String.format("%02d:%02d.%03d", min, sec, ms);
    }
}

From source file:org.eclipse.gyrex.p2.internal.installer.PackageScanner.java

/**
 * Creates a new instance.//from w  w  w  .j av  a 2 s.  c  o  m
 */
PackageScanner() {
    super("Software Package Scanner");
    initialSleepTime = Math.max(
            Long.getLong("gyrex.p2.packageScanner.initialSleepTime", DEFAULT_INITIAL_SLEEP_TIME),
            TimeUnit.SECONDS.toMillis(15));
    maxSleepTime = Math.min(Long.getLong("gyrex.p2.packageScanner.maxSleepTime", DEFAULT_MAX_SLEEP_TIME),
            TimeUnit.HOURS.toMillis(48));
    setSystem(true);
    setPriority(LONG);
    setRule(new MutexRule(PackageScanner.class));
}

From source file:org.apache.nutch.service.NutchServer.java

private NutchServer() {
    configManager = new ConfManagerImpl();
    seedManager = new SeedManagerImpl();
    BlockingQueue<Runnable> runnables = Queues.newArrayBlockingQueue(JOB_CAPACITY);
    NutchServerPoolExecutor executor = new NutchServerPoolExecutor(10, JOB_CAPACITY, 1, TimeUnit.HOURS,
            runnables);//ww  w  .j  a v a  2  s .c om
    jobManager = new JobManagerImpl(new JobFactory(), configManager, executor);
    fetchNodeDb = FetchNodeDb.getInstance();

    sf = new JAXRSServerFactoryBean();
    BindingFactoryManager manager = sf.getBus().getExtension(BindingFactoryManager.class);
    JAXRSBindingFactory factory = new JAXRSBindingFactory();
    factory.setBus(sf.getBus());
    manager.registerBindingFactory(JAXRSBindingFactory.JAXRS_BINDING_ID, factory);
    sf.setResourceClasses(getClasses());
    sf.setResourceProviders(getResourceProviders());
    sf.setProvider(new JacksonJaxbJsonProvider());

}

From source file:com.adaptris.core.transform.XmlSchemaValidator.java

public XmlSchemaValidator() {
    setSchemaCache(new CacheConnection(new ExpiringMapCache()
            .withExpiration(new TimeInterval(2L, TimeUnit.HOURS)).withMaxEntries(DEFAULT_CACHE_SIZE)));
}

From source file:DIA_Umpire_To_Skyline.FileThread.java

public void GenerateSkylineFiles() {
    try {/*from  ww  w  .  j a  va2  s.  co  m*/
        long time = System.currentTimeMillis();

        DIAPack DiaFile = new DIAPack(mzXMLFile, NoCPUs);
        if (!new File(FilenameUtils.getFullPath(DiaFile.Filename) + DiaFile.GetQ1Name() + ".mzXML").exists()
                | !new File(FilenameUtils.getFullPath(DiaFile.Filename) + DiaFile.GetQ2Name() + ".mzXML")
                        .exists()
                | !new File(FilenameUtils.getFullPath(DiaFile.Filename) + DiaFile.GetQ3Name() + ".mzXML")
                        .exists()) {
            throw new RuntimeException();
        }
        Logger.getRootLogger().info(
                "=================================================================================================");
        Logger.getRootLogger().info("Processing " + mzXMLFile);

        if (!DiaFile.RawMGFExist()) {
            if (!DiaFile.LoadDIASetting()) {
                Logger.getRootLogger().info("Loading DIA setting failed, job is incomplete");
                System.exit(1);
            }
            if (!DiaFile.LoadParams()) {
                Logger.getRootLogger().info("Loading parameters failed, job is incomplete");
                System.exit(1);
            }
            DiaFile.BuildStructure();
            if (!DiaFile.MS1FeatureMap.ReadPeakCluster()) {
                Logger.getRootLogger().info("Loading peak and structure failed, job is incomplete");
                System.exit(1);
            }
            DiaFile.CreateSkylingImportFolder();
            DiaFile.GenerateRawMGF();
            DiaFile.ClearStructure();
        }

        DiaFile.ConvertRawMGF(msconvertpath);
        ChangeScanTitlePepXML();
        DiaFile = null;
        System.gc();
        time = System.currentTimeMillis() - time;
        Logger.getRootLogger()
                .info(mzXMLFile + " processed time:"
                        + String.format("%d hour, %d min, %d sec", TimeUnit.MILLISECONDS.toHours(time),
                                TimeUnit.MILLISECONDS.toMinutes(time)
                                        - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(time)),
                                TimeUnit.MILLISECONDS.toSeconds(time)
                                        - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(time))));
    } catch (Exception ex) {
        Logger.getRootLogger().error(ExceptionUtils.getStackTrace(ex));
    }
}

From source file:org.apache.kylin.common.util.BasicTest.java

@Test
public void test0() throws Exception {

    ExecutorService executorService = Executors.newCachedThreadPool();
    List<Future<?>> futures = Lists.newArrayList();

    futures.add(executorService.submit(new Runnable() {
        @Override/*  www  .  j a v  a2s . c o  m*/
        public void run() {
            throw new RuntimeException("hi");
        }
    }));

    futures.add(executorService.submit(new Runnable() {
        @Override
        public void run() {
            try {
                Thread.sleep(2000);
                System.out.println("finish 1");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }));

    try {
        for (Future<?> future : futures) {
            future.get(1, TimeUnit.HOURS);
        }
    } catch (InterruptedException | ExecutionException | TimeoutException e) {
        System.out.println(e.getMessage());
    }

    futures.clear();

    futures.add(executorService.submit(new Runnable() {
        @Override
        public void run() {
            try {
                Thread.sleep(3000);
                System.out.println("finish 2");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }));

    try {
        for (Future<?> future : futures) {
            future.get(1, TimeUnit.HOURS);
        }
    } catch (InterruptedException | ExecutionException | TimeoutException e) {
        System.out.println(e.getMessage());
    }
}

From source file:ezbake.security.service.sync.EncryptedRedisCache.java

@Inject
public EncryptedRedisCache(EzConfiguration ezConfiguration, JedisPool redis, LocksmithKeySupplier keyProvider,
        CuratorFramework curator) {/*www. j  a v  a  2s  . c  om*/
    this.jedisPool = redis;
    this.lock = new InterProcessReadWriteLock(curator, ZK_LOCK_NODE);
    this.curator = curator;

    // Connect to curator (if not connected)
    if (curator.getState() != CuratorFrameworkState.STARTED) {
        curator.start();
    }

    // Register a connection state listener
    curator.getConnectionStateListenable().addListener(new ConnectionStateListener() {
        @Override
        public void stateChanged(CuratorFramework curatorFramework, ConnectionState connectionState) {
            setConnectionState(connectionState);
        }
    });

    redisDbIndex = new RedisConfigurationHelper(ezConfiguration.getProperties()).getRedisDb(REDIS_DB_DEFAULT);

    locksmithKeySupplier = CacheBuilder.newBuilder().maximumSize(1).refreshAfterWrite(1, TimeUnit.HOURS)
            .build(new LocksmithKeyCacheLoader<Integer>(keyProvider));
}

From source file:sagan.projects.support.BadgeController.java

/**
 * Creates a SVG badge for a project with a given {@link ReleaseStatus}.
 *
 * @param projectId/*from w  w w  . ja v a2  s .c  o m*/
 * @param releaseStatus
 * @return
 * @throws IOException
 */
private ResponseEntity<byte[]> badgeFor(String projectId, ReleaseStatus releaseStatus) throws IOException {

    Project project = service.getProject(projectId);

    if (project == null) {
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }

    Optional<ProjectRelease> gaRelease = getRelease(project.getProjectReleases(),
            projectRelease -> projectRelease.getReleaseStatus() == releaseStatus);

    if (!gaRelease.isPresent()) {
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }

    byte[] svgBadge = versionBadgeService.createSvgBadge(project, gaRelease.get());
    return ResponseEntity.ok().eTag(gaRelease.get().getVersion())
            .cacheControl(CacheControl.maxAge(1L, TimeUnit.HOURS)).body(svgBadge);
}

From source file:com.frostwire.android.tests.vuze.VuzeDownloadTest.java

@LargeTest
public void testDownload1() throws IOException, TOTorrentException {

    HttpClient c = HttpClientFactory.newInstance();

    File torrentFile = new File(SystemUtils.getTorrentsDirectory(), "download_test1.torrent");
    File saveDir = SystemUtils.getTorrentDataDirectory();
    c.save(TorrentUrls.FROSTCLICK_BRANDON_HINES_2010, torrentFile);

    TOTorrent t = readTorrent(torrentFile.getAbsolutePath());

    VuzeUtils.remove(t.getHash(), true);
    TestUtils.sleep(10000);//from  w w w .  j  a va  2s. c om

    final CountDownLatch signal = new CountDownLatch(1);

    VuzeDownloadManager dm = VuzeDownloadFactory.create(torrentFile.getAbsolutePath(), null,
            saveDir.getAbsolutePath(), new VuzeDownloadListener() {

                @Override
                public void stateChanged(VuzeDownloadManager dm, int state) {
                    LOG.info("testDownload1-stateChanged:" + formatDownloadState(state));
                }

                @Override
                public void downloadComplete(VuzeDownloadManager dm) {
                    signal.countDown();
                }
            });

    assertNotNull(dm);

    assertTrue("Download not finished", TestUtils.await(signal, 1, TimeUnit.HOURS));
}