public static String timeoutMessage(long timeout, TimeUnit unit) { return "The source did not signal an event for " + timeout + " " + unit.toString().toLowerCase() + " and has been terminated."; }
protected static String toString(TimeUnit unit) { switch(unit) { case SECONDS: return "s"; case MILLISECONDS: return "ms"; case MICROSECONDS: return "us"; case NANOSECONDS: return "ns"; } return unit.toString(); } }
/** * <p>getTimeUnitAsString.</p> * * @return a {@link java.lang.String} object. */ public String getTimeUnitAsString() { return unit == null ? "<not defined>" : unit.toString().toLowerCase(); }
@VisibleForTesting public static String constructReasonString(long maxTime, TimeUnit timeUnit) { return "retries get failed due to exceeded maximum allowed time (" + "in " + timeUnit.toString() + "): " + maxTime; } }
@Override @JsonValue public String toString() { String units = unit.toString().toLowerCase(Locale.ENGLISH); if (count == 1) { units = units.substring(0, units.length() - 1); } return Long.toString(count) + ' ' + units; }
public TimePeriodValidator(final long minValue, final TimeUnit minTimeUnit, final long maxValue, final TimeUnit maxTimeUnit) { this.minNanos = TimeUnit.NANOSECONDS.convert(minValue, minTimeUnit); this.maxNanos = TimeUnit.NANOSECONDS.convert(maxValue, maxTimeUnit); this.minValueEnglish = minValue + " " + minTimeUnit.toString(); this.maxValueEnglish = maxValue + " " + maxTimeUnit.toString(); }
public static Map<String, String> timeUnits() { Map<String, String> units = Maps.newHashMap(); for(TimeUnit unit : TimeUnit.values()) { String human = unit.toString().toLowerCase(Locale.ENGLISH); units.put(unit.toString(), Character.toUpperCase(human.charAt(0)) + human.substring(1)); } return units; }
private String calculateRateUnit(TimeUnit unit) { final String s = unit.toString().toLowerCase(Locale.US); return s.substring(0, s.length() - 1); } }
private String calculateRateUnit(TimeUnit unit) { final String s = unit.toString().toLowerCase(Locale.US); return s.substring(0, s.length() - 1); } }
private String[] getTimeUnits() { ArrayList<String> timeUnits = new ArrayList<String>(); for ( TimeUnit timeUnit : TimeUnit.values() ) { timeUnits.add( timeUnit.toString() ); } return timeUnits.toArray( new String[timeUnits.size()] ); }
/** * @param timeout in milliseconds. If set to 0, waits indefinitely. * @return true if lock was acquired; and false if waiting time elapsed before lock could be * acquired. */ public boolean await(long timeout, TimeUnit timeUnit) throws InterruptedException { final boolean result = latch.await(timeout, timeUnit); String lockRequestStr = lockRequest.toString().replace("\n", ", "); if (result) { LOG.info("Acquired " + lockRequestStr); } else { LOG.info(String.format("Failed acquire in %s %s of %s", timeout, timeUnit.toString(), lockRequestStr)); } return result; }
public void run() { try { if (!latch.await(timeout, unit)) { listener.error("Timeout after " + timeout + " " + unit.toString().toLowerCase(Locale.ENGLISH)); kill(); } } catch (InterruptedException | IOException | RuntimeException x) { Functions.printStackTrace(x, listener.error("Failed to join a process")); } } });
public void setTimeUnit( TimeUnit tu ) { for ( int i = 0; i < wTimeUnit.getItemCount(); i++ ) { if ( tu.toString().equals( wTimeUnit.getItem( i ) ) ) { wTimeUnit.select( i ); break; } } }
private static SuggestedFix replaceTreeWith( MethodInvocationTree tree, TimeUnit units, String replacement) { return SuggestedFix.builder() .postfixWith(tree, " /* " + units.toString().toLowerCase() + " */") .replace(tree, replacement) .build(); }
protected void awaitTermination(GfshScript script) throws InterruptedException { boolean exited = process.waitFor(script.getTimeout(), script.getTimeoutTimeUnit()); try { assertThat(exited).describedAs("Process of [" + script.toString() + "] did not exit after " + script.getTimeout() + " " + script.getTimeoutTimeUnit().toString()).isTrue(); assertThat(process.exitValue()).isEqualTo(script.getExpectedExitValue()); } catch (AssertionError error) { printLogFiles(); throw error; } }
private static List<CharSequence> timeUnitValues() { List<CharSequence> result = new ArrayList<CharSequence>(); for (TimeUnit tu : TimeUnit.values()) { result.add(tu.toString()); } return result; }
@Test public void shouldSendCommMsgWhenStringFormatForColumnChange() throws Exception { //given TableDisplayStringFormat timeFormat = TableDisplayStringFormat.getTimeFormat(); //when tableDisplay.setStringFormatForColumn(COL_1, timeFormat); //then assertThat(tableDisplay.getStringFormatForColumn().get(COL_1)).isEqualTo(timeFormat); LinkedHashMap model = getModelUpdate(); assertThat(model.size()).isEqualTo(1); Map column = (Map) ((Map) model.get(STRING_FORMAT_FOR_COLUMN)).get(COL_1); assertThat(column.get(TimeStringFormatSerializer.TYPE)).isEqualTo(TimeStringFormatSerializer.VALUE_TIME); assertThat(column.get(TimeStringFormatSerializer.UNIT)).isEqualTo(TimeUnit.MILLISECONDS.toString()); assertThat(column.get(TimeStringFormatSerializer.HUMAN_FRIENDLY)).isEqualTo(false); }
@Test public void shouldSendCommMsgWhenStringFormatForTimesChange() throws Exception { //given TimeUnit days = TimeUnit.DAYS; //when tableDisplay.setStringFormatForTimes(days); //then assertThat(tableDisplay.getStringFormatForTimes()).isEqualTo(days); LinkedHashMap model = getModelUpdate(); assertThat(model.size()).isEqualTo(1); Map time = (Map)((Map)model.get(STRING_FORMAT_FOR_TYPE)).get(ColumnType.Time.toString()); assertThat(time.get("unit")).isEqualTo(days.toString()); }
@Test public void serializeStringFormatForTimes_resultJsonHasStringFormatForTimes() throws IOException { //given tableDisplay.setStringFormatForTimes(TimeUnit.DAYS); //when Map model = serializeTableDisplay(); //then Map time = (Map)((Map)model.get(STRING_FORMAT_FOR_TYPE)).get(ColumnType.Time.toString()); assertThat(time.get("unit")).isEqualTo(TimeUnit.DAYS.toString()); }
@Test public void stalenessSourceUnits() { long num = 7; for (TimeUnit units : TimeUnit.values()) { TimestampBound bound = TimestampBound.ofExactStaleness(num, units); assertThat(bound.getExactStaleness(TimeUnit.NANOSECONDS)) .named(units.toString()) .isEqualTo(units.toNanos(num)); } }