本文整理汇总了Java中com.zuoxiaolong.niubi.job.core.helper.JsonHelper类的典型用法代码示例。如果您正苦于以下问题:Java JsonHelper类的具体用法?Java JsonHelper怎么用?Java JsonHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JsonHelper类属于com.zuoxiaolong.niubi.job.core.helper包,在下文中一共展示了JsonHelper类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import com.zuoxiaolong.niubi.job.core.helper.JsonHelper; //导入依赖的package包/类
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
JobDetail jobDetail = jobExecutionContext.getJobDetail();
Scheduler scheduler = jobExecutionContext.getScheduler();
JobDescriptor jobDescriptor = JobDataMapManager.getJobDescriptor(jobDetail);
JobParameter jobParameter = JobDataMapManager.getJobParameter(jobDetail);
JobBeanFactory jobBeanFactory = getJobBeanFactory(scheduler, jobDetail);
String jobMessageString = jobDescriptor + " JobParameter:" + JsonHelper.toJson(jobParameter);
try {
LoggerHelper.info("begin execute job : " + jobMessageString);
if (jobDescriptor.hasParameter()) {
jobDescriptor.method().invoke(jobBeanFactory.getJobBean(jobDescriptor.group()), new Object[]{jobParameter});
} else {
jobDescriptor.method().invoke(jobBeanFactory.getJobBean(jobDescriptor.group()), new Object[]{});
}
LoggerHelper.info("execute job success: " + jobMessageString);
} catch (Exception e) {
LoggerHelper.error("execute job failed: " + jobMessageString, e);
throw new NiubiException(e);
}
}
示例2: testQuartzAPI
import com.zuoxiaolong.niubi.job.core.helper.JsonHelper; //导入依赖的package包/类
public void testQuartzAPI() throws SchedulerException, InterruptedException {
Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
scheduler.start();
for (int i = 1 ; i < 10; i++) {
scheduler.scheduleJob(MockUtils.getEmptyJobDetail(String.valueOf(i)), MockUtils.getEmptyTrigger(String.valueOf(i)));
}
Thread.sleep(5000);
for (;;) {
List<JobExecutionContext> jobExecutionContexts = scheduler.getCurrentlyExecutingJobs();
for (JobExecutionContext jobExecutionContext : jobExecutionContexts) {
System.out.println(JsonHelper.toJson(jobExecutionContext.getJobDetail().getKey().getGroup()));
System.out.println(JsonHelper.toJson(jobExecutionContext.getJobDetail().getKey().getName()));
System.out.println(JsonHelper.toJson(scheduler.getTriggerState(jobExecutionContext.getTrigger().getKey())));
System.out.println("----------------------");
}
}
}
示例3: saveJob
import com.zuoxiaolong.niubi.job.core.helper.JsonHelper; //导入依赖的package包/类
@Override
public void saveJob(String group, String name, StandbyJobData.Data data) {
data.prepareOperation();
StandbyJobData standbyJobData = new StandbyJobData(PathHelper.getJobPath(getStandbyPathApi().getJobPath(), group, name), data);
standbyJobData.getData().incrementVersion();
if (checkExists(standbyJobData.getPath())) {
setData(standbyJobData.getPath(), standbyJobData.getDataBytes());
} else {
create(standbyJobData.getPath(), JsonHelper.toBytes(standbyJobData.getData()));
}
}
示例4: saveJob
import com.zuoxiaolong.niubi.job.core.helper.JsonHelper; //导入依赖的package包/类
@Override
public void saveJob(String group, String name, MasterSlaveJobData.Data data) {
data.prepareOperation();
MasterSlaveJobData masterSlaveJobData = new MasterSlaveJobData(PathHelper.getJobPath(getMasterSlavePathApi().getJobPath(), group, name), data);
masterSlaveJobData.getData().incrementVersion();
if (checkExists(masterSlaveJobData.getPath())) {
setData(masterSlaveJobData.getPath(), masterSlaveJobData.getDataBytes());
} else {
create(masterSlaveJobData.getPath(), JsonHelper.toBytes(masterSlaveJobData.getData()));
}
}
示例5: testGetChildren1
import com.zuoxiaolong.niubi.job.core.helper.JsonHelper; //导入依赖的package包/类
public void testGetChildren1() throws Exception {
CuratorFramework client = CuratorFrameworkFactory.newClient("localhost:2181,localhost:3181,localhost:4181", new ExponentialBackoffRetry(1000, 4));
client.start();
System.out.println(JsonHelper.toJson(client.getChildren().forPath("/nodecache")));
Thread.sleep(10000);
}
示例6: testDelete
import com.zuoxiaolong.niubi.job.core.helper.JsonHelper; //导入依赖的package包/类
public void testDelete() throws Exception {
CuratorFramework client = CuratorFrameworkFactory.newClient("localhost:2181,localhost:3181,localhost:4181", new ExponentialBackoffRetry(1000, 4));
client.start();
client.delete().inBackground(new BackgroundCallback() {
public void processResult(CuratorFramework curatorFramework, CuratorEvent curatorEvent) throws Exception {
System.out.println(JsonHelper.toJson(curatorEvent));
}
}).forPath("/curd-test/delete");
Thread.sleep(10000);
}
示例7: AbstractGenericData
import com.zuoxiaolong.niubi.job.core.helper.JsonHelper; //导入依赖的package包/类
public AbstractGenericData(String path, byte[] bytes) {
this.path = path;
this.id = PathHelper.getEndPath(this.path);
this.data = JsonHelper.fromJson(bytes, getGenericType());
}
示例8: getDataBytes
import com.zuoxiaolong.niubi.job.core.helper.JsonHelper; //导入依赖的package包/类
public byte[] getDataBytes() {
return JsonHelper.toBytes(data);
}
示例9: toString
import com.zuoxiaolong.niubi.job.core.helper.JsonHelper; //导入依赖的package包/类
@Override
public String toString() {
return "GenericData{" +
"data=" + JsonHelper.toJson(data) +
'}';
}