-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CDAP-21079] Refactor SPI/TMS for default context before spanner exte…
…nsion implementation
- Loading branch information
1 parent
8771c9c
commit 3e37e7d
Showing
9 changed files
with
150 additions
and
31 deletions.
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
34 changes: 34 additions & 0 deletions
34
cdap-messaging-spi/src/main/java/io/cdap/cdap/messaging/spi/MessagingServiceContext.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,34 @@ | ||
/* | ||
* Copyright © 2023 Cask Data, Inc. | ||
* | ||
* Licensed 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 io.cdap.cdap.messaging.spi; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* The context object available to {@link MessagingService} for access to CDAP resources. | ||
*/ | ||
public interface MessagingServiceContext { | ||
|
||
/** | ||
* System properties are derived from the CDAP configuration. Anything in the CDAP configuration | ||
* will be added as an entry in the system properties. | ||
* | ||
* @return unmodifiable system properties for the messaging service. | ||
*/ | ||
Map<String, String> getProperties(); | ||
|
||
} |
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
48 changes: 48 additions & 0 deletions
48
cdap-tms/src/main/java/io/cdap/cdap/messaging/client/DefaultMessagingServiceContext.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 @@ | ||
/* | ||
* Copyright © 2023 Cask Data, Inc. | ||
* | ||
* Licensed 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 io.cdap.cdap.messaging.client; | ||
|
||
import io.cdap.cdap.common.conf.CConfiguration; | ||
import io.cdap.cdap.common.conf.Constants; | ||
import io.cdap.cdap.messaging.spi.MessagingServiceContext; | ||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* Default implementation for {@link MessagingServiceContext}. | ||
*/ | ||
public class DefaultMessagingServiceContext implements MessagingServiceContext { | ||
|
||
private final CConfiguration cConf; | ||
|
||
private static final String storageImpl = "gcp-spanner"; | ||
|
||
DefaultMessagingServiceContext(CConfiguration cConf) { | ||
this.cConf = cConf; | ||
} | ||
|
||
@Override | ||
public Map<String, String> getProperties() { | ||
// TODO: cdap-tms module refactoring will remove this dependency on spanner. | ||
String spannerPropertiesPrefix = | ||
Constants.Dataset.STORAGE_EXTENSION_PROPERTY_PREFIX + storageImpl + "."; | ||
Map<String, String> propertiesMap = new HashMap<>( | ||
cConf.getPropsWithPrefix(spannerPropertiesPrefix)); | ||
return Collections.unmodifiableMap(propertiesMap); | ||
} | ||
} | ||
|
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
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
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