Search in sources :

Example 1 with RpcServiceReference

use of com.tis.hadoop.rpc.RpcServiceReference in project plugins by qlangtech.

the class TestDistributedOverseerDataXJobSubmit method testPushMsgToDistributeQueue.

public void testPushMsgToDistributeQueue() {
    DataXJobWorker dataxJobWorker = DataXJobWorker.getJobWorker(DataXJobWorker.K8S_DATAX_INSTANCE_NAME);
    assertEquals("/datax/jobs", dataxJobWorker.getZkQueuePath());
    assertEquals("192.168.28.200:2181/tis/cloud", dataxJobWorker.getZookeeperAddress());
    DataxProcessor dataxProcessor = IAppSource.load(DATAX_NAME);
    assertNotNull(dataxProcessor);
    // IDataxProcessor dataxProcessor = EasyMock.createMock("dataxProcessor", IDataxProcessor.class);
    // EasyMock.expect(dataxProcessor.getDataxCfgDir()).andReturn();
    IJoinTaskContext taskContext = EasyMock.createMock("joinTaskContext", IJoinTaskContext.class);
    EasyMock.expect(taskContext.getIndexName()).andReturn(DATAX_NAME);
    EasyMock.expect(taskContext.getTaskId()).andReturn(DATAX_TASK_ID);
    AtomicReference<ITISRpcService> ref = new AtomicReference<>();
    ref.set(StatusRpcClient.AssembleSvcCompsite.MOCK_PRC);
    RpcServiceReference svcRef = new RpcServiceReference(ref);
    Optional<DataXJobSubmit> jobSubmit = DataXJobSubmit.getDataXJobSubmit(DataXJobSubmit.InstanceType.DISTRIBUTE);
    assertTrue(jobSubmit.isPresent());
    DataXJobSubmit submit = jobSubmit.get();
    DataXJobSubmit.IDataXJobContext jobContext = submit.createJobContext(taskContext);
    EasyMock.replay(taskContext);
    // IJoinTaskContext taskContext
    // , RpcServiceReference statusRpc, IDataxProcessor dataxProcessor, String dataXfileName
    IRemoteTaskTrigger dataXJob = submit.createDataXJob(jobContext, svcRef, dataxProcessor, DATAX_JOB_FILE_NAME);
    dataXJob.run();
    EasyMock.verify(taskContext);
}
Also used : DataxProcessor(com.qlangtech.tis.datax.impl.DataxProcessor) DataXJobWorker(com.qlangtech.tis.datax.job.DataXJobWorker) DataXJobSubmit(com.qlangtech.tis.datax.DataXJobSubmit) IRemoteTaskTrigger(com.qlangtech.tis.fullbuild.indexbuild.IRemoteTaskTrigger) ITISRpcService(com.tis.hadoop.rpc.ITISRpcService) AtomicReference(java.util.concurrent.atomic.AtomicReference) IJoinTaskContext(com.qlangtech.tis.order.center.IJoinTaskContext) RpcServiceReference(com.tis.hadoop.rpc.RpcServiceReference)

Example 2 with RpcServiceReference

use of com.tis.hadoop.rpc.RpcServiceReference in project tis by qlangtech.

the class DataXExecuteInterceptor method getDataXExecReporter.

protected RpcServiceReference getDataXExecReporter() {
    IncrStatusUmbilicalProtocolImpl statusServer = IncrStatusUmbilicalProtocolImpl.getInstance();
    IncrStatusUmbilicalProtocol statReceiveSvc = new AdapterStatusUmbilicalProtocol() {

        @Override
        public void reportDumpTableStatus(DumpPhaseStatus.TableDumpStatus tableDumpStatus) {
            statusServer.reportDumpTableStatus(tableDumpStatus.getTaskid(), tableDumpStatus.isComplete(), tableDumpStatus.isWaiting(), tableDumpStatus.isFaild(), tableDumpStatus.getName());
        }
    };
    AtomicReference<ITISRpcService> ref = new AtomicReference<>();
    ref.set(new DataXAssembleSvcCompsite(statReceiveSvc));
    return new RpcServiceReference(ref);
}
Also used : IncrStatusUmbilicalProtocolImpl(com.qlangtech.tis.rpc.server.IncrStatusUmbilicalProtocolImpl) IncrStatusUmbilicalProtocol(com.qlangtech.tis.realtime.yarn.rpc.IncrStatusUmbilicalProtocol) ITISRpcService(com.tis.hadoop.rpc.ITISRpcService) AtomicReference(java.util.concurrent.atomic.AtomicReference) RpcServiceReference(com.tis.hadoop.rpc.RpcServiceReference) AdapterStatusUmbilicalProtocol(com.qlangtech.tis.realtime.yarn.rpc.impl.AdapterStatusUmbilicalProtocol)

Example 3 with RpcServiceReference

use of com.tis.hadoop.rpc.RpcServiceReference in project tis by qlangtech.

the class DataxExecutor method main.

/**
 * 入口开始执行
 *
 * @param args
 */
public static void main(String[] args) throws Exception {
    if (args.length != 7) {
        throw new IllegalArgumentException("args length must be 7,but now is " + args.length);
    }
    Integer jobId = Integer.parseInt(args[0]);
    String jobName = args[1];
    String dataXName = args[2];
    String incrStateCollectAddress = args[3];
    DataXJobSubmit.InstanceType execMode = DataXJobSubmit.InstanceType.parse(args[4]);
    final int allRows = Integer.parseInt(args[5]);
    // 任务每次执行会生成一个时间戳
    final String execTimeStamp = args[6];
    MDC.put(IParamContext.KEY_TASK_ID, String.valueOf(jobId));
    MDC.put(TISCollectionUtils.KEY_COLLECTION, dataXName);
    if (StringUtils.isEmpty(jobName)) {
        throw new IllegalArgumentException("arg 'jobName' can not be null");
    }
    if (StringUtils.isEmpty(dataXName)) {
        throw new IllegalArgumentException("arg 'dataXName' can not be null");
    }
    if (StringUtils.isEmpty(incrStateCollectAddress)) {
        throw new IllegalArgumentException("arg 'incrStateCollectAddress' can not be null");
    }
    StatusRpcClient.AssembleSvcCompsite statusRpc = StatusRpcClient.connect2RemoteIncrStatusServer(incrStateCollectAddress);
    Runtime.getRuntime().addShutdownHook(new Thread("dataX ShutdownHook") {

        @Override
        public void run() {
            statusRpc.close();
            // if (flumeAppendEnable) {
            com.qlangtech.tis.datax.log.TisFlumeLogstashV1Appender.instance.stop();
        // }
        }
    });
    DataxExecutor dataxExecutor = new DataxExecutor(new RpcServiceReference(new AtomicReference<>(statusRpc)), execMode, allRows);
    if (execMode == DataXJobSubmit.InstanceType.DISTRIBUTE) {
        // 如果是分布式执行状态,需要通过RPC的方式来监听监工是否执行了客户端终止操作
        Object thread = monitorDistributeCommand(jobId, jobName, dataXName, statusRpc, dataxExecutor);
        Objects.requireNonNull(thread);
    }
    try {
        dataxExecutor.reportDataXJobStatus(false, false, false, jobId, jobName);
        dataxExecutor.exec(jobId, jobName, dataXName, execTimeStamp);
        dataxExecutor.reportDataXJobStatus(false, jobId, jobName);
    } catch (Throwable e) {
        dataxExecutor.reportDataXJobStatus(true, jobId, jobName);
        logger.error(e.getMessage(), e);
        try {
            // 确保日志向远端写入了
            Thread.sleep(3000);
        } catch (InterruptedException ex) {
        }
        System.exit(1);
    }
    logger.info("dataX:" + dataXName + ",taskid:" + jobId + " finished");
    System.exit(0);
}
Also used : StatusRpcClient(com.tis.hadoop.rpc.StatusRpcClient) AtomicReference(java.util.concurrent.atomic.AtomicReference) RpcServiceReference(com.tis.hadoop.rpc.RpcServiceReference)

Example 4 with RpcServiceReference

use of com.tis.hadoop.rpc.RpcServiceReference in project tis by qlangtech.

the class BasicDataXExecutorTestCase method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    System.clearProperty(Config.DEFAULT_DATA_DIR);
    setDataDir();
    PluginStubUtils.setTISField();
    AtomicReference<ITISRpcService> ref = new AtomicReference<>();
    ref.set(StatusRpcClient.AssembleSvcCompsite.MOCK_PRC);
    statusRpc = new RpcServiceReference(ref);
    executor = createExecutor();
}
Also used : ITISRpcService(com.tis.hadoop.rpc.ITISRpcService) AtomicReference(java.util.concurrent.atomic.AtomicReference) RpcServiceReference(com.tis.hadoop.rpc.RpcServiceReference)

Example 5 with RpcServiceReference

use of com.tis.hadoop.rpc.RpcServiceReference in project plugins by qlangtech.

the class LocalTableDumpFactory method triggerTask.

public static IRemoteJobTrigger triggerTask(TaskContext context, ILocalTask task) {
    TisZkClient zk = context.getCoordinator().unwrap();
    Objects.requireNonNull(zk, "zk(TisZkClient) can not be null");
    AtomicReference<Throwable> errRef = new AtomicReference<>();
    CountDownLatch countDown = new CountDownLatch(1);
    final ExecutorService executor = Executors.newSingleThreadExecutor((r) -> {
        Thread t = new Thread(r);
        t.setUncaughtExceptionHandler((thread, e) -> {
            errRef.set(e);
            logger.error(e.getMessage(), e);
            countDown.countDown();
        });
        return t;
    });
    return new IRemoteJobTrigger() {

        @Override
        public void submitJob() {
            executor.execute(() -> {
                RpcServiceReference statusRpc = null;
                try {
                    statusRpc = StatusRpcClient.getService(zk);
                    task.process(statusRpc);
                    countDown.countDown();
                } catch (Exception e) {
                    throw new RuntimeException(e);
                } finally {
                    try {
                        statusRpc.get().close();
                    } catch (Throwable e) {
                    }
                }
            });
        }

        @Override
        public RunningStatus getRunningStatus() {
            RunningStatus runningStatus = null;
            // 反馈执行状态
            if (countDown.getCount() > 0) {
                runningStatus = new RunningStatus(0, false, false);
            } else {
                executor.shutdown();
                runningStatus = new RunningStatus(1, true, errRef.get() == null);
            }
            return runningStatus;
        }
    };
}
Also used : IRemoteJobTrigger(com.qlangtech.tis.fullbuild.indexbuild.IRemoteJobTrigger) RunningStatus(com.qlangtech.tis.fullbuild.indexbuild.RunningStatus) ExecutorService(java.util.concurrent.ExecutorService) AtomicReference(java.util.concurrent.atomic.AtomicReference) RpcServiceReference(com.tis.hadoop.rpc.RpcServiceReference) CountDownLatch(java.util.concurrent.CountDownLatch) TisZkClient(com.qlangtech.tis.TisZkClient) IOException(java.io.IOException)

Aggregations

RpcServiceReference (com.tis.hadoop.rpc.RpcServiceReference)7 AtomicReference (java.util.concurrent.atomic.AtomicReference)7 ITISRpcService (com.tis.hadoop.rpc.ITISRpcService)5 DataXJobSubmit (com.qlangtech.tis.datax.DataXJobSubmit)3 IRemoteTaskTrigger (com.qlangtech.tis.fullbuild.indexbuild.IRemoteTaskTrigger)3 RunningStatus (com.qlangtech.tis.fullbuild.indexbuild.RunningStatus)3 TisZkClient (com.qlangtech.tis.TisZkClient)2 DataxProcessor (com.qlangtech.tis.datax.impl.DataxProcessor)2 IExecChainContext (com.qlangtech.tis.exec.IExecChainContext)2 DumpPhaseStatus (com.qlangtech.tis.fullbuild.phasestatus.impl.DumpPhaseStatus)2 IncrStatusUmbilicalProtocol (com.qlangtech.tis.realtime.yarn.rpc.IncrStatusUmbilicalProtocol)2 AdapterStatusUmbilicalProtocol (com.qlangtech.tis.realtime.yarn.rpc.impl.AdapterStatusUmbilicalProtocol)2 IncrStatusUmbilicalProtocolImpl (com.qlangtech.tis.rpc.server.IncrStatusUmbilicalProtocolImpl)2 File (java.io.File)2 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 FullbuildPhase (com.qlangtech.tis.assemble.FullbuildPhase)1 IDataXBatchPost (com.qlangtech.tis.datax.IDataXBatchPost)1 IDataxProcessor (com.qlangtech.tis.datax.IDataxProcessor)1 IDataxReader (com.qlangtech.tis.datax.IDataxReader)1