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.query.aggregation.AggregationGroupByOperatorTest.java
private void setupSegment() throws Exception { final String filePath = TestUtils .getFileFromResourceUrl(getClass().getClassLoader().getResource(AVRO_DATA)); if (INDEX_DIR.exists()) { FileUtils.deleteQuietly(INDEX_DIR); }//from w ww . j a va2s. com final SegmentGeneratorConfig config = SegmentTestUtils.getSegmentGenSpecWithSchemAndProjectedColumns( new File(filePath), INDEX_DIR, "time_day", 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:org.apache.flume.sink.elasticsearch.TestElasticSearchSink.java
@Test public void shouldParseConfiguration() { parameters.put(HOSTNAMES, "10.5.5.27"); parameters.put(CLUSTER_NAME, "testing-cluster-name"); parameters.put(INDEX_NAME, "testing-index-name"); parameters.put(INDEX_TYPE, "testing-index-type"); parameters.put(TTL, "10"); fixture = new ElasticSearchSink(); fixture.configure(new Context(parameters)); InetSocketTransportAddress[] expected = { new InetSocketTransportAddress("10.5.5.27", DEFAULT_PORT) }; assertEquals("testing-cluster-name", fixture.getClusterName()); assertEquals("testing-index-name", fixture.getIndexName()); assertEquals("testing-index-type", fixture.getIndexType()); assertEquals(TimeUnit.DAYS.toMillis(10), fixture.getTTLMs()); assertArrayEquals(expected, fixture.getServerAddresses()); }
From source file:de.rub.syssec.saaf.Headless.java
/** * Analyze one or multiple APKs. Depending on the configuration this may * happen single- or multithreaded.//from ww w. java2 s . com * * @param apks the apks to analyze */ private static void performAnalysis(LinkedList<File> apks) { // Initialize MultiThreading and queue int corePoolSize = Runtime.getRuntime().availableProcessors(); if (corePoolSize > 1) corePoolSize--; int numThreads = CONFIG.getIntConfigValue(ConfigKeys.MULTITHREADING_THREADS, corePoolSize); if (!CONFIG.getBooleanConfigValue(ConfigKeys.MULTITHREADING_ENABLED)) { // multithreading is disabled numThreads = 1; } // Create executor and submit jobs SAAFThreadPoolExecutor executor = new SAAFThreadPoolExecutor(apks, numThreads, numThreads, 5, TimeUnit.SECONDS); executor.allowCoreThreadTimeOut(true); // Tell the executor to shutdown afterwards executor.shutdown(); boolean b = true; try { b = executor.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS); // timeout should not occur } catch (InterruptedException e) { LOGGER.error("Got interrupted while waiting for analyses to finish, this should not happen.", e); } if (!b) { LOGGER.error("Got a timeout while waiting for analyses to finish, this should not happen."); } executor.printStatistic(); }
From source file:com.cloud.agent.Agent.java
public Agent(final IAgentShell shell) { _shell = shell;/* w ww .jav a 2 s. c o m*/ _link = null; _connection = new NioClient("Agent", _shell.getHost(), _shell.getPort(), _shell.getWorkers(), this); Runtime.getRuntime().addShutdownHook(new ShutdownThread(this)); _ugentTaskPool = new ThreadPoolExecutor(shell.getPingRetries(), 2 * shell.getPingRetries(), 10, TimeUnit.MINUTES, new SynchronousQueue<Runnable>(), new NamedThreadFactory("UgentTask")); _executor = new ThreadPoolExecutor(_shell.getWorkers(), 5 * _shell.getWorkers(), 1, TimeUnit.DAYS, new LinkedBlockingQueue<Runnable>(), new NamedThreadFactory("agentRequest-Handler")); }
From source file:com.linkedin.pinot.query.selection.SelectionOnlyQueriesTest.java
private void setupSegmentList(int numberOfSegments) throws Exception { final String filePath = TestUtils .getFileFromResourceUrl(getClass().getClassLoader().getResource(AVRO_DATA)); if (INDEXES_DIR.exists()) { FileUtils.deleteQuietly(INDEXES_DIR); }//from w ww . j a va 2 s .c om INDEXES_DIR.mkdir(); for (int i = 0; i < numberOfSegments; ++i) { final File segmentDir = new File(INDEXES_DIR, "segment_" + i); final SegmentGeneratorConfig config = SegmentTestUtils.getSegmentGenSpecWithSchemAndProjectedColumns( new File(filePath), segmentDir, "time_day", TimeUnit.DAYS, "test"); final SegmentIndexCreationDriver driver = SegmentCreationDriverFactory.get(null); driver.init(config); driver.build(); System.out.println("built at : " + segmentDir.getAbsolutePath()); _indexSegmentList.add(new OfflineSegmentDataManager( ColumnarSegmentLoader.load(new File(segmentDir, driver.getSegmentName()), ReadMode.heap))); } }
From source file:org.dcache.util.histograms.HistogramModelTest.java
@Test public void buildShouldFailWhenNoCountGivenToCounting() throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException { givenCountingHistogram();// w w w . j a v a 2s. c om givenFilelifetimeValuesFor(150); givenBinUnitOf((double) TimeUnit.DAYS.toMillis(1)); givenBinLabelOf(TimeUnit.DAYS.name()); givenDataLabelOf("COUNT"); givenHistogramTypeOf("File Lifetime Count"); whenConfigureIsCalled(); assertThatBuildFailed(); }
From source file:org.apache.nifi.toolkit.tls.util.TlsHelperTest.java
private Date inFuture(int days) { return new Date(System.currentTimeMillis() + TimeUnit.DAYS.toMillis(days)); }
From source file:org.eclipse.gyrex.jobs.internal.storage.CloudPreferencesCleanupJob.java
public void setMaxDaysSinceLastRun(final int maxDaysSinceLastRun) { if (maxDaysSinceLastRun > 0) { maxAge = TimeUnit.DAYS.toMillis(maxDaysSinceLastRun); } else {//from www . j a v a 2s . co m maxAge = Long.MAX_VALUE; } }
From source file:org.apps8os.motivator.services.NotificationService.java
@Override protected void onHandleIntent(Intent intent) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); if (prefs.getBoolean(SettingsActivity.KEY_SEND_NOTIFICATIONS, true)) { // Set up the notification with a builder NotificationCompat.Builder builder = new NotificationCompat.Builder(this); NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); Bundle extras = intent.getExtras(); // Check the notification type. int notificationType = extras.getInt(NOTIFICATION_TYPE); if (notificationType == NOTIFICATION_MOOD) { // Cancel all previous notifications. manager.cancelAll();/*from w w w.ja v a2s .co m*/ SprintDataHandler dataHandler = new SprintDataHandler(this); Sprint currentSprint = dataHandler.getCurrentSprint(); AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); // If there is no current sprint, cancel alarms. if (currentSprint == null) { Sprint latestEndedSprint = dataHandler.getLatestEndedSprint(); if (latestEndedSprint != null) { if (latestEndedSprint.endedYesterday()) { builder.setContentTitle(getString(R.string.completed_sprint)); builder.setSmallIcon(R.drawable.ic_stat_notification_icon_1); builder.setAutoCancel(true); Intent resultIntent = new Intent(this, MainActivity.class); TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); stackBuilder.addParentStack(MainActivity.class); stackBuilder.addNextIntent(resultIntent); PendingIntent pendingResultIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_CANCEL_CURRENT); builder.setContentIntent(pendingResultIntent); manager.notify(NOTIFICATION_ID_SPRINT_ENDED, builder.build()); } } Intent notificationIntent = new Intent(this, NotificationService.class); PendingIntent pendingNotificationIntent = PendingIntent.getService(this, 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT); alarmManager.cancel(pendingNotificationIntent); } else { builder.setContentTitle(getString(R.string.today_screen_mood)); int currentDateInSprint = currentSprint.getCurrentDayOfTheSprint(); builder.setSmallIcon(R.drawable.ic_stat_notification_icon_1); // Remove the notification when the user clicks it. builder.setAutoCancel(true); // Where to go when user clicks the notification Intent resultIntent = new Intent(this, MoodQuestionActivity.class); DayDataHandler moodDataHandler = new DayDataHandler(this); // Check if there were events yesterday. DayInHistory yesterday = moodDataHandler.getDayInHistory( System.currentTimeMillis() - TimeUnit.MILLISECONDS.convert(1, TimeUnit.DAYS)); yesterday.setEvents(); ArrayList<MotivatorEvent> yesterdayEvents = yesterday.getUncheckedEvents(this); if (!yesterdayEvents.isEmpty()) { // Put the events as extras to the intent so that we can pass them to the checking activity. resultIntent.putExtra(MotivatorEvent.YESTERDAYS_EVENTS, yesterdayEvents); resultIntent.putExtra(EventDataHandler.EVENTS_TO_CHECK, true); builder.setContentText(getString(R.string.you_had_an_event_yesterday)); } else { // No events to check. resultIntent.putExtra(EventDataHandler.EVENTS_TO_CHECK, false); EventDataHandler eventHandler = new EventDataHandler(this); long lastAddedEventTimestamp = eventHandler.getLatestAddedEventTimestamp(); if (lastAddedEventTimestamp != 0L && System.currentTimeMillis() - lastAddedEventTimestamp > TimeUnit.MILLISECONDS.convert(7, TimeUnit.DAYS)) { builder.setContentText(getString(R.string.plan_reminder)); } else { builder.setContentText(getString(R.string.today_is_the_day) + " " + currentDateInSprint + "/" + currentSprint.getDaysInSprint() + " - " + currentSprint.getSprintTitle()); } } // Preserve the normal navigation of the app by adding the parent stack of the result activity TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); stackBuilder.addParentStack(MoodQuestionActivity.class); stackBuilder.addNextIntent(resultIntent); PendingIntent pendingResultIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_CANCEL_CURRENT); builder.setContentIntent(pendingResultIntent); manager.notify(NOTIFICATION_ID_MOOD, builder.build()); } } else if (notificationType == NOTIFICATION_EVENT_START) { // Set up a notification for the start of an event. int eventId = extras.getInt(EventDataHandler.EVENT_ID); String eventName = extras.getString(EventDataHandler.EVENT_NAME); builder.setContentTitle(getString(R.string.you_have_an_event_starting)); builder.setContentText(eventName); builder.setSmallIcon(R.drawable.ic_stat_notification_icon_1); // Remove the notification when the user clicks it. builder.setAutoCancel(true); Intent resultIntent = new Intent(this, EventDetailsActivity.class); resultIntent.putExtra(EventDataHandler.EVENT_ID, eventId); TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); stackBuilder.addParentStack(EventDetailsActivity.class); stackBuilder.addNextIntent(resultIntent); PendingIntent pendingResultIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); builder.setContentIntent(pendingResultIntent); manager.notify(eventId, builder.build()); } else if (notificationType == NOTIFICATION_EVENT_END) { // Set up a notification for the start of an event. int eventId = extras.getInt(EventDataHandler.EVENT_ID); builder.setContentTitle(getString(R.string.event_ending)); builder.setContentText(getString(R.string.go_home)); builder.setSmallIcon(R.drawable.ic_stat_notification_icon_1); // Remove the notification when the user clicks it. builder.setAutoCancel(true); Intent resultIntent = new Intent(this, EventDetailsActivity.class); resultIntent.putExtra(EventDataHandler.EVENT_ID, eventId); TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); stackBuilder.addParentStack(EventDetailsActivity.class); stackBuilder.addNextIntent(resultIntent); PendingIntent pendingResultIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); builder.setContentIntent(pendingResultIntent); manager.notify(eventId + 10000, builder.build()); } } }
From source file:com.netflix.spinnaker.igor.gitlabci.GitlabCiBuildMonitor.java
private List<Pipeline> filterOldPipelines(List<Pipeline> pipelines) { final Long threshold = new Date().getTime() - TimeUnit.DAYS.toMillis(gitlabCiProperties.getCachedJobTTLDays()); return pipelines.stream().filter( pipeline -> (pipeline.getFinishedAt() != null) && (pipeline.getFinishedAt().getTime() > threshold)) .collect(Collectors.toList()); }