Search in sources :

Example 1 with NetComClientProxy

use of com.xxl.job.core.rpc.netcom.NetComClientProxy in project xxl-job by xuxueli.

the class XxlJobDynamicScheduler method getExecutorBiz.

public static ExecutorBiz getExecutorBiz(String address) throws Exception {
    // valid
    if (address == null || address.trim().length() == 0) {
        return null;
    }
    // load-cache
    address = address.trim();
    ExecutorBiz executorBiz = executorBizRepository.get(address);
    if (executorBiz != null) {
        return executorBiz;
    }
    // set-cache
    executorBiz = (ExecutorBiz) new NetComClientProxy(ExecutorBiz.class, address, accessToken).getObject();
    executorBizRepository.put(address, executorBiz);
    return executorBiz;
}
Also used : ExecutorBiz(com.xxl.job.core.biz.ExecutorBiz) NetComClientProxy(com.xxl.job.core.rpc.netcom.NetComClientProxy)

Example 2 with NetComClientProxy

use of com.xxl.job.core.rpc.netcom.NetComClientProxy in project xxl-job by xuxueli.

the class AdminBizTest method registryTest.

/**
 * registry executor
 *
 * @throws Exception
 */
@Test
public void registryTest() throws Exception {
    AdminBiz adminBiz = (AdminBiz) new NetComClientProxy(AdminBiz.class, addressUrl, accessToken).getObject();
    // test executor registry
    RegistryParam registryParam = new RegistryParam(RegistryConfig.RegistType.EXECUTOR.name(), "xxl-job-executor-example", "127.0.0.1:9999");
    ReturnT<String> returnT = adminBiz.registry(registryParam);
    Assert.assertTrue(returnT.getCode() == ReturnT.SUCCESS_CODE);
}
Also used : AdminBiz(com.xxl.job.core.biz.AdminBiz) NetComClientProxy(com.xxl.job.core.rpc.netcom.NetComClientProxy) RegistryParam(com.xxl.job.core.biz.model.RegistryParam) Test(org.junit.Test)

Example 3 with NetComClientProxy

use of com.xxl.job.core.rpc.netcom.NetComClientProxy in project xxl-job by xuxueli.

the class DemoJobHandlerTest method main.

public static void main(String[] args) throws Exception {
    // param
    String jobHandler = "demoJobHandler";
    String params = "";
    // trigger data
    TriggerParam triggerParam = new TriggerParam();
    triggerParam.setJobId(1);
    triggerParam.setExecutorHandler(jobHandler);
    triggerParam.setExecutorParams(params);
    triggerParam.setExecutorBlockStrategy(ExecutorBlockStrategyEnum.COVER_EARLY.name());
    triggerParam.setGlueType(GlueTypeEnum.BEAN.name());
    triggerParam.setGlueSource(null);
    triggerParam.setGlueUpdatetime(System.currentTimeMillis());
    triggerParam.setLogId(1);
    triggerParam.setLogDateTim(System.currentTimeMillis());
    // do remote trigger
    String accessToken = null;
    ExecutorBiz executorBiz = (ExecutorBiz) new NetComClientProxy(ExecutorBiz.class, "127.0.0.1:9999", null).getObject();
    ReturnT<String> runResult = executorBiz.run(triggerParam);
}
Also used : TriggerParam(com.xxl.job.core.biz.model.TriggerParam) ExecutorBiz(com.xxl.job.core.biz.ExecutorBiz) NetComClientProxy(com.xxl.job.core.rpc.netcom.NetComClientProxy)

Example 4 with NetComClientProxy

use of com.xxl.job.core.rpc.netcom.NetComClientProxy in project xxl-job by xuxueli.

the class AdminBizTest method registryRemove.

/**
 * registry executor remove
 *
 * @throws Exception
 */
@Test
public void registryRemove() throws Exception {
    AdminBiz adminBiz = (AdminBiz) new NetComClientProxy(AdminBiz.class, addressUrl, accessToken).getObject();
    // test executor registry remove
    RegistryParam registryParam = new RegistryParam(RegistryConfig.RegistType.EXECUTOR.name(), "xxl-job-executor-example", "127.0.0.1:9999");
    ReturnT<String> returnT = adminBiz.registryRemove(registryParam);
    Assert.assertTrue(returnT.getCode() == ReturnT.SUCCESS_CODE);
}
Also used : AdminBiz(com.xxl.job.core.biz.AdminBiz) NetComClientProxy(com.xxl.job.core.rpc.netcom.NetComClientProxy) RegistryParam(com.xxl.job.core.biz.model.RegistryParam) Test(org.junit.Test)

Example 5 with NetComClientProxy

use of com.xxl.job.core.rpc.netcom.NetComClientProxy in project xxl-job by xuxueli.

the class AdminBizTest method triggerJob.

/**
 * trigger job for once
 *
 * @throws Exception
 */
@Test
public void triggerJob() throws Exception {
    AdminBiz adminBiz = (AdminBiz) new NetComClientProxy(AdminBiz.class, addressUrl, accessToken).getObject();
    int jobId = 1;
    ReturnT<String> returnT = adminBiz.triggerJob(jobId);
    Assert.assertTrue(returnT.getCode() == ReturnT.SUCCESS_CODE);
}
Also used : AdminBiz(com.xxl.job.core.biz.AdminBiz) NetComClientProxy(com.xxl.job.core.rpc.netcom.NetComClientProxy) Test(org.junit.Test)

Aggregations

NetComClientProxy (com.xxl.job.core.rpc.netcom.NetComClientProxy)6 AdminBiz (com.xxl.job.core.biz.AdminBiz)4 Test (org.junit.Test)3 ExecutorBiz (com.xxl.job.core.biz.ExecutorBiz)2 RegistryParam (com.xxl.job.core.biz.model.RegistryParam)2 TriggerParam (com.xxl.job.core.biz.model.TriggerParam)1