private CommandHandler(int id, Map<String, String> config) { super("CommandHandler-" + id); // setDaemon(true); // 默认100毫秒 loopInterval = DateTimeUtils.getLoopInterval(config, "command_handler_loop_interval", 100); }
@Override public Value subtract(Value v) { ValueTimestamp t = (ValueTimestamp) v.convertTo(Value.TIMESTAMP); long d1 = DateTimeUtils.absoluteDayFromDateValue(dateValue); long d2 = DateTimeUtils.absoluteDayFromDateValue(t.dateValue); return DateTimeUtils.normalizeTimestamp(d1 - d2, nanos - t.nanos); }
@Override public Date getDate() { return DateTimeUtils.convertDateValueToDate(dateValue); }
/** * Convert a date to the specified time zone. * * @param x the date to convert * @param target the calendar with the target timezone * @return the milliseconds in UTC */ public static long convertToLocal(java.util.Date x, Calendar target) { if (target == null) { throw DbException.getInvalidValueException("calendar", null); } target = (Calendar) target.clone(); Calendar local = Calendar.getInstance(); synchronized (local) { local.setTime(x); convertTime(local, target); } return target.getTime().getTime(); }
/** * Returns the value of the specified column as a java.sql.Date using a * specified time zone. * * @param columnIndex (1,2,...) * @param calendar the calendar * @return the value * @throws SQLException if the column is not found or if the result set is * closed */ @Override public Date getDate(int columnIndex, Calendar calendar) throws SQLException { try { if (isDebugEnabled()) { debugCode("getDate(" + columnIndex + ", calendar)"); } return DateTimeUtils.convertDate(get(columnIndex), calendar); } catch (Exception e) { throw logAndConvert(e); } }
@Override public Timestamp getTimestamp() { return DateTimeUtils.convertDateValueToTimestamp(dateValue, nanos); }
@Override public Time getTime() { return DateTimeUtils.convertNanoToTime(nanos); }
/** * Returns the value of the specified column as a java.sql.Time using a * specified time zone. * * @param columnIndex (1,2,...) * @param calendar the calendar * @return the value * @throws SQLException if the column is not found or if the result set is * closed */ @Override public Time getTime(int columnIndex, Calendar calendar) throws SQLException { try { if (isDebugEnabled()) { debugCode("getTime(" + columnIndex + ", calendar)"); } return DateTimeUtils.convertTime(get(columnIndex), calendar); } catch (Exception e) { throw logAndConvert(e); } }
/** * Returns the value of the specified column as a java.sql.Date using a * specified time zone. * * @param columnLabel the column label * @param calendar the calendar * @return the value * @throws SQLException if the column is not found or if the result set is * closed */ @Override public Date getDate(String columnLabel, Calendar calendar) throws SQLException { try { if (isDebugEnabled()) { debugCode("getDate(" + StringUtils.quoteJavaString(columnLabel) + ", calendar)"); } return DateTimeUtils.convertDate(get(columnLabel), calendar); } catch (Exception e) { throw logAndConvert(e); } }
InstantLogSyncService(Map<String, String> config) { syncIntervalMillis = DateTimeUtils.getLoopInterval(config, "log_sync_service_loop_interval", DEFAULT_LOG_SYNC_INTERVAL); }
/** * Returns the value of the specified column as a java.sql.Time using a * specified time zone. * * @param columnLabel the column label * @param calendar the calendar * @return the value * @throws SQLException if the column is not found or if the result set is * closed */ @Override public Time getTime(String columnLabel, Calendar calendar) throws SQLException { try { if (isDebugEnabled()) { debugCode("getTime(" + StringUtils.quoteJavaString(columnLabel) + ", calendar)"); } return DateTimeUtils.convertTime(get(columnLabel), calendar); } catch (Exception e) { throw logAndConvert(e); } }
@Override public Value add(Value v) { ValueTimestamp t = (ValueTimestamp) v.convertTo(Value.TIMESTAMP); long d1 = DateTimeUtils.absoluteDayFromDateValue(dateValue); long d2 = DateTimeUtils.absoluteDayFromDateValue(t.dateValue); return DateTimeUtils.normalizeTimestamp(d1 + d2, nanos + t.nanos); }
/** * Sets the date using a specified time zone. The value will be converted to * the local time zone. * * @param parameterIndex the parameter index (1, 2, ...) * @param x the value * @param calendar the calendar * @throws SQLException if this object is closed */ @Override public void setDate(int parameterIndex, java.sql.Date x, Calendar calendar) throws SQLException { try { if (isDebugEnabled()) { debugCode("setDate(" + parameterIndex + ", " + quoteDate(x) + ", calendar);"); } if (x == null) { setParameter(parameterIndex, ValueNull.INSTANCE); } else { setParameter(parameterIndex, DateTimeUtils.convertDate(x, calendar)); } } catch (Exception e) { throw logAndConvert(e); } }
public NioEventLoopAdapter(Map<String, String> config, String loopIntervalKey, long loopIntervalDefaultValue) throws IOException { loopInterval = DateTimeUtils.getLoopInterval(config, loopIntervalKey, loopIntervalDefaultValue); selector = Selector.open(); }
/** * Sets the time using a specified time zone. The value will be converted to * the local time zone. * * @param parameterIndex the parameter index (1, 2, ...) * @param x the value * @param calendar the calendar * @throws SQLException if this object is closed */ @Override public void setTime(int parameterIndex, java.sql.Time x, Calendar calendar) throws SQLException { try { if (isDebugEnabled()) { debugCode("setTime(" + parameterIndex + ", " + quoteTime(x) + ", calendar);"); } if (x == null) { setParameter(parameterIndex, ValueNull.INSTANCE); } else { setParameter(parameterIndex, DateTimeUtils.convertTime(x, calendar)); } } catch (Exception e) { throw logAndConvert(e); } }
public synchronized void start(Map<String, String> config) { // 默认3秒钟 loopInterval = DateTimeUtils.getLoopInterval(config, "storage_service_loop_interval", 3000); start(); }
CheckpointService(Map<String, String> config) { setName(getClass().getSimpleName()); setDaemon(true); String v = config.get("committed_data_cache_size_in_mb"); if (v != null) committedDataCacheSize = Integer.parseInt(v) * 1024 * 1024; else committedDataCacheSize = DEFAULT_COMMITTED_DATA_CACHE_SIZE; v = config.get("checkpoint_period"); if (v != null) checkpointPeriod = Long.parseLong(v); else checkpointPeriod = DEFAULT_CHECKPOINT_PERIOD; // 默认1分钟 long loopInterval = DateTimeUtils.getLoopInterval(config, "checkpoint_service_loop_interval", 1 * 60 * 1000); if (checkpointPeriod < loopInterval) loopInterval = checkpointPeriod; this.loopInterval = loopInterval; }