-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[Feature][Connector V2] expose configurable options in Cassandra #3681
Merged
Merged
Changes from 4 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
f301720
[Feature][Connector V2]add Cassandra Option Rule
cason0126 09dda07
[Feature][Connector V2] Cassandra Confing expose
cason0126 2cb3e23
[Feature] #3663
cason0126 5ef5922
Merge branch 'dev' into options_cassandra
cason0126 7ad1bea
Merge branch 'apache:dev' into options_cassandra
cason0126 a958863
[Feature][expose configurable options] move else branch for default v…
cason0126 98730d5
fix Sink Doc About batch_type Default Value ;
cason0126 0bbf529
Merge branch 'apache:dev' into options_cassandra
cason0126 9b42fe0
add Cassandra SourceGetSource;
cason0126 3d65776
bundled USERNAME and PASSWORD
cason0126 16dd31d
Merge branch 'dev' into options_cassandra
cason0126 2bbaa29
fix spotless
cason0126 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
.../java/org/apache/seatunnel/connectors/seatunnel/cassandra/config/CassandraParameters.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* | ||
* 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.seatunnel.connectors.seatunnel.cassandra.config; | ||
|
||
import org.apache.seatunnel.shade.com.typesafe.config.Config; | ||
|
||
import com.datastax.oss.driver.api.core.ConsistencyLevel; | ||
import com.datastax.oss.driver.api.core.DefaultConsistencyLevel; | ||
import com.datastax.oss.driver.api.core.cql.DefaultBatchType; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
import java.io.Serializable; | ||
import java.util.List; | ||
|
||
@Setter | ||
@Getter | ||
public class CassandraParameters implements Serializable { | ||
private String host; | ||
private String username; | ||
private String password; | ||
private String datacenter; | ||
private String keyspace; | ||
private String table; | ||
private String cql; | ||
private List<String> fields; | ||
private ConsistencyLevel consistencyLevel; | ||
private Integer batchSize; | ||
private DefaultBatchType batchType; | ||
private Boolean asyncWrite; | ||
|
||
public void buildWithConfig(Config config) { | ||
this.host = config.getString(CassandraConfig.HOST.key()); | ||
this.keyspace = config.getString(CassandraConfig.KEYSPACE.key()); | ||
|
||
if (config.hasPath(CassandraConfig.USERNAME.key())) { | ||
this.username = config.getString(CassandraConfig.USERNAME.key()); | ||
} | ||
if (config.hasPath(CassandraConfig.PASSWORD.key())) { | ||
this.password = config.getString(CassandraConfig.PASSWORD.key()); | ||
} | ||
if (config.hasPath(CassandraConfig.DATACENTER.key())) { | ||
this.datacenter = config.getString(CassandraConfig.DATACENTER.key()); | ||
} else { | ||
this.datacenter = CassandraConfig.DATACENTER.defaultValue(); | ||
} | ||
if (config.hasPath(CassandraConfig.TABLE.key())) { | ||
this.table = config.getString(CassandraConfig.TABLE.key()); | ||
} | ||
if (config.hasPath(CassandraConfig.CQL.key())) { | ||
this.cql = config.getString(CassandraConfig.CQL.key()); | ||
} | ||
if (config.hasPath(CassandraConfig.FIELDS.key())) { | ||
this.fields = config.getStringList(CassandraConfig.FIELDS.key()); | ||
} | ||
if (config.hasPath(CassandraConfig.CONSISTENCY_LEVEL.key())) { | ||
this.consistencyLevel = DefaultConsistencyLevel.valueOf(config.getString(CassandraConfig.CONSISTENCY_LEVEL.key())); | ||
} else { | ||
this.consistencyLevel = DefaultConsistencyLevel.valueOf(CassandraConfig.CONSISTENCY_LEVEL.defaultValue()); | ||
} | ||
if (config.hasPath(CassandraConfig.BATCH_SIZE.key())) { | ||
this.batchSize = config.getInt(CassandraConfig.BATCH_SIZE.key()); | ||
} else { | ||
this.batchSize = CassandraConfig.BATCH_SIZE.defaultValue(); | ||
} | ||
if (config.hasPath(CassandraConfig.BATCH_TYPE.key())) { | ||
this.batchType = DefaultBatchType.valueOf(config.getString(CassandraConfig.BATCH_TYPE.key())); | ||
} else { | ||
this.batchType = DefaultBatchType.valueOf(CassandraConfig.BATCH_TYPE.defaultValue()); | ||
} | ||
if (config.hasPath(CassandraConfig.ASYNC_WRITE.key())) { | ||
this.asyncWrite = config.getBoolean(CassandraConfig.ASYNC_WRITE.key()); | ||
} else { | ||
this.asyncWrite = true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default value is assigned when the variable is declared. So we can get rid of the else branch. |
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I was refered to the writing of Redis.
Is this necessary at this stage?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only suggested, not required.