@Scheduled(cron = "10 * * * * ?")
void storeUserCountMetrics() {
ZonedDateTime timestamp = ZonedDateTime.now().truncatedTo(MINUTES);
userCountRepository.save(
metricRegistry.getHistograms((name, metric) -> name.startsWith("discord.ws.users"))
.entrySet().stream()
.map(entry -> Pair.of(extractTags(entry.getKey()), (long) entry.getValue().getSnapshot().getMean()))
.map(pair -> new UserCount()
.bot(pair.getKey()[0])
.guild(pair.getKey()[1])
.status(pair.getKey()[2])
.value(pair.getValue())
.timestamp(timestamp))
.collect(Collectors.toList())
);
}
java类org.springframework.scheduling.annotation.Scheduled的实例源码
UserCountService.java 文件源码
项目:sentry
阅读 18
收藏 0
点赞 0
评论 0
DataService.java 文件源码
项目:microservices-prototype
阅读 23
收藏 0
点赞 0
评论 0
@HystrixCommand(fallbackMethod = HYSTRIX_FALL_BACK,
commandKey = HYSTRIX_COMMAND_KEY,
groupKey = HYSTRIX_GROUP_KEY)
@Scheduled(fixedDelay = 60000)
public void indexedData() {
log.info("SEARCH-SERVICE: Data indexer is starting to work.");
currentPageIndex = getCurrentPageIndex();
log.info("Current page for pushing is {}", currentPageIndex);
long totalPage = tweetClient.getTweets().getMetadata().getTotalPages();
for (long i = currentPageIndex; i <= totalPage; i++) {
Runnable task = new PusherProcessor(tweetRepository, tweetClient, i);
taskExecutor.execute(task);
currentPageIndex = i++;
saveCurrentPageIndex(i);
}
}
TaskTimeoutJob.java 文件源码
项目:lemon
阅读 22
收藏 0
点赞 0
评论 0
@Scheduled(cron = "0/10 * * * * ?")
public void execute() throws Exception {
logger.info("start");
List<Task> tasks = processEngine.getTaskService().createTaskQuery()
.list();
for (Task task : tasks) {
if (task.getDueDate() != null) {
SendNoticeCmd sendNoticeCmd = new SendNoticeCmd(task.getId());
processEngine.getManagementService().executeCommand(
sendNoticeCmd);
}
}
logger.info("end");
}
DataScheduler.java 文件源码
项目:stdds-monitor
阅读 18
收藏 0
点赞 0
评论 0
@Scheduled(fixedRate = 60000)
@Transactional
public void purgeOldNotifications() {
ExpirationConfiguration props = properties.getNotifications();
String methodName = "purgeOldNotifications";
PurgeMethods purgeMethod = new PurgeMethods() {
@Override
public long deleteByTime(long time) {
return notRepo.deleteByTimeLessThanOrderByTimeDesc(time);
}
@Override
public long deleteBySize(long max) {
return 0;
}
};
purgeData(methodName, props, purgeMethod);
}
AgentServiceImpl.java 文件源码
项目:flow-platform
阅读 16
收藏 0
点赞 0
评论 0
@Override
@Transactional(propagation = Propagation.NEVER)
@Scheduled(initialDelay = 10 * 1000, fixedDelay = SESSION_TIMEOUT_TASK_HEARTBEAT)
public void sessionTimeoutTask() {
if (!taskConfig.isEnableAgentSessionTimeoutTask()) {
return;
}
LOGGER.traceMarker("sessionTimeoutTask", "start");
ZonedDateTime now = DateUtil.utcNow();
for (Zone zone : zoneService.getZones()) {
Collection<Agent> agents = listForOnline(zone.getName());
for (Agent agent : agents) {
if (agent.getSessionId() != null && isSessionTimeout(agent, now, zone.getAgentSessionTimeout())) {
Cmd delSessionCmd = cmdService.create(new CmdInfo(agent.getPath(), CmdType.DELETE_SESSION, null));
cmdDispatchService.dispatch(delSessionCmd);
LOGGER.traceMarker("sessionTimeoutTask", "Send DELETE_SESSION to agent %s", agent);
}
}
}
LOGGER.traceMarker("sessionTimeoutTask", "end");
}
ScheduledTask.java 文件源码
项目:AngularAndSpring
阅读 20
收藏 0
点赞 0
评论 0
@Scheduled(fixedRate = 60000, initialDelay=15000)
public void insertCoinbaseQuote() {
Date start = new Date();
WebClient wc = buildWebClient(URLCB);
try {
operations.insert(
wc.get().uri("/exchange-rates?currency=BTC")
.accept(MediaType.APPLICATION_JSON).exchange()
.flatMap(response -> response.bodyToMono(WrapperCb.class))
.flatMap(resp -> Mono.just(resp.getData()))
.flatMap(resp2 -> {log.info(resp2.getRates().toString()); return Mono.just(resp2.getRates());})
).then().block(Duration.ofSeconds(3));
log.info("CoinbaseQuote " + dateFormat.format(new Date()) + " " + (new Date().getTime()-start.getTime()) + "ms");
} catch (Exception e) {
// log.error("Coinbase insert error", e);
log.error("Coinbase insert error "+ dateFormat.format(new Date()));
}
}
SendNotifyMessageJob.java 文件源码
项目:agile-wroking-backend
阅读 16
收藏 0
点赞 0
评论 0
@Scheduled(fixedDelay = 60 * 1000)
public void execute() {
Date date = DateUtils.parse(DateUtils.format(new Date(), DateUtils.PATTERN_SIMPLE_DATE),
DateUtils.PATTERN_SIMPLE_DATE);
if (date.compareTo(this.date) > 0) {
this.date = date;
cache.clear();
}
String accessToken = getAccessToken();
scheduleRepository.findByDate(date).forEach(s -> {
if (cache.contains(new Long(s.getScheduleId().intValue()))) {
return;
}
if (isNeedSendMessageNow(s)) {
doSend(accessToken, s);
cache.add(new Long(s.getScheduleId().intValue()));
}
});
}
CachedDataProvider.java 文件源码
项目:app-ms
阅读 17
收藏 0
点赞 0
评论 0
/**
* Builds JWKS if necessary after 60 seconds, but only builds
* {@value #MIN_NUMBER_OF_KEYS} at a time.
*/
@Scheduled(fixedDelay = 60000)
public void buildJwks() {
int nCreated = 0;
for (int i = 0; i < MAX_NUMBER_OF_KEYS; ++i) {
final String cacheKey = String.valueOf(i);
final JsonWebKey jwk = jwksCache.get(cacheKey, JsonWebKey.class);
if (jwk == null && nCreated < MIN_NUMBER_OF_KEYS) {
final RsaJsonWebKey newJwk = buildNewRsaKey();
jwksCache.putIfAbsent(cacheKey, newJwk);
++nCreated;
LOG.debug("Created new JWK kid={}", newJwk.getKeyId());
}
}
}
PostService.java 文件源码
项目:biblebot
阅读 18
收藏 0
点赞 0
评论 0
/**
* Process all instance days that are not processed already, but are due
*
* “At minute 0 past every hour.”
*/
@Scheduled(cron = "${biblereadingplan.postservice.cron:0 0 */1 * * *}")
@Transactional
public void process() {
validateService.scheduleAll();
for (PlanInstanceDay instanceDay : planInstanceDayRepository
.findAllByIsPostedIsFalseAndScheduledDateBeforeOrderByScheduledDateAsc(new Date())) {
validateService.setDefaultValues(instanceDay.getDay());
validateService.setDefaultValues(instanceDay);
if (rocketChatPostService.post(instanceDay)) {
instanceDay.setPosted(true);
planInstanceDayRepository.save(instanceDay);
} else {
LOGGER.error("Could not post message.");
}
}
}
ProductService.java 文件源码
项目:spring-cloud-samples
阅读 21
收藏 0
点赞 0
评论 0
/**
*/
@Scheduled(fixedRate = 10000)
public void autoCancel() {
// 获取过期的资源
final List<ProuctTcc> tccs = productTccRepositorie.expireReservation(2);
tccs.forEach(tcc -> {
cancel(tcc.getId());
});
}
ProcessorTasks.java 文件源码
项目:proxylive
阅读 18
收藏 0
点赞 0
评论 0
@Scheduled(fixedDelay = 5 * 1000)//Every 5 seconds
public void killHLSStreams() {
long now = new Date().getTime();
Map<Thread, IStreamTask> HLSTasksFore = new HashMap(HLSTasks);
for (Entry<Thread, IStreamTask> entry : HLSTasksFore.entrySet()) {
HLSTask hlsTask = (HLSTask) entry.getValue();
if (hlsTask.getLastAccess() != null) {
long difference = (now - hlsTask.getLastAccess()) / 1000;
if (difference > config.getFfmpeg().getHls().getTimeout()) {
//Kill all stream processors using this task
for (ClientInfo client : new ArrayList<>(streamProcessorsSession.getClientInfoList())) {
for (IStreamProcessor streamProcessor : new ArrayList<>(client.getStreams())) {
IStreamTask streamBindedTask = streamProcessor.getTask();
if (streamBindedTask == hlsTask) {
try {
streamProcessor.stop(false);
streamProcessorsSession.removeClientInfo(client, streamProcessor);
} catch (Exception ex) {
}
}
}
}
}
}
}
}
UploadTask.java 文件源码
项目:SkyEye
阅读 19
收藏 0
点赞 0
评论 0
/**
* 上传到hdfs并删除相应的文件
*/
@Scheduled(cron = "${spring.upload.log.cron}")
private void upload() {
String yesterday = this.getYesterday();
LOGGER.info("开始上传到hdfs, 时间: {}", yesterday);
StopWatch sw = new StopWatch();
sw.start();
this.fileUtil.uploadToHDFS(yesterday);
sw.stop();
LOGGER.info("上传到hdfs结束, 耗时: {} ms", sw.getTotalTimeMillis());
}
FanfouTask.java 文件源码
项目:telegram-bot
阅读 17
收藏 0
点赞 0
评论 0
@Scheduled(cron = "0 5 8 * * *")
public void daily() {
long start = System.currentTimeMillis();
log.info("每日精选启动...");
try {
String date = DateFormatUtils.format(new Date(), pattern);
fanfouHandler.sendContent(dailyChatId, AppUtils.getFanFouDailyByDate(date));
} catch (Exception e) {
log.info(e.getMessage());
appUtils.sendServerChan(e.getMessage(), ExceptionUtils.getStackTrace(e));
}
log.info("每日精选完成,耗时:{} ms", System.currentTimeMillis() - start);
}
CommentSimulator.java 文件源码
项目:Learning-Spring-Boot-2.0-Second-Edition
阅读 20
收藏 0
点赞 0
评论 0
@Scheduled(fixedRate = 100)
public void simulateActivity() {
repository
.findAll()
.map(image -> {
Comment comment = new Comment();
comment.setImageId(image.getId());
comment.setComment(
"Comment #" + counter.getAndIncrement());
return Mono.just(comment);
})
.map(commentController::addComment)
.subscribe();
}
JavaConfig.java 文件源码
项目:Spring-Security-Third-Edition
阅读 19
收藏 0
点赞 0
评论 0
@Scheduled(fixedRate = 600_000)
public void tokenRepositoryCleaner(){
Thread trct = new Thread(
new JpaTokenRepositoryCleaner(
rememberMeTokenRepository,
100_000L));
trct.start();
}
CommentSimulator.java 文件源码
项目:Learning-Spring-Boot-2.0-Second-Edition
阅读 20
收藏 0
点赞 0
评论 0
@Scheduled(fixedRate = 100)
public void simulateActivity() {
repository
.findAll()
.map(image -> {
Comment comment = new Comment();
comment.setImageId(image.getId());
comment.setComment(
"Comment #" + counter.getAndIncrement());
return Mono.just(comment);
})
.map(commentController::addComment)
.subscribe();
}
ResponseCacheImpl.java 文件源码
项目:artemis-disruptor-miaosha
阅读 21
收藏 0
点赞 0
评论 0
/**
* 定时清理缓存, 5分钟
*/
@Scheduled(fixedDelay = 1000 * 60L * 5)
public void flush() {
Long now = System.currentTimeMillis();
RESPONSE_MAP.keySet().stream()
.filter(s -> RESPONSE_MAP.get(s).getValue1() < now)
.forEach(RESPONSE_MAP::remove);
}
UserService.java 文件源码
项目:Microservices-with-JHipster-and-Spring-Boot
阅读 26
收藏 0
点赞 0
评论 0
/**
* Not activated users should be automatically deleted after 3 days.
* <p>
* This is scheduled to get fired everyday, at 01:00 (am).
* </p>
*/
@Scheduled(cron = "0 0 1 * * ?")
public void removeNotActivatedUsers() {
ZonedDateTime now = ZonedDateTime.now();
List<User> users = userRepository.findAllByActivatedIsFalseAndCreatedDateBefore(now.minusDays(3));
for (User user : users) {
log.debug("Deleting not activated user {}", user.getLogin());
userRepository.delete(user);
userSearchRepository.delete(user);
}
}
BitbucketService.java 文件源码
项目:rebazer
阅读 19
收藏 0
点赞 0
评论 0
@Scheduled( fixedDelay = 60 * 1000 )
public void pollBitbucket() {
for ( final Repository repo : config.getRepos() ) {
log.debug( "Processing {}.", repo );
for ( final PullRequest pr : getAllPullRequests( repo ) ) {
handlePR( repo, pr );
}
}
}
UserService.java 文件源码
项目:jhipster-microservices-example
阅读 28
收藏 0
点赞 0
评论 0
/**
* Not activated users should be automatically deleted after 3 days.
* <p>
* This is scheduled to get fired everyday, at 01:00 (am).
* </p>
*/
@Scheduled(cron = "0 0 1 * * ?")
public void removeNotActivatedUsers() {
List<User> users = userRepository.findAllByActivatedIsFalseAndCreatedDateBefore(Instant.now().minus(3, ChronoUnit.DAYS));
for (User user : users) {
log.debug("Deleting not activated user {}", user.getLogin());
userRepository.delete(user);
userSearchRepository.delete(user);
}
}
JavaConfig.java 文件源码
项目:Spring-Security-Third-Edition
阅读 21
收藏 0
点赞 0
评论 0
@Scheduled(fixedRate = 600_000)
public void tokenRepositoryCleaner(){
Thread trct = new Thread(
new JpaTokenRepositoryCleaner(
rememberMeTokenRepository,
100_000L));
trct.start();
}
ScheduledTask.java 文件源码
项目:AngularAndSpring
阅读 20
收藏 0
点赞 0
评论 0
@Scheduled(fixedRate = 60000,initialDelay=33000)
public void insertBitstampQuoteXRPUSD() throws InterruptedException {
Date start = new Date();
WebClient wc = buildWebClient(URLBS);
try {
operations.insert(wc.get().uri("/v2/ticker/xrpusd/").accept(MediaType.APPLICATION_JSON).exchange()
.flatMap(response -> response.bodyToMono(QuoteBs.class)).map(res -> {res.setPair("xrpusd"); log.info(res.toString()); return res;})).then().block(Duration.ofSeconds(3));
log.info("BitstampQuote Xrp Usd " + dateFormat.format(new Date()) + " " + (new Date().getTime()-start.getTime()) + "ms");
} catch (Exception e) {
// log.error("Bitstamp insert error", e);
log.error("Bitstamp Xrp insert error Usd "+ dateFormat.format(new Date()));
}
}
UserService.java 文件源码
项目:patient-portal
阅读 24
收藏 0
点赞 0
评论 0
/**
* Persistent Token are used for providing automatic authentication, they should be automatically deleted after
* 30 days.
* <p>
* This is scheduled to get fired everyday, at midnight.
*/
@Scheduled(cron = "0 0 0 * * ?")
public void removeOldPersistentTokens() {
LocalDate now = LocalDate.now();
persistentTokenRepository.findByTokenDateBefore(now.minusMonths(1)).forEach(token -> {
log.debug("Deleting token {}", token.getSeries());
User user = token.getUser();
user.getPersistentTokens().remove(token);
persistentTokenRepository.delete(token);
});
}
TaskManager.java 文件源码
项目:sdudoc
阅读 27
收藏 0
点赞 0
评论 0
/**
* 每天0点的时候,执行一遍日志删除工作,将30天之前的日志删除
*/
@Scheduled(cron = "0 0 0 * * ? ")
public void deleteLogs() {
if (log.isInfoEnabled()) {
log.info("执行删除日志任务");
}
logService.deleteLogDaysAgo(30);
}
EmailRetentionTimer.java 文件源码
项目:fake-smtp-server
阅读 15
收藏 0
点赞 0
评论 0
@Scheduled(fixedDelay = 300000, initialDelay = 500)
public void deleteOutdatedMails(){
FakeSmtpConfigurationProperties.Persistence persistence = fakeSmtpConfigurationProperties.getPersistence();
if(isDataRetentionConfigured(persistence)){
int maxNumber = persistence.getMaxNumberEmails();
int count = emailRepository.deleteEmailsExceedingDateRetentionLimit(maxNumber);
logger.info("Deleted {} emails which exceeded the maximum number {} of emails to be stored", count, maxNumber);
}
}
UserService.java 文件源码
项目:Code4Health-Platform
阅读 28
收藏 0
点赞 0
评论 0
/**
* Not activated users should be automatically deleted after 3 days.
* <p>
* This is scheduled to get fired everyday, at 01:00 (am).
* </p>
*/
@Scheduled(cron = "0 0 1 * * ?")
public void removeNotActivatedUsers() {
ZonedDateTime now = ZonedDateTime.now();
List<User> users = userRepository.findAllByActivatedIsFalseAndCreatedDateBefore(now.minusDays(3));
for (User user : users) {
log.debug("Deleting not activated user {}", user.getLogin());
userRepository.delete(user);
userSearchRepository.delete(user);
}
}
LabelUpdater.java 文件源码
项目:mensa-api
阅读 16
收藏 0
点赞 0
评论 0
@Scheduled(cron = "${update.label.cron}")
public void update() {
log.info("Starting label update");
List<Label> labels = scraper.scrape();
labels.forEach(label -> label.setId(UUID.randomUUID().toString()));
if (!labels.isEmpty()) {
List<Label> oldLabels = repo.findAll();
log.info("Replacing {} old labels with {} new ones", oldLabels.size(), labels.size());
repo.delete(oldLabels);
repo.save(labels);
log.info("Finished label update");
} else {
log.info("No labels found");
}
}
UserService.java 文件源码
项目:qualitoast
阅读 24
收藏 0
点赞 0
评论 0
/**
* Persistent Token are used for providing automatic authentication, they should be automatically deleted after
* 30 days.
* <p>
* This is scheduled to get fired everyday, at midnight.
*/
@Scheduled(cron = "0 0 0 * * ?")
public void removeOldPersistentTokens() {
LocalDate now = LocalDate.now();
persistentTokenRepository.findByTokenDateBefore(now.minusMonths(1)).forEach(token -> {
log.debug("Deleting token {}", token.getSeries());
User user = token.getUser();
user.getPersistentTokens().remove(token);
persistentTokenRepository.delete(token);
});
}
ScheduledTask.java 文件源码
项目:AngularAndSpring
阅读 18
收藏 0
点赞 0
评论 0
@Scheduled(fixedRate = 60000,initialDelay=42000)
public void insertBitfinexQuoteLTCUSD() throws InterruptedException {
Date start = new Date();
WebClient wc = buildWebClient(URLBF);
try {
operations.insert(wc.get().uri("/v1/pubticker/ltcusd").accept(MediaType.APPLICATION_JSON).exchange()
.flatMap(response -> response.bodyToMono(QuoteBf.class)).map(res -> {res.setPair("ltcusd"); log.info(res.toString()); return res;})).then().block(Duration.ofSeconds(3));
log.info("BitfinexQuote Ltc Usd " + dateFormat.format(new Date()) + " " + (new Date().getTime()-start.getTime()) + "ms");
} catch (Exception e) {
// log.error("Bitstamp insert error", e);
log.error("Bitfinex Ltc insert error Usd "+ dateFormat.format(new Date()));
}
}
InMemoryThrottledSubmissionCleaner.java 文件源码
项目:cas-5.1.0
阅读 18
收藏 0
点赞 0
评论 0
/**
* Kicks off the job that attempts to clean the throttling submission record history.
*/
@Override
@Scheduled(initialDelayString = "${cas.authn.throttle.startDelay:PT10S}",
fixedDelayString = "${cas.authn.throttle.repeatInterval:PT15S}")
public void run() {
this.throttlingAdapter.decrement();
}