This repository has been archived by the owner on Nov 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TransactionKeyValueServiceFactory and service loading. (#6984)
TransactionKeyValueServiceFactory and service loading.
- Loading branch information
1 parent
e300b67
commit 53e716a
Showing
11 changed files
with
278 additions
and
6 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
atlasdb-api/src/main/java/com/palantir/atlasdb/spi/KeyValueServiceManager.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,29 @@ | ||
/* | ||
* (c) Copyright 2024 Palantir Technologies Inc. All rights reserved. | ||
* | ||
* 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 com.palantir.atlasdb.spi; | ||
|
||
import com.palantir.atlasdb.keyvalue.api.KeyValueService; | ||
import com.palantir.refreshable.Refreshable; | ||
import java.util.Optional; | ||
|
||
public interface KeyValueServiceManager { | ||
KeyValueService getKeyValueService( | ||
KeyValueServiceConfig config, | ||
Refreshable<Optional<KeyValueServiceRuntimeConfig>> runtimeConfig, | ||
String namespace, | ||
boolean initializeAsync); | ||
} |
25 changes: 25 additions & 0 deletions
25
atlasdb-api/src/main/java/com/palantir/atlasdb/spi/TransactionKeyValueServiceConfig.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,25 @@ | ||
/* | ||
* (c) Copyright 2024 Palantir Technologies Inc. All rights reserved. | ||
* | ||
* 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 com.palantir.atlasdb.spi; | ||
|
||
import com.fasterxml.jackson.annotation.JsonTypeInfo; | ||
import com.fasterxml.jackson.annotation.JsonTypeInfo.As; | ||
|
||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = As.PROPERTY, property = "type", visible = false) | ||
public interface TransactionKeyValueServiceConfig { | ||
String type(); | ||
} |
46 changes: 46 additions & 0 deletions
46
...-api/src/main/java/com/palantir/atlasdb/spi/TransactionKeyValueServiceManagerFactory.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,46 @@ | ||
/* | ||
* (c) Copyright 2024 Palantir Technologies Inc. All rights reserved. | ||
* | ||
* 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 com.palantir.atlasdb.spi; | ||
|
||
import com.palantir.atlasdb.coordination.CoordinationService; | ||
import com.palantir.atlasdb.transaction.api.TransactionKeyValueServiceManager; | ||
import com.palantir.refreshable.Refreshable; | ||
|
||
/** | ||
* Factory for creating {@link TransactionKeyValueServiceManager} instances. | ||
* | ||
* Implementations have access to the coordination service to be able query their internal state at a particular | ||
* timestamp, as well as schedule changes to it at a future timestamp. | ||
* | ||
* AtlasDb will ensure that transactions that span state changes do not succeed and non-transactional workflows | ||
* are also retried. | ||
* | ||
* @param <T> type used for the coordination state. Should be a jackson-compatible POJO. | ||
*/ | ||
public interface TransactionKeyValueServiceManagerFactory<T> { | ||
|
||
String getType(); | ||
|
||
Class<T> coordinationValueClass(); | ||
|
||
TransactionKeyValueServiceManager create( | ||
CoordinationService<T> coordinationService, | ||
KeyValueServiceManager keyValueServiceManager, | ||
TransactionKeyValueServiceConfig install, | ||
Refreshable<TransactionKeyValueServiceRuntimeConfig> runtime, | ||
boolean initializeAsync); | ||
} |
24 changes: 24 additions & 0 deletions
24
...b-api/src/main/java/com/palantir/atlasdb/spi/TransactionKeyValueServiceRuntimeConfig.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,24 @@ | ||
/* | ||
* (c) Copyright 2024 Palantir Technologies Inc. All rights reserved. | ||
* | ||
* 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 com.palantir.atlasdb.spi; | ||
|
||
import com.fasterxml.jackson.annotation.JsonTypeInfo; | ||
|
||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = false) | ||
public interface TransactionKeyValueServiceRuntimeConfig { | ||
String type(); | ||
} |
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
50 changes: 50 additions & 0 deletions
50
atlasdb-config/src/main/java/com/palantir/atlasdb/factory/DefaultKeyValueServiceManager.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,50 @@ | ||
/* | ||
* (c) Copyright 2024 Palantir Technologies Inc. All rights reserved. | ||
* | ||
* 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 com.palantir.atlasdb.factory; | ||
|
||
import com.palantir.atlasdb.keyvalue.api.KeyValueService; | ||
import com.palantir.atlasdb.spi.AtlasDbFactory; | ||
import com.palantir.atlasdb.spi.KeyValueServiceConfig; | ||
import com.palantir.atlasdb.spi.KeyValueServiceManager; | ||
import com.palantir.atlasdb.spi.KeyValueServiceRuntimeConfig; | ||
import com.palantir.atlasdb.util.MetricsManager; | ||
import com.palantir.refreshable.Refreshable; | ||
import java.util.Optional; | ||
import java.util.function.LongSupplier; | ||
|
||
public final class DefaultKeyValueServiceManager implements KeyValueServiceManager { | ||
|
||
private final MetricsManager metricsManager; | ||
private final LongSupplier timestampSupplier; | ||
|
||
public DefaultKeyValueServiceManager(MetricsManager metricsManager, LongSupplier timestampSupplier) { | ||
this.metricsManager = metricsManager; | ||
this.timestampSupplier = timestampSupplier; | ||
} | ||
|
||
@Override | ||
public KeyValueService getKeyValueService( | ||
KeyValueServiceConfig config, | ||
Refreshable<Optional<KeyValueServiceRuntimeConfig>> runtimeConfig, | ||
String namespace, | ||
boolean initializeAsync) { | ||
// TODO(jakubk): In order to meaningfully memoize things we need to know cluster names. | ||
AtlasDbFactory atlasFactory = AtlasDbServiceDiscovery.createAtlasFactoryOfCorrectType(config); | ||
return atlasFactory.createRawKeyValueService( | ||
metricsManager, config, runtimeConfig, Optional.of(namespace), timestampSupplier, initializeAsync); | ||
} | ||
} |
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.