HBase的etl初步完成

This commit is contained in:
mcy
2018-10-24 20:47:25 +08:00
parent 49caff5759
commit 30a11c75cb
10 changed files with 121 additions and 22 deletions

View File

@@ -9,7 +9,7 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.alibaba.otter</groupId>
<artifactId>launcher</artifactId>
<artifactId>client-adapter.launcher</artifactId>
<packaging>jar</packaging>
<name>canal client adapter launcher module for otter ${project.version}</name>

View File

@@ -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);
}
}

View File

@@ -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