mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
HBase的etl初步完成
This commit is contained in:
@@ -2,20 +2,18 @@ package com.alibaba.otter.canal.adapter.launcher.rest;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import com.alibaba.otter.canal.client.adapter.support.EtlResult;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import com.alibaba.otter.canal.client.adapter.OuterAdapter;
|
||||
import com.alibaba.otter.canal.client.adapter.support.EtlResult;
|
||||
import com.alibaba.otter.canal.client.adapter.support.ExtensionLoader;
|
||||
|
||||
@RestController
|
||||
public class EtlRest {
|
||||
public class CommonRest {
|
||||
|
||||
private ExtensionLoader<OuterAdapter> loader;
|
||||
|
||||
@@ -25,9 +23,9 @@ public class EtlRest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Demo: http://127.0.0.1:8081/etl/hbase/mytest_person2.yml
|
||||
* Demo: POST: http://127.0.0.1:8081/etl/hbase/mytest_person2.yml
|
||||
*/
|
||||
@GetMapping("/etl/{type}/{task}")
|
||||
@PostMapping("/etl/{type}/{task}")
|
||||
public EtlResult etl(@PathVariable String type, @PathVariable String task,
|
||||
@RequestParam(required = false) String params) {
|
||||
OuterAdapter adapter = loader.getExtension(type);
|
||||
@@ -37,6 +35,15 @@ public class EtlRest {
|
||||
paramArr = Arrays.asList(parmaArray);
|
||||
}
|
||||
|
||||
return adapter.etl(task, paramArr);
|
||||
return adapter.etl(task, paramArr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Demo: GET: http://127.0.0.1:8081/count/hbase/mytest_person2.yml
|
||||
*/
|
||||
@GetMapping("/count/{type}/{task}")
|
||||
public Map<String, Object> count(@PathVariable String type, @PathVariable String task) {
|
||||
OuterAdapter adapter = loader.getExtension(type);
|
||||
return adapter.count(task);
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ canal.conf:
|
||||
- instance: example
|
||||
adapterGroups:
|
||||
- outAdapters:
|
||||
# - name: logger
|
||||
- name: logger
|
||||
- name: hbase
|
||||
properties:
|
||||
hbase.zookeeper.quorum: slave1
|
||||
@@ -39,4 +39,5 @@ adapter.conf:
|
||||
username: root
|
||||
password: 121212
|
||||
adapterConfigs:
|
||||
- hbase/mytest_person2.yml
|
||||
- hbase/mytest_person2.yml
|
||||
# - hbase/mytest.person2@defaultDS
|
||||
|
||||
Reference in New Issue
Block a user