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-7404][Agent] Fix error of Redis connector #7405

Merged
merged 2 commits into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public class JobProfileDto {
* oracle source
*/
public static final String ORACLE_SOURCE = "org.apache.inlong.agent.plugin.sources.OracleSource";
/**
* redis source
*/
public static final String REDIS_SOURCE = "org.apache.inlong.agent.plugin.sources.RedisSource";
/**
* mqtt source
*/
Expand Down Expand Up @@ -215,6 +219,22 @@ private static PostgreSQLJob getPostgresJob(DataConfig dataConfigs) {
return postgreSQLJob;
}

private static RedisJob getRedisJob(DataConfig dataConfig) {
RedisJob.RedisJobConfig config = GSON.fromJson(dataConfig.getExtParams(), RedisJob.RedisJobConfig.class);
RedisJob redisJob = new RedisJob();

redisJob.setAuthUser(config.getUsername());
redisJob.setAuthPassword(config.getPassword());
redisJob.setHostname(config.getHostname());
redisJob.setPort(config.getPort());
redisJob.setSsl(config.getSsl());
redisJob.setReadTimeout(config.getTimeout());
redisJob.setQueueSize(config.getQueueSize());
redisJob.setReplId(config.getReplId());

return redisJob;
}

private static MongoJob getMongoJob(DataConfig dataConfigs) {

MongoJob.MongoJobTaskConfig config = GSON.fromJson(dataConfigs.getExtParams(),
Expand Down Expand Up @@ -440,6 +460,12 @@ public static TriggerProfile convertToTriggerProfile(DataConfig dataConfig) {
job.setSource(MONGO_SOURCE);
profileDto.setJob(job);
break;
case REDIS:
RedisJob redisJob = getRedisJob(dataConfig);
job.setRedisJob(redisJob);
job.setSource(REDIS_SOURCE);
profileDto.setJob(job);
break;
case MQTT:
MqttJob mqttJob = getMqttJob(dataConfig);
job.setMqttJob(mqttJob);
Expand Down Expand Up @@ -481,6 +507,7 @@ public static class Job {
private PostgreSQLJob postgreSQLJob;
private OracleJob oracleJob;
private MongoJob mongoJob;
private RedisJob redisJob;
private MqttJob mqttJob;
private SqlServerJob sqlserverJob;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* 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.pojo;

import lombok.Data;

@Data
public class RedisJob {

private String authUser;
private String authPassword;
private String hostname;
private String port;
private Boolean ssl;
private String readTimeout;
private String queueSize;
private String replId;

@Data
public static class RedisJobConfig {

private String username;
private String password;
private String hostname;
private String port;
private Boolean ssl;
private String timeout;
private String queueSize;
private String replId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public RedisSource() {
@Override
public List<Reader> split(JobProfile conf) {
super.init(conf);
Reader redisReader = new RedisReader();
RedisReader redisReader = new RedisReader();
redisReader.setReadSource(conf.getInstanceId());
List<Reader> readerList = new ArrayList<>();
readerList.add(redisReader);
sourceMetric.sourceSuccessCount.incrementAndGet();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ public String getReadSource() {
return instanceId;
}

public void setReadSource(String instanceId) {
this.instanceId = instanceId;
}

@Override
public void setReadTimeout(long mill) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ public static TaskTypeEnum getTaskType(int taskType) {
return MONGODB;
case 10:
return TUBEMQ;
case 11:
return REDIS;
case 12:
return MQTT;
case 13:
Expand Down