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:org.whispersystems.textsecuregcm.storage.Device.java
public boolean isActive() { boolean hasChannel = fetchesMessages || !Util.isEmpty(getApnId()) || !Util.isEmpty(getGcmId()); return (id == MASTER_ID && hasChannel && signedPreKey != null) || (id != MASTER_ID && hasChannel && signedPreKey != null && lastSeen > (System.currentTimeMillis() - TimeUnit.DAYS.toMillis(30))); }
From source file:com.linkedin.pinot.broker.routing.TimeBoundaryServiceTest.java
private void addingSegmentsToPropertyStore(int numSegments, String tableName) { for (int i = 0; i < numSegments; ++i) { OfflineSegmentZKMetadata offlineSegmentZKMetadata = new OfflineSegmentZKMetadata(); offlineSegmentZKMetadata.setSegmentName(tableName + "_" + System.currentTimeMillis() + "_" + i); offlineSegmentZKMetadata.setTableName(tableName); offlineSegmentZKMetadata.setStartTime(i - 1); offlineSegmentZKMetadata.setEndTime(i); offlineSegmentZKMetadata.setTimeUnit(TimeUnit.DAYS); offlineSegmentZKMetadata.setCrc(-1); offlineSegmentZKMetadata.setCreationTime(-1); offlineSegmentZKMetadata.setIndexVersion("0"); offlineSegmentZKMetadata.setPushTime(i + 5); offlineSegmentZKMetadata.setSegmentType(SegmentType.OFFLINE); ZKMetadataProvider.setOfflineSegmentZKMetadata(_propertyStore, offlineSegmentZKMetadata); }/* w ww. ja v a2 s .co m*/ }
From source file:org.apps8os.motivator.ui.CheckEventsActivity.java
/** * Sets up the listeners for the buttons. *///from ww w . j a v a2s. c o m private void setButtons() { final Button nextButton = (Button) findViewById(R.id.questions_next_button); nextButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mViewPager.setCurrentItem(mViewPager.getCurrentItem() + 1); } }); final Button previousButton = (Button) findViewById(R.id.questions_previous_button); previousButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mViewPager.setCurrentItem(mViewPager.getCurrentItem() - 1); } }); final Context context = this; mCompleteButton = (Button) findViewById(R.id.questions_complete_button); mCompleteButton.setEnabled(false); if (mEventsPagerAdapter.getCount() == 1) { nextButton.setEnabled(false); nextButton.setVisibility(View.GONE); previousButton.setVisibility(View.GONE); mCompleteButton.setEnabled(true); } mCompleteButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { final int count = mEventsPagerAdapter.getCount(); int checkedDrinksAmount = 0; final DayDataHandler dayHandler = new DayDataHandler(context); final int clickedDrinks = dayHandler.getClickedDrinksForDay( System.currentTimeMillis() - TimeUnit.MILLISECONDS.convert(1, TimeUnit.DAYS)); for (int i = 0; i < count; i++) { int[] answers = mEventsPagerAdapter.getFragment(i).getAnswers(); checkedDrinksAmount += answers[0]; mEventDataHandler.insertCheckedEvent(mEvents.get(i).getId(), answers[0] + 1, answers[1], answers[2], answers[3], mEvents.get(i).getName()); } final int checkedDrinks = checkedDrinksAmount; // If the user is confirming lower amount of drinks than he clicked on the previous day, confirm the amount with a dialog if (checkedDrinksAmount < clickedDrinks) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle("Suunnitelmissasi on vhemmn juomia kuin klikkasit eilen.") .setMessage("Eilen klikatut: " + clickedDrinks + " \r\n" + "Tarkistetut suunnitelmat: " + checkedDrinksAmount + " \r\n \r\n" + "Paljon joit eilen yhteens?") .setPositiveButton("" + checkedDrinksAmount, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dayHandler.insertDailyDrinkAmount(checkedDrinks, System.currentTimeMillis() - TimeUnit.MILLISECONDS.convert(1, TimeUnit.DAYS)); eventsChecked(); } }).setNegativeButton("" + clickedDrinks, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dayHandler.insertDailyDrinkAmount(clickedDrinks, System.currentTimeMillis() - TimeUnit.MILLISECONDS.convert(1, TimeUnit.DAYS)); eventsChecked(); } }); Dialog dialog = builder.create(); dialog.show(); } else { dayHandler.insertDailyDrinkAmount(checkedDrinks, System.currentTimeMillis() - TimeUnit.MILLISECONDS.convert(1, TimeUnit.DAYS)); eventsChecked(); } } }); // Disable these buttons at start. previousButton.setEnabled(false); LinePageIndicator titleIndicator = (LinePageIndicator) findViewById(R.id.indicator); titleIndicator.setSelectedColor(getResources().getColor(R.color.actionbar_orange)); titleIndicator.setViewPager(mViewPager); // Set up a page change listener to enable and disable buttons. titleIndicator.setOnPageChangeListener(new OnPageChangeListener() { @Override public void onPageScrollStateChanged(int arg0) { } @Override public void onPageScrolled(int arg0, float arg1, int arg2) { } @Override public void onPageSelected(int arg0) { if (arg0 == mEventsPagerAdapter.getCount() - 1) { nextButton.setEnabled(false); mCompleteButton.setEnabled(true); } else { nextButton.setEnabled(true); } if (arg0 == 0) { previousButton.setEnabled(false); } else { previousButton.setEnabled(true); } } }); }
From source file:com.linkedin.pinot.server.integration.IntegrationTest.java
private void setupSegmentList() throws Exception { final URL resource = getClass().getClassLoader().getResource(SMALL_AVRO_DATA); final String filePath = TestUtils.getFileFromResourceUrl(resource); _indexSegmentList.clear();/*from w w w. j a v a 2 s . co m*/ if (INDEXES_DIR.exists()) { FileUtils.deleteQuietly(INDEXES_DIR); } INDEXES_DIR.mkdir(); for (int i = 0; i < 2; ++i) { final File segmentDir = new File(INDEXES_DIR, "segment_" + i); final SegmentGeneratorConfig config = SegmentTestUtils.getSegmentGenSpecWithSchemAndProjectedColumns( new File(filePath), segmentDir, "dim" + i, TimeUnit.DAYS, "testTable"); final SegmentIndexCreationDriver driver = SegmentCreationDriverFactory.get(null); driver.init(config); driver.build(); _indexSegmentList.add(ColumnarSegmentLoader.load( new File(new File(INDEXES_DIR, "segment_" + String.valueOf(i)), driver.getSegmentName()), ReadMode.mmap)); System.out.println("built at : " + segmentDir.getAbsolutePath()); } }
From source file:com.freshdigitable.udonroad.StatusViewBase.java
private String createTimeString(Date createdAtDate) { final long deltaInSec = TimeUnit.MILLISECONDS .toSeconds(System.currentTimeMillis() - createdAtDate.getTime()); if (deltaInSec <= TimeUnit.SECONDS.toSeconds(1)) { return getContext().getString(R.string.created_now); }//www.j a v a2 s. c om if (deltaInSec < TimeUnit.SECONDS.toSeconds(60)) { return getContext().getString(R.string.created_seconds_ago, TimeUnit.SECONDS.toSeconds(deltaInSec)); } if (deltaInSec <= TimeUnit.MINUTES.toSeconds(1)) { return getContext().getString(R.string.created_a_minute_ago); } if (deltaInSec < TimeUnit.MINUTES.toSeconds(45)) { return getContext().getString(R.string.created_minutes_ago, TimeUnit.SECONDS.toMinutes(deltaInSec)); } if (deltaInSec < TimeUnit.MINUTES.toSeconds(105)) { return getContext().getString(R.string.created_a_hour_ago); } if (deltaInSec < TimeUnit.DAYS.toSeconds(1)) { long hours = deltaInSec + TimeUnit.MINUTES.toSeconds(15); return getContext().getString(R.string.created_hours_ago, TimeUnit.SECONDS.toHours(hours)); } return timeSpanConv.toTimeSpanString(createdAtDate); }
From source file:com.netflix.simianarmy.basic.chaos.BasicChaosMonkey.java
/** * Instantiates a new basic chaos monkey. * @param ctx//w ww. j a va 2 s . c o m * the ctx */ public BasicChaosMonkey(ChaosMonkey.Context ctx) { super(ctx); this.cfg = ctx.configuration(); this.monkeyCalendar = ctx.calendar(); Calendar open = monkeyCalendar.now(); Calendar close = monkeyCalendar.now(); open.set(Calendar.HOUR, monkeyCalendar.openHour()); close.set(Calendar.HOUR, monkeyCalendar.closeHour()); allChaosTypes = Lists.newArrayList(); allChaosTypes.add(new ShutdownInstanceChaosType(cfg)); allChaosTypes.add(new BlockAllNetworkTrafficChaosType(cfg)); allChaosTypes.add(new DetachVolumesChaosType(cfg)); allChaosTypes.add(new BurnCpuChaosType(cfg)); allChaosTypes.add(new BurnIoChaosType(cfg)); allChaosTypes.add(new KillProcessesChaosType(cfg)); allChaosTypes.add(new NullRouteChaosType(cfg)); allChaosTypes.add(new FailEc2ChaosType(cfg)); allChaosTypes.add(new FailDnsChaosType(cfg)); allChaosTypes.add(new FailDynamoDbChaosType(cfg)); allChaosTypes.add(new FailS3ChaosType(cfg)); allChaosTypes.add(new FillDiskChaosType(cfg)); allChaosTypes.add(new NetworkCorruptionChaosType(cfg)); allChaosTypes.add(new NetworkLatencyChaosType(cfg)); allChaosTypes.add(new NetworkLossChaosType(cfg)); TimeUnit freqUnit = ctx.scheduler().frequencyUnit(); if (TimeUnit.DAYS == freqUnit) { runsPerDay = ctx.scheduler().frequency(); } else { long units = freqUnit.convert(close.getTimeInMillis() - open.getTimeInMillis(), TimeUnit.MILLISECONDS); runsPerDay = units / ctx.scheduler().frequency(); } }
From source file:org.fim.internal.StateGenerator.java
private void waitAllFilesToBeHashed() { try {//from w ww. j a va 2s .com executorService.shutdown(); executorService.awaitTermination(3, TimeUnit.DAYS); } catch (InterruptedException ex) { Logger.error("Exception while waiting for files to be hashed", ex, context.isDisplayStackTrace()); } }
From source file:com.linkedin.pinot.transport.common.TimeBoundaryServiceTest.java
private void addingSegmentsToPropertyStore(int numSegments, ZkHelixPropertyStore<ZNRecord> propertyStore, String tableName) {// w w w .j a v a 2s. co m for (int i = 0; i < numSegments; ++i) { OfflineSegmentZKMetadata offlineSegmentZKMetadata = new OfflineSegmentZKMetadata(); offlineSegmentZKMetadata.setSegmentName(tableName + "_" + System.currentTimeMillis() + "_" + i); offlineSegmentZKMetadata.setTimeUnit(TimeUnit.DAYS); offlineSegmentZKMetadata.setEndTime(i); offlineSegmentZKMetadata.setCrc(-1); offlineSegmentZKMetadata.setCreationTime(-1); offlineSegmentZKMetadata.setStartTime(i - 1); offlineSegmentZKMetadata.setIndexVersion("0"); offlineSegmentZKMetadata.setPushTime(i + 5); offlineSegmentZKMetadata.setTableName(tableName); offlineSegmentZKMetadata.setSegmentType(SegmentType.OFFLINE); ZKMetadataProvider.setOfflineSegmentZKMetadata(_propertyStore, offlineSegmentZKMetadata); } }
From source file:com.dalamar.model.LateTrainDaoImpl.java
private Conjunction createDateCriterion(Date d) { d.setHours(0);/*from www .j a v a 2 s .co m*/ d.setMinutes(0); d.setSeconds(0); Date beginDate = d; Date endDate = new Date(beginDate.getTime() + TimeUnit.DAYS.toMillis(1)); Conjunction andOperator = Restrictions.conjunction(); andOperator.add(Restrictions.ge("dateCaptured", beginDate)); andOperator.add(Restrictions.lt("dateCaptured", endDate)); return andOperator; }
From source file:com.linkedin.pinot.query.selection.SelectionOnlyQueriesTest.java
private void setupSegment() throws Exception { final String filePath = TestUtils .getFileFromResourceUrl(getClass().getClassLoader().getResource(AVRO_DATA)); if (INDEX_DIR.exists()) { FileUtils.deleteQuietly(INDEX_DIR); }//ww w .java2 s . c om 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(); System.out.println("built at : " + INDEX_DIR.getAbsolutePath()); final File indexSegmentDir = new File(INDEX_DIR, driver.getSegmentName()); _indexSegment = ColumnarSegmentLoader.load(indexSegmentDir, ReadMode.heap); _medataMap = ((SegmentMetadataImpl) ((IndexSegmentImpl) _indexSegment).getSegmentMetadata()) .getColumnMetadataMap(); }