List of usage examples for org.joda.time Duration getMillis
public long getMillis()
From source file:com.brighttag.agathon.dao.zerg.ZergDaoModule.java
License:Apache License
@Provides @Singleton/*from w w w. ja va 2 s . c o m*/ AsyncHttpClientConfig provideAsyncHttpClientConfig( @Named(ZERG_CONNECTION_TIMEOUT_PROPERTY) Duration connectionTimeout, @Named(ZERG_REQUEST_TIMEOUT_PROPERTY) Duration requestTimeout) { PeriodFormatter formatter = PeriodFormat.getDefault(); log.info("Using connection timeout {} and request timeout {}", formatter.print(connectionTimeout.toPeriod()), formatter.print(requestTimeout.toPeriod())); return new AsyncHttpClientConfig.Builder().setAllowPoolingConnection(true) .setConnectionTimeoutInMs(Ints.saturatedCast(connectionTimeout.getMillis())) .setRequestTimeoutInMs(Ints.saturatedCast(requestTimeout.getMillis())).setFollowRedirects(true) .setMaximumNumberOfRedirects(3).setMaxRequestRetry(1).build(); }
From source file:com.cloud.utils.script.Script.java
License:Apache License
public Script(String command, Duration timeout, Logger logger) { this(command, timeout.getMillis(), logger); }
From source file:com.cloud.utils.script.Script.java
License:Apache License
public Script(boolean runWithSudo, String command, Duration timeout, Logger logger) { this(runWithSudo, command, timeout.getMillis(), logger); }
From source file:com.cloud.utils.script.Script.java
License:Apache License
public Script(String command, Duration timeout) { this(command, timeout.getMillis(), s_logger); }
From source file:com.cloud.utils.ssh.SshHelper.java
License:Apache License
public static Pair<Boolean, String> sshExecute(String host, int port, String user, File pemKeyFile, String password, String command, Duration connectTimeout, Duration kexTimeout, Duration waitTime) throws Exception { return sshExecute(host, port, user, pemKeyFile, password, command, (int) connectTimeout.getMillis(), (int) kexTimeout.getMillis(), (int) waitTime.getMillis()); }
From source file:com.cloudera.api.model.ApiImpalaQuery.java
License:Apache License
public ApiImpalaQuery(String queryId, String statement, String queryType, String queryState, Date startTime, Date endTime, Long rowsProduced, Map<String, String> syntheticAttributes, String user, String frontEndHostId, boolean runtimeProfileAvailable, String defaultDatabase, Duration duration) { Preconditions.checkNotNull(queryId); this.queryId = queryId; this.statement = statement; this.queryType = queryType; this.queryState = queryState; this.startTime = startTime; this.endTime = endTime; this.rowsProduced = rowsProduced; this.attributes = syntheticAttributes; this.user = user; coordinator = new ApiHostRef(frontEndHostId); this.detailsAvailable = runtimeProfileAvailable; this.database = defaultDatabase; durationMillis = duration == null ? null : duration.getMillis(); }
From source file:com.cubeia.games.poker.tournament.PokerTournament.java
License:Open Source License
private void scheduleNextBlindsLevel() { Duration levelDuration = Duration .standardMinutes(pokerState.getCurrentBlindsLevel().getDurationInMinutes()); long millisecondsToNextLevel = levelDuration.getMillis(); pokerState.setNextLevelStartTime(dateFetcher.date().plus(levelDuration)); log.debug("Scheduling next blinds level in " + millisecondsToNextLevel + " millis, for tournament " + instance);/*from w ww . j av a2 s . co m*/ instance.getScheduler().scheduleAction( new MttObjectAction(instance.getId(), TournamentTrigger.INCREASE_LEVEL), millisecondsToNextLevel); }
From source file:com.dataartisans.timeoutmonitoring.session.LatencyWindowFunction.java
License:Apache License
@Override public JSONObject apply(JSONObject left, JSONObject right) { JSONObject result = JSONObjectExtractor.createJSONObject(left, resultFields); String firstTimestamp = left.getString("timestamp"); String lastTimestamp = right.getString("timestamp"); DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss.SSSSSS"); DateTime firstDateTime = formatter.parseDateTime(firstTimestamp); DateTime lastDateTime = formatter.parseDateTime(lastTimestamp); Duration diff = new Duration(firstDateTime, lastDateTime); result.put("latency", diff.getMillis() + ""); return result; }
From source file:com.ephemeraldreams.gallyshuttle.ui.MainFragment.java
License:Apache License
/** * Calculate time difference in milliseconds between now and next available shuttle arrival time. * * @param stationId Station id to get times from. * @return Duration between now and next arrival time in milliseconds. */// ww w. ja v a 2 s .c o m private long calculateTimeFromNowToNextArrivalAtStation(int stationId) { List<String> times = schedule.getTimes(stationId); LocalDateTime now = LocalDateTime.now(); arrivalTime = null; LocalDateTime stationTime; for (String time : times) { stationTime = DateUtils.parseToLocalDateTime(time); Timber.d(stationTime.toString()); //Workaround midnight exception case where station time was converted to midnight of current day instead of next day. if (stationTime.getHourOfDay() == 0 && now.getHourOfDay() != 0) { stationTime = stationTime.plusDays(1); } if (now.isBefore(stationTime)) { arrivalTime = stationTime; break; } } if (arrivalTime == null) { arrivalTimeTextView.setText(getString(R.string.arrival_not_available_message)); return -1; } else { arrivalTimeTextView.setText(String.format(getString(R.string.until_arrival_time_message), DateUtils.formatTime(arrivalTime))); Duration duration = new Duration(now.toDateTime(), arrivalTime.toDateTime()); long milliseconds = duration.getMillis(); Timber.d("Now: " + DateUtils.formatTime(now)); Timber.d("Arrival: " + DateUtils.formatTime(arrivalTime)); Timber.d("Time difference between now and arrival: " + DateUtils.convertMillisecondsToTime(milliseconds)); return milliseconds; } }
From source file:com.ephemeraldreams.gallyshuttle.ui.MainFragment.java
License:Apache License
/** * Set a timer for arrival notification. * * @param notificationsBoxChecked Notification check box's checked status. *//*from ww w . j a v a2 s .c o m*/ private void setArrivalNotificationTimer(boolean notificationsBoxChecked) { if (notificationsBoxChecked) { if (arrivalTime != null) { Intent notificationIntent = new Intent(getActivity(), ArrivalNotificationReceiver.class); notificationIntent.putExtra(ArrivalNotificationReceiver.EXTRA_STATION_NAME, stationStopsAdapter.getItem(stationIndex)); notificationPendingIntent = PendingIntent.getBroadcast(getActivity(), 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT); Duration duration = new Duration(LocalDateTime.now().toDateTime(), arrivalTime.toDateTime()); long millis = duration.getMillis(); alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + millis, notificationPendingIntent); Timber.d("Arrival Notification receiver set: " + DateUtils.convertMillisecondsToTime(millis)); } else { Timber.d("Arrival Notification receiver not set. Arrival time is null."); } } else { alarmManager.cancel(notificationPendingIntent); Timber.d("Arrival Notification receiver cancelled."); } }