-
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
Open
jyothsnakonisa
wants to merge
3
commits into
apache:trunk
Choose a base branch
from
jyothsnakonisa:cdc-config
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,212
−10
Open
Changes from all commits
Commits
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
42 changes: 42 additions & 0 deletions
42
...on/src/main/java/org/apache/cassandra/sidecar/common/request/GetServiceConfigRequest.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,42 @@ | ||
/* | ||
* 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.cassandra.sidecar.common.request; | ||
|
||
import io.netty.handler.codec.http.HttpMethod; | ||
import org.apache.cassandra.sidecar.common.request.data.GetServicesConfigPayload; | ||
|
||
/** | ||
* Represents a request for getting configurations for services from "configs" table inside | ||
* sidecar internal keyspace. | ||
*/ | ||
public class GetServiceConfigRequest extends JsonRequest<GetServicesConfigPayload> | ||
{ | ||
/** | ||
* Constructs a Sidecar request with the given {@code requestURI}. Defaults to {@code ssl} enabled. | ||
*/ | ||
public GetServiceConfigRequest() | ||
{ | ||
super("/api/v1/services"); | ||
} | ||
|
||
@Override | ||
public HttpMethod method() | ||
{ | ||
return HttpMethod.GET; | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
...on/src/main/java/org/apache/cassandra/sidecar/common/request/PutServiceConfigRequest.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,48 @@ | ||
/* | ||
* 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.cassandra.sidecar.common.request; | ||
|
||
import io.netty.handler.codec.http.HttpMethod; | ||
import org.apache.cassandra.sidecar.common.request.data.PutCdcServiceConfigPayload; | ||
|
||
/** | ||
* Request class for updating the config of a given service. | ||
* Ex: updating kafka configs or updating cdc configs | ||
*/ | ||
public class PutServiceConfigRequest extends JsonRequest<PutCdcServiceConfigPayload> | ||
{ | ||
final PutCdcServiceConfigPayload payload; | ||
|
||
public PutServiceConfigRequest(ServiceConfig serviceConfig, PutCdcServiceConfigPayload payload) | ||
{ | ||
super(String.format("/api/v1/services/%s/config", serviceConfig.getServiceConfig())); | ||
this.payload = payload; | ||
} | ||
|
||
@Override | ||
public Object requestBody() | ||
{ | ||
return this.payload; | ||
} | ||
|
||
@Override | ||
public HttpMethod method() | ||
{ | ||
return HttpMethod.PUT; | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
client-common/src/main/java/org/apache/cassandra/sidecar/common/request/ServiceConfig.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,40 @@ | ||
/* | ||
* 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.cassandra.sidecar.common.request; | ||
|
||
/** | ||
* "configs" table inside internal sidecar keyspace stores configs for Kafka and CDC. ServiceConfig identifies | ||
* the service of the configs. | ||
*/ | ||
public enum ServiceConfig | ||
{ | ||
CDC("cdc"), | ||
KAFKA("kafka"); | ||
jyothsnakonisa marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
private final String serviceConfig; | ||
|
||
ServiceConfig(String serviceConfig) | ||
{ | ||
this.serviceConfig = serviceConfig; | ||
} | ||
|
||
public String getServiceConfig() | ||
{ | ||
return serviceConfig; | ||
} | ||
} |
105 changes: 105 additions & 0 deletions
105
.../main/java/org/apache/cassandra/sidecar/common/request/data/GetServicesConfigPayload.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,105 @@ | ||
/* | ||
* 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.cassandra.sidecar.common.request.data; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
/** | ||
* A class representing a response for the GetServicesConfig api "/api/v1/services" which contains | ||
* configs for all the services in the "configs" table. | ||
*/ | ||
public class GetServicesConfigPayload | ||
{ | ||
public final List<Service> services; | ||
|
||
@JsonCreator | ||
public GetServicesConfigPayload(@JsonProperty("services") List<Service> services) | ||
{ | ||
this.services = services; | ||
} | ||
|
||
@JsonProperty("services") | ||
public List<Service> services() | ||
{ | ||
return services; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) | ||
{ | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
GetServicesConfigPayload that = (GetServicesConfigPayload) o; | ||
return Objects.equals(services, that.services); | ||
} | ||
|
||
@Override | ||
public int hashCode() | ||
{ | ||
return Objects.hash(services); | ||
} | ||
|
||
/** | ||
* POJO class that represent config for a given service in "configs" table in sidecar | ||
* internal keyspace | ||
*/ | ||
public static class Service | ||
{ | ||
public final String service; | ||
public final Map<String, String> config; | ||
|
||
@JsonCreator | ||
public Service(@JsonProperty("service") String service, | ||
@JsonProperty("config") Map<String, String> config) | ||
{ | ||
this.service = service; | ||
this.config = config; | ||
} | ||
|
||
@JsonProperty("service") | ||
public String service() | ||
{ | ||
return service; | ||
} | ||
|
||
@JsonProperty("config") | ||
public Map<String, String> config() | ||
{ | ||
return config; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) | ||
{ | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
Service service1 = (Service) o; | ||
return Objects.equals(service, service1.service) && Objects.equals(config, service1.config); | ||
} | ||
|
||
@Override | ||
public int hashCode() | ||
{ | ||
return Objects.hash(service, config); | ||
} | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
...ain/java/org/apache/cassandra/sidecar/common/request/data/PutCdcServiceConfigPayload.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,58 @@ | ||
/* | ||
* 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.cassandra.sidecar.common.request.data; | ||
|
||
import java.util.Map; | ||
import java.util.Objects; | ||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
/** | ||
* A class representing a response for the {@link PutCdcServiceConfigPayload}. | ||
*/ | ||
public class PutCdcServiceConfigPayload | ||
{ | ||
public final Map<String, String> config; | ||
|
||
@JsonCreator | ||
public PutCdcServiceConfigPayload(@JsonProperty("config") Map<String, String> config) | ||
{ | ||
this.config = config; | ||
} | ||
|
||
@JsonProperty("config") | ||
public Map<String, String> config() | ||
{ | ||
return config; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) | ||
{ | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
PutCdcServiceConfigPayload that = (PutCdcServiceConfigPayload) o; | ||
return Objects.equals(config, that.config); | ||
} | ||
|
||
@Override | ||
public int hashCode() | ||
{ | ||
return Objects.hash(config); | ||
} | ||
} |
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.
I think the URI should be the same for the service, with different verbs to specify the action:
/api/v1/config/services/: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
.