Skip to content

Instantly share code, notes, and snippets.

@hn5092
hn5092 / spring scheduler
Created December 25, 2016 09:08
如何动态的使用spring的调度,支持cron 表达式
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
CronTrigger cronTrigger = new CronTrigger("* 0/2 * * * * ");
SimpleTriggerContext triggerContext = new SimpleTriggerContext();
triggerContext.update(new Date(System.currentTimeMillis()),new Date(System.currentTimeMillis()+10),
new Date(System.currentTimeMillis()+100));
Date date = cronTrigger.nextExecutionTime(triggerContext);
System.out.println(date);
/*
* Copyright 2002-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
package com.pajk.bigdata.flink.utils;
import org.apache.hadoop.hbase.util.Bytes;
import org.testng.annotations.Test;
import org.testng.collections.Lists;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
@hn5092
hn5092 / udf_jieba.py
Created April 10, 2017 09:14
hive python udf
#coding=utf-8
import logging
import traceback
import jieba
import jieba.analyse
import redis
import sys
import os
import json
import codecs