com.palantir.atlasdb.timelock.api.management.TimeLockManagementServiceBlocking Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of timelock-api-dialogue Show documentation
Show all versions of timelock-api-dialogue Show documentation
Palantir open source project
package com.palantir.atlasdb.timelock.api.management;
import com.palantir.conjure.java.lib.internal.ClientEndpoint;
import com.palantir.dialogue.Channel;
import com.palantir.dialogue.ConjureRuntime;
import com.palantir.dialogue.Deserializer;
import com.palantir.dialogue.DialogueService;
import com.palantir.dialogue.DialogueServiceFactory;
import com.palantir.dialogue.Endpoint;
import com.palantir.dialogue.EndpointChannel;
import com.palantir.dialogue.EndpointChannelFactory;
import com.palantir.dialogue.PlainSerDe;
import com.palantir.dialogue.Request;
import com.palantir.dialogue.Serializer;
import com.palantir.dialogue.TypeMarker;
import com.palantir.logsafe.Safe;
import com.palantir.tokens.auth.AuthHeader;
import java.lang.Override;
import java.lang.String;
import java.lang.Void;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import javax.annotation.processing.Generated;
@Generated("com.palantir.conjure.java.services.dialogue.DialogueInterfaceGenerator")
@DialogueService(TimeLockManagementServiceBlocking.Factory.class)
public interface TimeLockManagementServiceBlocking {
/**
* The endpoint loads all persisted namespaces. leaderPaxos
is filtered out from the set as it is not a
* namespace. No transactionality guarantees are given: namespace additions and deletions while the request is
* running may or may not be reflected in the output.
*
* @apiNote {@code POST /tl/management/getNamespaces}
*/
@ClientEndpoint(method = "POST", path = "/tl/management/getNamespaces")
Set getNamespaces(AuthHeader authHeader);
/**
* The endpoint loads all namespaces that have had any interaction with the namespace within the past 6 hours (or
* since the last restart, if that happened within the last 6 hours). leaderPaxos
is filtered out from
* the set as it is not a namespace.
*
* @apiNote {@code POST /tl/management/getActiveNamespaces}
*/
@ClientEndpoint(method = "POST", path = "/tl/management/getActiveNamespaces")
Set getActiveNamespaces(AuthHeader authHeader);
/**
* The operation of achieving consensus on all namespaces is NOT atomic. In the case of failures, it can be assumed
* that consensus was achieved on some namespaces.
*
* @apiNote {@code POST /tl/management/achieveConsensus}
*/
@ClientEndpoint(method = "POST", path = "/tl/management/achieveConsensus")
void achieveConsensus(AuthHeader authHeader, @Safe Set namespaces);
/**
* Invalidates existing resources for a given TimeLock namespace in a persistant way, until re-enabled. Does not
* actually cause a leader election, and should not interrupt service for other naemspaces. Note that this operation
* is atomic for each namespace (e.g. users will not see two different lock services servicing the same
* startTransactions request), but not atomic as a whole. Additionally, if this method throws, it is
* nondeterministic which, if any, namespaces have been invalidated; some may even be invalidated only on a subset
* of nodes. This state can be cleared by re-enabling all namespaces.
*
* @apiNote {@code POST /tl/management/invalidateResources}
*/
@ClientEndpoint(method = "POST", path = "/tl/management/invalidateResources")
void invalidateResources(AuthHeader authHeader, @Safe Set namespaces);
/**
* Gets the randomly generated server id associated with the server's current lifecycle upon start up.
*
* @apiNote {@code POST /tl/management/getServerLifecycleId}
*/
@ClientEndpoint(method = "POST", path = "/tl/management/getServerLifecycleId")
UUID getServerLifecycleId(AuthHeader authHeader);
/**
* Kills TimeLock server asynchronously i.e. current server will not be able to talk to peer nodes or serve requests
* once the task is executed. After hitting this endpoint, the server will require external intervention to start up
* the service again. The endpoint returns the (randomly generated) server id associated with server upon start up.
* A client can then make getServerId
requests wherein change in server id would imply that the server
* was bounced.
*
* @apiNote {@code POST /tl/management/forceKillTimeLockServer}
*/
@ClientEndpoint(method = "POST", path = "/tl/management/forceKillTimeLockServer")
UUID forceKillTimeLockServer(AuthHeader authHeader);
/**
* Updates the timestamp service to the currentTimestamp to ensure that all fresh timestamps issued after this
* request are greater than the current timestamp. The caller of this is responsible for not using any of the fresh
* timestamps previously served to it, and must call getFreshTimestamps() to ensure it is using timestamps after the
* fastforward point.
*
* @apiNote {@code POST /tl/management/fastForward}
* @param currentTimestamp the largest timestamp issued until the fast-forward call
*/
@ClientEndpoint(method = "POST", path = "/tl/management/fastForward")
void fastForwardTimestamp(AuthHeader authHeader, @Safe String namespace, long currentTimestamp);
/** Creates a synchronous/blocking client for a TimeLockManagementService service. */
static TimeLockManagementServiceBlocking of(
EndpointChannelFactory _endpointChannelFactory, ConjureRuntime _runtime) {
return new TimeLockManagementServiceBlocking() {
private final PlainSerDe _plainSerDe = _runtime.plainSerDe();
private final EndpointChannel getNamespacesChannel =
_endpointChannelFactory.endpoint(DialogueTimeLockManagementEndpoints.getNamespaces);
private final Deserializer> getNamespacesDeserializer =
_runtime.bodySerDe().deserializer(new TypeMarker>() {});
private final EndpointChannel getActiveNamespacesChannel =
_endpointChannelFactory.endpoint(DialogueTimeLockManagementEndpoints.getActiveNamespaces);
private final Deserializer> getActiveNamespacesDeserializer =
_runtime.bodySerDe().deserializer(new TypeMarker>() {});
private final Serializer> achieveConsensusSerializer =
_runtime.bodySerDe().serializer(new TypeMarker>() {});
private final EndpointChannel achieveConsensusChannel =
_endpointChannelFactory.endpoint(DialogueTimeLockManagementEndpoints.achieveConsensus);
private final Deserializer achieveConsensusDeserializer =
_runtime.bodySerDe().emptyBodyDeserializer();
private final Serializer> invalidateResourcesSerializer =
_runtime.bodySerDe().serializer(new TypeMarker>() {});
private final EndpointChannel invalidateResourcesChannel =
_endpointChannelFactory.endpoint(DialogueTimeLockManagementEndpoints.invalidateResources);
private final Deserializer invalidateResourcesDeserializer =
_runtime.bodySerDe().emptyBodyDeserializer();
private final EndpointChannel getServerLifecycleIdChannel =
_endpointChannelFactory.endpoint(DialogueTimeLockManagementEndpoints.getServerLifecycleId);
private final Deserializer getServerLifecycleIdDeserializer =
_runtime.bodySerDe().deserializer(new TypeMarker() {});
private final EndpointChannel forceKillTimeLockServerChannel =
_endpointChannelFactory.endpoint(DialogueTimeLockManagementEndpoints.forceKillTimeLockServer);
private final Deserializer forceKillTimeLockServerDeserializer =
_runtime.bodySerDe().deserializer(new TypeMarker() {});
private final EndpointChannel fastForwardTimestampChannel =
_endpointChannelFactory.endpoint(DialogueTimeLockManagementEndpoints.fastForwardTimestamp);
private final Deserializer fastForwardTimestampDeserializer =
_runtime.bodySerDe().emptyBodyDeserializer();
@Override
public Set getNamespaces(AuthHeader authHeader) {
Request.Builder _request = Request.builder();
_request.putHeaderParams("Authorization", authHeader.toString());
return _runtime.clients()
.callBlocking(getNamespacesChannel, _request.build(), getNamespacesDeserializer);
}
@Override
public Set getActiveNamespaces(AuthHeader authHeader) {
Request.Builder _request = Request.builder();
_request.putHeaderParams("Authorization", authHeader.toString());
return _runtime.clients()
.callBlocking(getActiveNamespacesChannel, _request.build(), getActiveNamespacesDeserializer);
}
@Override
public void achieveConsensus(AuthHeader authHeader, Set namespaces) {
Request.Builder _request = Request.builder();
_request.putHeaderParams("Authorization", authHeader.toString());
_request.body(achieveConsensusSerializer.serialize(namespaces));
_runtime.clients()
.callBlocking(achieveConsensusChannel, _request.build(), achieveConsensusDeserializer);
}
@Override
public void invalidateResources(AuthHeader authHeader, Set namespaces) {
Request.Builder _request = Request.builder();
_request.putHeaderParams("Authorization", authHeader.toString());
_request.body(invalidateResourcesSerializer.serialize(namespaces));
_runtime.clients()
.callBlocking(invalidateResourcesChannel, _request.build(), invalidateResourcesDeserializer);
}
@Override
public UUID getServerLifecycleId(AuthHeader authHeader) {
Request.Builder _request = Request.builder();
_request.putHeaderParams("Authorization", authHeader.toString());
return _runtime.clients()
.callBlocking(getServerLifecycleIdChannel, _request.build(), getServerLifecycleIdDeserializer);
}
@Override
public UUID forceKillTimeLockServer(AuthHeader authHeader) {
Request.Builder _request = Request.builder();
_request.putHeaderParams("Authorization", authHeader.toString());
return _runtime.clients()
.callBlocking(
forceKillTimeLockServerChannel, _request.build(), forceKillTimeLockServerDeserializer);
}
@Override
public void fastForwardTimestamp(AuthHeader authHeader, String namespace, long currentTimestamp) {
Request.Builder _request = Request.builder();
_request.putHeaderParams("Authorization", authHeader.toString());
_request.putQueryParams("namespace", _plainSerDe.serializeString(namespace));
_request.putQueryParams("currentTimestamp", Objects.toString(currentTimestamp));
_runtime.clients()
.callBlocking(fastForwardTimestampChannel, _request.build(), fastForwardTimestampDeserializer);
}
@Override
public String toString() {
return "TimeLockManagementServiceBlocking{_endpointChannelFactory=" + _endpointChannelFactory
+ ", runtime=" + _runtime + '}';
}
};
}
/** Creates an asynchronous/non-blocking client for a TimeLockManagementService service. */
static TimeLockManagementServiceBlocking of(Channel _channel, ConjureRuntime _runtime) {
if (_channel instanceof EndpointChannelFactory) {
return of((EndpointChannelFactory) _channel, _runtime);
}
return of(
new EndpointChannelFactory() {
@Override
public EndpointChannel endpoint(Endpoint endpoint) {
return _runtime.clients().bind(_channel, endpoint);
}
},
_runtime);
}
final class Factory implements DialogueServiceFactory {
@Override
public TimeLockManagementServiceBlocking create(
EndpointChannelFactory endpointChannelFactory, ConjureRuntime runtime) {
return TimeLockManagementServiceBlocking.of(endpointChannelFactory, runtime);
}
}
}