Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions consilens-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,20 @@ consilens <command> [options]
```yaml
source:
type: mysql
url: jdbc:mysql://localhost:3306/source_db
username: user1
password: password1
connection:
url: jdbc:mysql://localhost:3306/source_db
username: user1
password: password1
resource:
type: table
name: orders

target:
type: postgresql
url: jdbc:postgresql://localhost:5432/target_db?currentSchema=public
username: user2
password: password2
connection:
url: jdbc:postgresql://localhost:5432/target_db?currentSchema=public
username: user2
password: password2
resource:
type: table
name: orders
Expand Down Expand Up @@ -154,18 +156,20 @@ result:
```yaml
source:
type: mysql
url: jdbc:mysql://localhost:3306/database1?useSSL=false&serverTimezone=UTC
username: user1
password: password1
connection:
url: jdbc:mysql://localhost:3306/database1?useSSL=false&serverTimezone=UTC
username: user1
password: password1
resource:
type: table
name: users

target:
type: postgresql
url: jdbc:postgresql://localhost:5432/database2?currentSchema=public&ssl=false&ApplicationName=consilens
username: user2
password: password2
connection:
url: jdbc:postgresql://localhost:5432/database2?currentSchema=public&ssl=false&ApplicationName=consilens
username: user2
password: password2
resource:
type: sql
path: |
Expand Down Expand Up @@ -194,6 +198,7 @@ comparison:
- updated_at
filters:
source: "status = 'active'"
target: "status = 'active'"

strategy:
mode: checksum
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ private void printVerboseDetails(ConfigurationManager configurationManager, Stri
System.out.println(" Source fields: " + nvl(config.getComparison().getFields().getSource()));
System.out.println(" Target fields: " + nvl(config.getComparison().getFields().getTarget()));
}
if (config.getComparison().getWhere() != null) {
System.out.println(" Source where : " + nvl(config.getComparison().getWhere().getSource()));
System.out.println(" Target where : " + nvl(config.getComparison().getWhere().getTarget()));
if (config.getComparison().getFilters() != null) {
System.out.println(" Source filters: " + nvl(config.getComparison().getFilters().getSource()));
System.out.println(" Target filters: " + nvl(config.getComparison().getFilters().getTarget()));
}
}

Expand Down Expand Up @@ -208,9 +208,9 @@ private String describeResource(com.consilens.cli.model.ConnectionConfig connect
return "(not set)";
}
com.consilens.cli.model.ConnectionConfig.ResourceConfig resource = connectionConfig.getResource();
String location = resource.getName() != null && !resource.getName().isBlank()
? resource.getName()
: resource.getPath();
String location = "sql".equalsIgnoreCase(resource.getType())
? resource.getPath()
: resource.getName();
return nvl(resource.getType()) + ":" + nvl(location);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.consilens.cli.model.CliConfiguration;
import com.consilens.cli.model.CliDiffResult;
import com.consilens.cli.service.DiffService;
import com.consilens.cli.service.RealtimeCompareRunner;

import lombok.extern.slf4j.Slf4j;
import picocli.CommandLine.Command;
Expand Down Expand Up @@ -66,9 +65,6 @@ public void run() {
if (dryRun) {
log.info("Performing dry run (validation only)...");
result = diffService.performDryRun(config);
} else if (config.getRealtime() != null && Boolean.TRUE.equals(config.getRealtime().getEnabled())) {
log.info("Starting realtime long-running compare loop...");
result = new RealtimeCompareRunner().runLoop(config);
} else {
log.info("Starting diff operation...");
log.info("This may take a while depending on table sizes and strategy chosen.");
Expand Down Expand Up @@ -124,9 +120,9 @@ private String resourceDisplay(com.consilens.cli.model.ConnectionConfig connecti
return "(not set)";
}
com.consilens.cli.model.ConnectionConfig.ResourceConfig resource = connectionConfig.getResource();
String location = resource.getName() != null && !resource.getName().isBlank()
? resource.getName()
: resource.getPath();
String location = "sql".equalsIgnoreCase(resource.getType())
? resource.getPath()
: resource.getName();
return resource.getType() + ":" + location;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ public class CliConfiguration {
@JsonProperty("normalization")
private NormalizationConfig normalization;

@JsonProperty("realtime")
private RealtimeConfig realtime;

@JsonProperty("result")
private ResultConfig result;

Expand Down Expand Up @@ -271,10 +268,6 @@ public void validate() throws ValidationException {
if (normalization != null) {
normalization.validate();
}
if (realtime != null) {
realtime.validate("realtime");
}

validateResultSinks();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ public class CompareMappingConfig {
@JsonProperty("name")
private String name;

@JsonProperty("type")
private String type;

@JsonProperty("source")
private FieldExpressionConfig source;

Expand All @@ -31,7 +28,4 @@ public class CompareMappingConfig {

@JsonProperty("compare")
private Boolean compare;

@JsonProperty("ordinal")
private Integer ordinal;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.consilens.core.validation.ValidationException;
import com.consilens.core.validation.ValidationFramework;
import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
Expand Down Expand Up @@ -42,12 +41,8 @@ public class ComparisonConfig {
private List<String> extraColumns;

@JsonProperty("filters")
@JsonAlias("where")
private StringPairConfig filters;

@JsonProperty("updateColumn")
private String updateColumn;

public void validate() throws ValidationException {
ValidationFramework.forContext("comparison")
.validate(keys, "comparison.keys", Objects::nonNull, "comparison.keys 配置不能为空")
Expand Down Expand Up @@ -87,14 +82,6 @@ public void validate() throws ValidationException {
}
}

public StringPairConfig getWhere() {
return filters;
}

public void setWhere(StringPairConfig where) {
this.filters = where;
}

private void validateMappings() {
if (mappings == null || mappings.isEmpty()) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,6 @@ public class ConnectionConfig {
@JsonProperty("name")
private String name;

@JsonProperty("url")
private String url;

@JsonProperty("username")
private String username;

@JsonProperty("password")
private String password;

@JsonProperty("connection")
private ConnectorConnectionProperties connection;

Expand All @@ -57,30 +48,21 @@ public Map<String, Object> toConnectionMap() {
if (connection != null) {
result.putAll(connection.asMap());
}
putIfPresent(result, "url", url);
putIfPresent(result, "username", username);
putIfPresent(result, "password", password);
return result;
}

@JsonIgnore
public String getUrl() {
if (url != null && !url.trim().isEmpty()) {
return url;
}
return connection != null ? connection.getUrl() : null;
}

@JsonIgnore
public String getUsername() {
if (username != null && !username.trim().isEmpty()) {
return username;
}
return connection != null ? connection.getUsername() : null;
}

@JsonIgnore
public String getPassword() {
if (password != null && !password.trim().isEmpty()) {
return password;
}
return connection != null ? connection.getPassword() : null;
}

Expand All @@ -94,9 +76,9 @@ public void validate(String fieldName) throws ValidationException {

if (requiresJdbcValidation()) {
ValidationFramework.forContext(fieldName)
.notEmpty(getUrl(), fieldName + ".url")
.validJdbcUrl(getUrl(), fieldName + ".url")
.notEmpty(getUsername(), fieldName + ".username")
.notEmpty(getUrl(), fieldName + ".connection.url")
.validJdbcUrl(getUrl(), fieldName + ".connection.url")
.notEmpty(getUsername(), fieldName + ".connection.username")
.throwIfInvalid();
return;
}
Expand Down Expand Up @@ -131,12 +113,6 @@ private boolean requiresJdbcValidation() {
}
}

private void putIfPresent(Map<String, Object> result, String key, String value) {
if (value != null && !value.trim().isEmpty()) {
result.put(key, value);
}
}

@Data
@Builder
@NoArgsConstructor
Expand Down Expand Up @@ -222,9 +198,13 @@ public void validate(String fieldName) throws ValidationException {
String normalizedType = type.trim().toLowerCase(Locale.ROOT);
switch (normalizedType) {
case "table":
if (isBlank(name) && isBlank(path)) {
if (isBlank(name)) {
throw ValidationException.simple("CONFIGURATION_VALIDATION",
fieldName + " type=table 时必须配置 name");
}
if (!isBlank(path)) {
throw ValidationException.simple("CONFIGURATION_VALIDATION",
fieldName + " type=table 时必须配置 name 或 path");
fieldName + " type=table 时不应配置 path");
}
break;
case "sql":
Expand Down
Loading
Loading