New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support cron timer to arrange the period heartbeat executor invoke time #16900
Conversation
@maobaolong checkstyle failed. Maybe you need to format the code style. |
@JiamingMai The style issue has been resolved, PTAL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this interesting feature! Left some comments to improve the design.
core/common/src/main/java/alluxio/heartbeat/ScheduledTimer.java
Outdated
Show resolved
Hide resolved
core/common/src/main/java/alluxio/heartbeat/HeartbeatTimer.java
Outdated
Show resolved
Hide resolved
core/common/src/main/java/alluxio/heartbeat/HeartbeatThread.java
Outdated
Show resolved
Hide resolved
core/common/src/main/java/alluxio/heartbeat/HeartbeatExecutor.java
Outdated
Show resolved
Hide resolved
core/common/src/main/java/alluxio/heartbeat/HeartbeatExecutor.java
Outdated
Show resolved
Hide resolved
core/common/src/main/java/alluxio/heartbeat/HeartbeatExecutor.java
Outdated
Show resolved
Hide resolved
core/common/src/main/java/alluxio/heartbeat/HeartbeatExecutor.java
Outdated
Show resolved
Hide resolved
@dbw9580 Thanks advance for your helpful suggestion and kindly helping, I've refactor the code, PTAL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly LGTM, only a few minor issues
core/common/src/main/java/alluxio/heartbeat/CronExpressionIntervalSupplier.java
Outdated
Show resolved
Hide resolved
core/common/src/main/java/alluxio/heartbeat/FixedIntervalSupplier.java
Outdated
Show resolved
Hide resolved
core/common/src/main/java/alluxio/heartbeat/HeartbeatTimer.java
Outdated
Show resolved
Hide resolved
core/common/src/main/java/alluxio/heartbeat/ScheduledTimer.java
Outdated
Show resolved
Hide resolved
f53a617
to
b902913
Compare
b902913
to
ef89064
Compare
@dbw9580 The failed test has been fixed, PTAL. |
() -> { | ||
try { | ||
return new CronExpressionIntervalSupplier( | ||
new CronExpression("* 30-59 0-1,4-9,13-23 * * ? *"), INTERVAL_MS); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this is not the standard crontab expression. When we add the docs, a link to the cron syntax specification should be included. https://logging.apache.org/log4j/2.x/log4j-core/apidocs/org/apache/logging/log4j/core/util/CronExpression.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason we use log4j's implementation of cron? Is this cron syntax commonly used by log4j or other utilities?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dbw9580 Log4j cron expression is used for config RollingFileAppender
and TimeBasedRollingPolicy
, it can control the rolling of log file, something like
appender.rolling.type = RollingFile
appender.rolling.name = RollingFile
appender.rolling.fileName = logs/app.log
appender.rolling.filePattern = logs/app-%d{yyyy-MM-dd}.log
appender.rolling.layout.type = PatternLayout
appender.rolling.layout.pattern = %d{yyyy-MM-dd HH:mm:ss} [%t] %-5p %c{1}:%L - %m%n
appender.rolling.policies.type = Policies
appender.rolling.policies.time.type = TimeBasedTriggeringPolicy
appender.rolling.policies.time.interval = 1
appender.rolling.policies.time.modulate = true
appender.rolling.policies.time.cron = 0 0 1 * * ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
alluxio-bot, merge this please |
mStatus = Status.RUNNING; | ||
mExecutor.heartbeat(); | ||
LOG.debug("{} #{} will run limited in {}s", mThreadName, counter++, limitTime / 1000); | ||
mExecutor.heartbeat(limitTime); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Who stops this heartbeat if the limitTime has been exceeded?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stopped by Heartbeat implementation
…period heartbeat executor invoke time Support cron timer to arrange the period heartbeat executor invoke time. Example ``` cron timer config: * 0-10,20-30,40-56 12-13 * * ? * The heartbeat executor invoke at every minute from 0 through 10, from 20 through 30, from 40 through 56, at past every hour from 12 through 13. ``` pr-link: Alluxio#16900 change-id: cid-9277f30e2159e64863067d14cbcbee526707c5b6
…period heartbeat executor invoke time Support cron timer to arrange the period heartbeat executor invoke time. Example ``` cron timer config: * 0-10,20-30,40-56 12-13 * * ? * The heartbeat executor invoke at every minute from 0 through 10, from 20 through 30, from 40 through 56, at past every hour from 12 through 13. ``` pr-link: Alluxio#16900 change-id: cid-9277f30e2159e64863067d14cbcbee526707c5b6
Support cron timer to arrange the period heartbeat executor invoke time.
Example