本文整理了Java中ch.qos.logback.core.util.Duration.getMilliseconds()
方法的一些代码示例,展示了Duration.getMilliseconds()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Duration.getMilliseconds()
方法的具体详情如下:
包路径:ch.qos.logback.core.util.Duration
类名称:Duration
方法名:getMilliseconds
暂无
代码示例来源:origin: ch.qos.logback/logback-classic
void processScanAttrib(InterpretationContext ic, Attributes attributes) {
String scanAttrib = ic.subst(attributes.getValue(SCAN_ATTR));
if (!OptionHelper.isEmpty(scanAttrib) && !"false".equalsIgnoreCase(scanAttrib)) {
ScheduledExecutorService scheduledExecutorService = context.getScheduledExecutorService();
URL mainURL = ConfigurationWatchListUtil.getMainWatchURL(context);
if (mainURL == null) {
addWarn("Due to missing top level configuration file, reconfiguration on change (configuration file scanning) cannot be done.");
return;
}
ReconfigureOnChangeTask rocTask = new ReconfigureOnChangeTask();
rocTask.setContext(context);
context.putObject(CoreConstants.RECONFIGURE_ON_CHANGE_TASK, rocTask);
String scanPeriodAttrib = ic.subst(attributes.getValue(SCAN_PERIOD_ATTR));
Duration duration = getDuration(scanAttrib, scanPeriodAttrib);
if (duration == null) {
return;
}
addInfo("Will scan for changes in [" + mainURL + "] ");
// Given that included files are encountered at a later phase, the complete list of files
// to scan can only be determined when the configuration is loaded in full.
// However, scan can be active if mainURL is set. Otherwise, when changes are detected
// the top level config file cannot be accessed.
addInfo("Setting ReconfigureOnChangeTask scanning period to " + duration);
ScheduledFuture<?> scheduledFuture = scheduledExecutorService.scheduleAtFixedRate(rocTask, duration.getMilliseconds(), duration.getMilliseconds(),
TimeUnit.MILLISECONDS);
context.addScheduledFuture(scheduledFuture);
}
}
代码示例来源:origin: camunda/camunda-bpm-platform
/**
* {@inheritDoc}
*/
@Override
protected void append(E event) {
if (event == null || !isStarted()) return;
try {
final boolean inserted = queue.offer(event, eventDelayLimit.getMilliseconds(), TimeUnit.MILLISECONDS);
if (!inserted) {
addInfo("Dropping event due to timeout limit of [" + eventDelayLimit +
"] milliseconds being exceeded");
}
} catch (InterruptedException e) {
addError("Interrupted while appending event to SocketAppender", e);
}
}
代码示例来源:origin: camunda/camunda-bpm-platform
/**
* {@inheritDoc}
*/
public final void run() {
signalEntryInRunMethod();
try {
while (!Thread.currentThread().isInterrupted()) {
SocketConnector connector = createConnector(address, port, 0,
reconnectionDelay.getMilliseconds());
connectorTask = activateConnector(connector);
if(connectorTask == null)
break;
socket = waitForConnectorToReturnASocket();
if(socket == null)
break;
dispatchEvents();
}
} catch (InterruptedException ex) {
assert true; // ok... we'll exit now
}
addInfo("shutting down");
}
代码示例来源:origin: camunda/camunda-bpm-platform
void processScanAttrib(InterpretationContext ic, Attributes attributes) {
String scanAttrib = ic.subst(attributes.getValue(SCAN_ATTR));
if (!OptionHelper.isEmpty(scanAttrib)
&& !"false".equalsIgnoreCase(scanAttrib)) {
ReconfigureOnChangeFilter rocf = new ReconfigureOnChangeFilter();
rocf.setContext(context);
String scanPeriodAttrib = ic.subst(attributes.getValue(SCAN_PERIOD_ATTR));
if (!OptionHelper.isEmpty(scanPeriodAttrib)) {
try {
Duration duration = Duration.valueOf(scanPeriodAttrib);
rocf.setRefreshPeriod(duration.getMilliseconds());
addInfo("Setting ReconfigureOnChangeFilter scanning period to "
+ duration);
} catch (NumberFormatException nfe) {
addError("Error while converting [" + scanAttrib + "] to long", nfe);
}
}
rocf.start();
LoggerContext lc = (LoggerContext) context;
addInfo("Adding ReconfigureOnChangeFilter as a turbo filter");
lc.addTurboFilter(rocf);
}
}
代码示例来源:origin: tony19/logback-android
/**
* Gets the maximum history in milliseconds
* @return the max history in milliseconds
*/
public long getMaxHistoryMs() {
return maxHistory != null ? maxHistory.getMilliseconds() : 0;
}
代码示例来源:origin: net.logstash.logback/logstash-logback-encoder
@Override
public void connectSuccess(long connectionStartTimeInMillis, int connectedDestinationIndex, int numDestinations) {
if (connectionTTL != null) {
connectionExpirationTime = connectionStartTimeInMillis + connectionTTL.getMilliseconds();
}
else {
connectionExpirationTime = Long.MAX_VALUE;
}
}
代码示例来源:origin: net.logstash.logback/logstash-logback-encoder
@Override
public void connectSuccess(long connectionStartTimeInMillis, int connectedDestinationIndex, int numDestinations) {
/*
* If connected to a secondary, remember when the connection should be closed to
* force attempt to reconnect to primary
*/
if (secondaryConnectionTTL != null && connectedDestinationIndex != PRIMARY_DESTINATION_INDEX) {
secondaryConnectionExpirationTime = connectionStartTimeInMillis + secondaryConnectionTTL.getMilliseconds();
}
else {
secondaryConnectionExpirationTime = Long.MAX_VALUE;
}
nextDestinationIndex = PRIMARY_DESTINATION_INDEX;
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Override
public void start() {
int errors = 0;
if (discriminator == null) {
addError("Missing discriminator. Aborting");
errors++;
}
if (!discriminator.isStarted()) {
addError("Discriminator has not started successfully. Aborting");
errors++;
}
if (appenderFactory == null) {
addError("AppenderFactory has not been set. Aborting");
errors++;
} else {
appenderTracker = new AppenderTracker<E>(context, appenderFactory);
appenderTracker.setMaxComponents(maxAppenderCount);
appenderTracker.setTimeout(timeout.getMilliseconds());
}
if (errors == 0) {
super.start();
}
}
代码示例来源:origin: net.logstash.logback/logstash-logback-encoder
/**
* Time period for which to wait after failing to connect to all servers,
* before attempting to reconnect.
* Default is {@value #DEFAULT_RECONNECTION_DELAY} milliseconds.
*/
public void setReconnectionDelay(Duration delay) {
if (delay == null || delay.getMilliseconds() <= 0) {
throw new IllegalArgumentException("reconnectionDelay must be > 0");
}
this.reconnectionDelay = delay;
}
代码示例来源:origin: net.logstash.logback/logstash-logback-encoder
public void setConnectionTTL(Duration connectionTTL) {
if (connectionTTL != null && connectionTTL.getMilliseconds() <= 0) {
throw new IllegalArgumentException("connectionTTL must be > 0");
}
this.connectionTTL = connectionTTL;
}
代码示例来源:origin: net.logstash.logback/logstash-logback-encoder
/**
* Time period for connections to secondary destinations to be used
* before attempting to reconnect to primary destination.
*
* When the value is null (the default), the feature is disabled:
* the appender will stay on the current destination until an error occurs.
*
* @param secondaryConnectionTTL
*/
public void setSecondaryConnectionTTL(Duration secondaryConnectionTTL) {
if (secondaryConnectionTTL != null && secondaryConnectionTTL.getMilliseconds() <= 0) {
throw new IllegalArgumentException("secondaryConnectionTTL must be > 0");
}
this.secondaryConnectionTTL = secondaryConnectionTTL;
}
代码示例来源:origin: tony19/logback-android
public void run() {
if (delay.getMilliseconds() > 0) {
addInfo("Sleeping for " + delay);
try {
Thread.sleep(delay.getMilliseconds());
} catch (InterruptedException e) {
}
}
super.stop();
}
}
代码示例来源:origin: com.hynnet/logback-core
public void run() {
try {
Thread.sleep(delay.getMilliseconds());
} catch (InterruptedException e) {
}
super.stop();
}
}
代码示例来源:origin: tony19/logback-android
public void performLogCleanup(SQLiteDatabase db, Duration expiry) {
final long expiryMs = thisClock.currentTimeMillis() - expiry.getMilliseconds();
final String deleteExpiredLogsSQL = SQLBuilder.buildDeleteExpiredLogsSQL(dbNameResolver, expiryMs);
db.execSQL(deleteExpiredLogsSQL);
}
};
代码示例来源:origin: Nextdoor/bender
public void run() {
addInfo("Sleeping for "+delay);
try {
Thread.sleep(delay.getMilliseconds());
} catch (InterruptedException e) {
}
super.stop();
}
}
代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded
public void run() {
addInfo("Sleeping for "+delay);
try {
Thread.sleep(delay.getMilliseconds());
} catch (InterruptedException e) {
}
super.stop();
}
}
代码示例来源:origin: io.virtdata/virtdata-lib-realer
public void run() {
addInfo("Sleeping for "+delay);
try {
Thread.sleep(delay.getMilliseconds());
} catch (InterruptedException e) {
}
super.stop();
}
}
代码示例来源:origin: me.moocar/socket-encoder-appender
@Override
protected void subAppend(E event) {
if (event == null || !isStarted()) return;
try {
final boolean inserted = deque.offer(event, eventDelayLimit.getMilliseconds(), TimeUnit.MILLISECONDS);
if (!inserted) {
addInfo("Dropping event due to timeout limit of [" + eventDelayLimit + "] being exceeded");
}
} catch (InterruptedException e) {
addError("Interrupted while appending event to SocketAppender", e);
}
}
代码示例来源:origin: com.hynnet/logback-core
/**
* {@inheritDoc}
*/
@Override
protected void append(E event) {
if (event == null || !isStarted()) return;
try {
final boolean inserted = deque.offer(event, eventDelayLimit.getMilliseconds(), TimeUnit.MILLISECONDS);
if (!inserted) {
addInfo("Dropping event due to timeout limit of [" + eventDelayLimit + "] being exceeded");
}
} catch (InterruptedException e) {
addError("Interrupted while appending event to SocketAppender", e);
}
}
代码示例来源:origin: tony19/logback-android
@Test
public void testDuration() {
setter.setProperty("duration", "1.4 seconds");
assertEquals(1400, house.getDuration().getMilliseconds());
}
内容来源于网络,如有侵权,请联系作者删除!