-
Notifications
You must be signed in to change notification settings - Fork 38
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
CASSSIDECAR-211 Config APIs for storing CDC/Kafka configs for CDC feature #193
base: trunk
Are you sure you want to change the base?
Conversation
82a6c78
to
59eeaaa
Compare
client/src/main/java/org/apache/cassandra/sidecar/client/SidecarClient.java
Show resolved
Hide resolved
ObjectMapper mapper = new ObjectMapper(); | ||
response.setBody(mapper.writeValueAsString(putResponse)); | ||
enqueue(response); | ||
assertThat(client.putCdcServiceConfig(ServiceConfig.CDC, payload).get()).isEqualTo(putResponse); |
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.
Maybe we could add a test with an invalid payload (or service) to check that we are getting 400s?
server/src/main/java/org/apache/cassandra/sidecar/cdc/CdcConfig.java
Outdated
Show resolved
Hide resolved
client-common/src/main/java/org/apache/cassandra/sidecar/common/request/ServiceConfig.java
Show resolved
Hide resolved
59eeaaa
to
aa8c404
Compare
server/src/main/java/org/apache/cassandra/sidecar/cdc/CdcConfig.java
Outdated
Show resolved
Hide resolved
35cbf00
to
a42736a
Compare
client/src/main/java/org/apache/cassandra/sidecar/client/SidecarClient.java
Outdated
Show resolved
Hide resolved
Logger LOGGER = LoggerFactory.getLogger(CdcConfig.class); | ||
|
||
String DEFAULT_JOB_ID = "test-job"; | ||
int DEFAULT_MAX_WATERMARKER_SIZE = 400000; |
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.
It is generally not advised to define constants in an interface. Can you relocate them to the implementation, CdcConfigImpl
?
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.
The constant is used in the interface for default value and relocation to implementation will now work in this case
server/src/main/java/org/apache/cassandra/sidecar/cdc/CdcConfig.java
Outdated
Show resolved
Hide resolved
private static final String CDC_CONFIG_DC_KEY = "dc"; | ||
private static final String CDC_CONFIG_LOG_ONLY_KEY = "log_only"; | ||
private static final String CDC_CONFIG_PERSIST_STATE_KEY = "persist_state"; | ||
private static final String CDC_CONFIG_ENV_KEY = "env"; | ||
private static final String KAFKA_CONFIG_TOPIC_KEY = "topic"; | ||
private static final String KAFKA_FORMAT_TYPE_CONFIG_TOPIC_KEY = "topic_format_type"; | ||
private static final String CDC_ENABLED_KEY = "cdc_enabled"; | ||
private static final String KAFKA_CONFIG_JOB_ID_KEY = "jobId"; | ||
private static final String WATERMARK_WINDOW_KEY = "watermark_seconds"; | ||
private static final String MICROBATCH_DELAY_KEY = "microbatch_delay_millis"; | ||
private static final String CDC_CONFIG_MAX_COMMIT_LOGS_KEY = "max_commit_logs"; | ||
private static final String CDC_MAX_WATERMARKER_SIZE_KEY = "max_watermarker_size"; | ||
private static final String CDC_FAIL_KAFKA_ERRORS = "fail_kafka_errors"; | ||
private static final String CDC_FAIL_KAFKA_TOO_LARGE_ERRORS = "fail_kafka_too_large_errors"; | ||
private static final String CDC_PERSIST_DELAY_MILLIS = "persist_delay_millis"; |
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.
nit: define enums for the keys? and use the name()
of each enum. It is less verbose.
server/src/main/java/org/apache/cassandra/sidecar/cdc/CdcConfigImpl.java
Outdated
Show resolved
Hide resolved
} | ||
|
||
@Override | ||
public Optional<ServiceConfig> storeConfigIfNotExists(Map<String, String> config) |
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.
Not used anywhere. Is there a mistake?
If it is no longer needed, can you delete the method as well as the relevant fields in the schema class.
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.
It is used in some classes that we will be adding in other patches after this patch. we can remove it for now and add it or else we can add it now. I don't have a strong preference
server/src/main/java/org/apache/cassandra/sidecar/db/ConfigAccessorImpl.java
Outdated
Show resolved
Hide resolved
if (service.equals(ValidServices.KAFKA.serviceName)) | ||
{ | ||
return kafkaConfigAccessor; | ||
} | ||
|
||
if (service.equals(ValidServices.CDC.serviceName)) | ||
{ | ||
return cdcConfigAccessor; | ||
} | ||
|
||
throw new RuntimeException("Couldn't find a db accessor for service " + service); |
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.
Can you create a map and do the look up?
configAccessors.get(service.toLowerCase())
. If the result it null, it throws.
private final KafkaConfigAccessor kafkaConfigAccessor; | ||
private final CdcConfigAccessor cdcConfigAccessor; |
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.
Remove them. And have a map instead.
Map<String, ConfigAccessor> configAccessors
where the key is service name in lower case.
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.
I prefer having two separate objects, which are explicit instead of putting just two objects in the map and getting them with a string key.
server/src/main/java/org/apache/cassandra/sidecar/db/ConfigAccessor.java
Outdated
Show resolved
Hide resolved
dd9e2eb
to
bc93d91
Compare
public static final String SERVICE_CONFIG_ROUTE = API_V1 + SERVICES_PATH + SERVICE_PARAM + CONFIG; | ||
public static final String GET_SERVICES_CONFIG_ROUTE = API_V1 + SERVICES_PATH; |
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.
I think the URI should be the same for the service, with different verbs to specify the action:
/api/v1/config/services/:service
- GET : retrieve configuration for :service
- DELETE: remove configuration for :service
- PUT: update configuration for :service
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.
The get verb gets config for all the services, I think it is valuable. If we want to be able to get configs of a given service we can add GET verb on /api/v1/config/services/:service
.
9840126
to
ff860db
Compare
ff860db
to
07e11a2
Compare
No description provided.