List of usage examples for java.util.concurrent TimeUnit DAYS
TimeUnit DAYS
To view the source code for java.util.concurrent TimeUnit DAYS.
Click Source Link
From source file:com.linkedin.pinot.core.segment.index.creator.SegmentGenerationWithTimeColumnTest.java
private Schema createSchema(boolean isSimpleDate) { Schema schema = new Schema(); schema.addField(new DimensionFieldSpec(STRING_COL_NAME, FieldSpec.DataType.STRING, true)); if (isSimpleDate) { schema.addField(new TimeFieldSpec(TIME_COL_NAME, FieldSpec.DataType.INT, TimeUnit.DAYS)); } else {//from w w w . jav a 2s .com schema.addField(new TimeFieldSpec(TIME_COL_NAME, FieldSpec.DataType.LONG, TimeUnit.MILLISECONDS)); } return schema; }
From source file:cimav.client.data.domain.Incidencia.java
public void ajustar() { // Fecha//from w w w. java 2s .c o m Date fechaInicioQuin = Quincena.get().getFechaInicio(); Date fechaFinQuin = Quincena.get().getFechaFin(); if (this.getTipo().isIncapacidad()) { // la fecha de inicio para Incapacidades tiene que ser mayor o igual al inicio de la quincena //boolean isAntes = this.fechaInicial.compareTo(fechaInicioQuin) < 0; if (this.fechaInicial.before(fechaInicioQuin)) { this.fechaInicial = fechaInicioQuin; } } else if (this.getTipo().isFalta()) { // la falta tiene que estar entre la fecha de inicio y la fecha de fin de la quincena //boolean isBetween = (this.fechaInicial.compareTo(fechaInicioQuin) >= 0) && (this.fechaInicial.compareTo(fechaFinQuin) <= 0); // incluye endpoints boolean isBetween = (this.fechaInicial.equals(fechaInicioQuin) || this.fechaInicial.after(fechaInicioQuin)) && (this.fechaInicial.equals(fechaFinQuin) || this.fechaInicial.before(fechaFinQuin)); if (!isBetween) { // Si no esta, ajustarla a la fecha de inicio this.fechaInicial = Quincena.get().getFechaInicio(); } } else if (this.getTipo().isPermiso()) { } // Dias if (this.getTipo().isIncapacidad()) { if (this.dias > 90) { // Mximo 90 incapacidades this.dias = 90; } Date fechaAux = this.fechaInicial; this.diasHabiles = 0; this.diasInhabiles = 0; while ((fechaFinQuin.after(fechaAux) || fechaFinQuin.equals(fechaAux)) && ((this.diasHabiles + this.diasInhabiles) < this.dias)) { // mientras no revase a la fecha fin // y mientras Habiles + Inhabibles no superen los dias totales DateTimeFormat format = DateTimeFormat.getFormat("c"); // try with "E" pattern also String dayOfWeek = format.format(fechaAux); //0 for sunday if (dayOfWeek.equals("0") || dayOfWeek.equals("6")) { this.diasInhabiles++; } else { this.diasHabiles++; } // avanzar 1 da fechaAux = new Date(fechaAux.getTime() + TimeUnit.DAYS.toMillis(1)); } } else if (this.getTipo().isFalta()) { if (this.dias > 5) { // Mximo 5 faltas this.dias = 5; } if (this.dias > Quincena.get().getDiasOrdinarios()) { // Mximo igual a los ordinarios this.dias = Quincena.get().getDiasOrdinarios(); } // todas la faltas capturadas son sobre dias hbiles; no hay faltas en das inhabiles o de asueto this.diasHabiles = this.dias; // no hay faltas en das de descanso this.diasInhabiles = 0; } else if (this.getTipo().isPermiso()) { // no cuentan como faltas //this.incidencias = 0; } }
From source file:metlos.executors.batch.BatchCpuThrottlingExecutorTest.java
@Test public void maxUsage_MultiThreaded() throws Exception { NamingThreadFactory factory = new NamingThreadFactory(); ThreadPoolExecutor e = new ThreadPoolExecutor(10, 10, 0, TimeUnit.DAYS, new LinkedBlockingQueue<Runnable>(), factory);// w w w. j a v a2 s . co m e.prestartAllCoreThreads(); List<Future<?>> payloadResults = new ArrayList<Future<?>>(); long startTime = System.nanoTime(); //create load for (int i = 0; i < NOF_JOBS; ++i) { Future<?> f = e.submit(new Payload()); payloadResults.add(f); } //wait for it all to finish for (Future<?> f : payloadResults) { f.get(); } long endTime = System.nanoTime(); long time = endTime - startTime; LOG.info("MAX Multithreaded test took " + (time / 1000.0 / 1000.0) + "ms"); ThreadMXBean threadBean = ManagementFactory.getThreadMXBean(); long cpuTime = 0; for (Thread t : factory.createdThreads) { long threadCpuTime = threadBean.getThreadCpuTime(t.getId()); LOG.info(t.getName() + ": " + threadCpuTime + "ns"); cpuTime += threadCpuTime; } float actualUsage = (float) cpuTime / time; LOG.info("MAX Multithreaded overall usage: " + actualUsage); }
From source file:nblair.pipeline.AbstractParallelPipelineStep.java
@Override public final void blockUntilComplete() { this.executorService.shutdown(); try {//from w ww.j a v a2s. c om // no "await indefinitely", 10 DAYS seemingly long enough this.executorService.awaitTermination(10, TimeUnit.DAYS); } catch (InterruptedException e) { throw new IllegalStateException("Interrupted in executorService#awaitTermination in step " + getName(), e); } getNextStep().blockUntilComplete(); }
From source file:org.dcache.util.histograms.CountingHistogramTest.java
@Test public void binUnitShouldBe2ForMaxValue100Days() throws Exception { givenCountingHistogram();/*ww w . j av a 2s . c om*/ givenFilelifetimeValuesFor(100); givenBinCountOf(51); givenBinUnitOf((double) TimeUnit.DAYS.toMillis(1)); givenBinLabelOf(TimeUnit.DAYS.name()); givenDataLabelOf("COUNT"); givenHistogramTypeOf("File Lifetime Count"); whenConfigureIsCalled(); assertThatBuildSucceeded(); assertThatBinWidthIs(2); }
From source file:com.ibm.watson.movieapp.dialog.rest.SearchTheMovieDbProxyResource.java
/** * Loads an internal cache which gets refreshed periodically. We are depending on a third party system (themoviedb.org) so it is possible that their genres * may change over time or the url used to retrieve posters will change. As a result we periodically (for now daily) check to make sure we have the correct * values for these./*from w w w. j a v a2 s . c o m*/ * * @return a cache which looks up certain values in themoviedb.org */ private static LoadingCache<String, String> loadTheMovieDbCache() { return CacheBuilder.newBuilder().initialCapacity(8).expireAfterWrite(1, TimeUnit.DAYS) // refresh once a day .maximumSize(20).concurrencyLevel(5).build(new CacheLoader<String, String>() { private HashMap<String, String> genresAndIds = new HashMap<>(); @Override public String load(String key) throws Exception { if (IMAGE_CACHE_KEY.equals(key)) { // Get the poster path. String imageBaseURL = null; URI uri = buildUriStringFromParamsHash(new Hashtable<String, String>(), CONFIGURATION); JsonObject tmdbResponse = UtilityFunctions.httpGet(createTMDBHttpClient(), uri); if (tmdbResponse.has("images")) { //$NON-NLS-1$ JsonObject images = tmdbResponse.get("images").getAsJsonObject(); //$NON-NLS-1$ imageBaseURL = UtilityFunctions.getPropValue(images, "base_url"); //$NON-NLS-1$ if (images.has("backdrop_sizes")) { //$NON-NLS-1$ JsonArray sizes = images.get("backdrop_sizes").getAsJsonArray(); //$NON-NLS-1$ String size = sizes.get(0).getAsString(); if (size != null) { imageBaseURL += size; } } return imageBaseURL; } } if (key != null && key.startsWith(GENRE_CACHE_PREFIX)) { if (genresAndIds.isEmpty()) { URI uri = buildUriStringFromParamsHash(null, LIST_GENRES); JsonObject tmdbResponse = UtilityFunctions.httpGet(createTMDBHttpClient(), uri); if (tmdbResponse.has("genres")) { //$NON-NLS-1$ JsonArray genres = tmdbResponse.getAsJsonArray("genres"); //$NON-NLS-1$ for (JsonElement element : genres) { JsonObject genre = element.getAsJsonObject(); genresAndIds.put(genre.get("name").getAsString().toLowerCase(), //$NON-NLS-1$ genre.get("id").getAsString()); //$NON-NLS-1$ } } } String ret = genresAndIds.get(key.substring(GENRE_CACHE_PREFIX.length()).toLowerCase()); return ret != null ? ret : ""; //$NON-NLS-1$ } return null; } }); }
From source file:org.kuali.rice.kim.impl.role.RoleInternalServiceImpl.java
@Override public void groupInactivated(String groupId) { if (StringUtils.isBlank(groupId)) { throw new IllegalArgumentException("groupId is null or blank"); }/* w w w. java 2 s .c o m*/ long oneDayInMillis = TimeUnit.DAYS.toMillis(1); Timestamp yesterday = new Timestamp(System.currentTimeMillis() - oneDayInMillis); List<String> groupIds = new ArrayList<String>(); groupIds.add(groupId); inactivatePrincipalGroupMemberships(groupIds, yesterday); inactivateGroupRoleMemberships(groupIds, yesterday); }
From source file:com.asakusafw.operation.tools.hadoop.fs.Clean.java
@Override public int run(String[] args) { if (args == null) { throw new IllegalArgumentException("args must not be null"); //$NON-NLS-1$ }//w w w. j a v a2 s.co m Opts opts; try { opts = parseOptions(args); if (opts == null) { return 2; } } catch (Exception e) { LOG.error(MessageFormat.format("[OT-CLEAN-E00001] Invalid options: {0}", Arrays.toString(args)), e); return 2; } long period = currentTime - (long) (opts.keepDays * TimeUnit.DAYS.toMillis(1)); if (LOG.isDebugEnabled()) { LOG.debug("Keep switching-time: {}", new Date(period)); //$NON-NLS-1$ } Context context = new Context(opts.recursive, period, opts.dryRun); for (Path path : opts.paths) { remove(path, context); } if (context.hasError()) { return 1; } return 0; }
From source file:edu.sdsc.scigraph.owlapi.loader.BatchOwlLoader.java
void loadOntology() throws InterruptedException { if (!ontologies.isEmpty()) { for (int i = 0; i < numConsumers; i++) { //exec.submit(new OwlOntologyConsumer(queue, graph, PRODUCER_COUNT, mappedProperties, numProducersShutdown)); exec.submit(consumerProvider.get()); }// w w w . j a v a 2 s . c o m for (int i = 0; i < numProducers; i++) { //exec.submit(new OwlOntologyProducer(queue, urlQueue, numProducersShutdown)); exec.submit(producerProvider.get()); } for (OntologySetup ontology : ontologies) { urlQueue.offer(ontology); } for (int i = 0; i < numProducers; i++) { urlQueue.offer(POISON_STR); } } exec.shutdown(); exec.awaitTermination(10, TimeUnit.DAYS); graph.shutdown(); logger.info("Postprocessing..."); postprocessorProvider.get().postprocess(); postprocessorProvider.shutdown(); }
From source file:org.eclipse.skalli.core.rest.admin.StatisticsQueryTest.java
@Test public void testToQuery() throws Exception { Calendar cal = Calendar.getInstance(); long now = cal.getTimeInMillis(); long toMillis = now - TimeUnit.MILLISECONDS.convert(1, TimeUnit.DAYS); cal.setTimeInMillis(toMillis);//from ww w .j a v a 2s .c om String toStr = DatatypeConverter.printDateTime(cal); StatisticsQuery query = new StatisticsQuery(getParams(null, toStr, null), now); Assert.assertEquals(0, query.getFrom()); Assert.assertEquals(toMillis, query.getTo()); }