Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[INLONG-5046][Agent] Support collect data from PostgreSQL #5367

Merged
merged 19 commits into from
Aug 17, 2022
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
a0bb533
[INLONG-5046] add agent module to collect data from postgreSql
iamsee123 Aug 4, 2022
e247b57
Merge branch 'master' of https://github.com/apache/inlong into INLONG…
iamsee123 Aug 4, 2022
5de007c
[INLONG-5046] roback checkstyle.xml
iamsee123 Aug 4, 2022
d3df498
[INLONG-5046] rollback vcs.xml
iamsee123 Aug 4, 2022
bd2d7bc
Merge branch 'master' of https://github.com/apache/inlong into INLONG…
iamsee123 Aug 5, 2022
5212a2a
[INLONG-5046] fix PostgreSqlReader
iamsee123 Aug 5, 2022
27fc0bd
[INLONG-5046] fix TestPostgresReader
iamsee123 Aug 5, 2022
2d31f69
[INLONG-5046] fix License Header
iamsee123 Aug 5, 2022
c283121
[INLONG-5046] fix checkstyle problems
iamsee123 Aug 5, 2022
0f22dbf
[INLONG-5046] add third-party dependencies
iamsee123 Aug 8, 2022
e5cb6a3
[INLONG-5046] fix some problems
iamsee123 Aug 11, 2022
5bc36ec
[INLONG-5046] fix some checkstyle problems
iamsee123 Aug 11, 2022
b1f5b13
Merge branch 'master' into INLONG-5046
iamsee123 Aug 12, 2022
111cc03
[INLONG-5046] change class name and add doc to some classes
iamsee123 Aug 12, 2022
b3e7aea
[INLONG-5046] fix test case problem
iamsee123 Aug 12, 2022
a04a6d1
[INLONG-5046] adjust variables name and class name to satisfy checkst…
iamsee123 Aug 14, 2022
2fbc404
[INLONG-5046] adjust name with postgreSQL into official name postgreSQL
iamsee123 Aug 15, 2022
a50f321
[INLONG-5046] adjust name with postgres,postgreSql into official name…
iamsee123 Aug 16, 2022
6ec8d70
[INLONG-5046] adjust codeStyle to fit the requests
iamsee123 Aug 16, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.inlong.agent.constant;

/**
* Constants of job fetcher Postgressnapshot mode
*/
public class PostgresSnapshotModeConstants {
iamsee123 marked this conversation as resolved.
Show resolved Hide resolved
public static final String INITIAL = "initial";

public static final String EARLIEST_OFFSET = "never";

public static final String ALWAYS = "always";

public static final String EXPORTED = "exported";

public static final String INITIAL_ONLY = "initial_only";

public static final String CUSTOM = "custom";
}
4 changes: 4 additions & 0 deletions inlong-agent/agent-plugins/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<dependency>
<groupId>io.debezium</groupId>
<artifactId>debezium-connector-postgres</artifactId>
</dependency>
<dependency>
<artifactId>awaitility</artifactId>
<groupId>org.awaitility</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.inlong.agent.plugin.sources;

import org.apache.inlong.agent.conf.JobProfile;
import org.apache.inlong.agent.plugin.Reader;
import org.apache.inlong.agent.plugin.Source;
import org.apache.inlong.agent.plugin.sources.reader.PostgreSqlReader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;

import static org.apache.inlong.agent.constant.CommonConstants.PROXY_INLONG_GROUP_ID;
import static org.apache.inlong.agent.constant.CommonConstants.DEFAULT_PROXY_INLONG_GROUP_ID;
import static org.apache.inlong.agent.constant.CommonConstants.PROXY_INLONG_STREAM_ID;
import static org.apache.inlong.agent.constant.CommonConstants.DEFAULT_PROXY_INLONG_STREAM_ID;
import static org.apache.inlong.agent.constant.AgentConstants.GLOBAL_METRICS;

/**
* PostgreSql source, split PostgreSql source job into multi readers
*/
public class PostgreSQLSource implements Source {

private static final Logger logger = LoggerFactory.getLogger(PostgreSQLSource.class);

private static final String POSTGRESQL_SOURCE_TAG_NAME = "PostgreSqlSourceMetric";

public PostgreSQLSource() {

}

@Override
public List<Reader> split(JobProfile conf) {
String inlongGroupId = conf.get(PROXY_INLONG_GROUP_ID, DEFAULT_PROXY_INLONG_GROUP_ID);
String inlongStreamId = conf.get(PROXY_INLONG_STREAM_ID, DEFAULT_PROXY_INLONG_STREAM_ID);
String metricTagName = POSTGRESQL_SOURCE_TAG_NAME + "_" + inlongGroupId + "_" + inlongStreamId;
Reader postgreReader = new PostgreSqlReader();
List<Reader> readerList = new ArrayList<>();
readerList.add(postgreReader);
GLOBAL_METRICS.incSourceSuccessCount(metricTagName);
return readerList;
}
}
Loading