All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.palantir.atlasdb.timelock.api.management.TimeLockManagementServiceAsync Maven / Gradle / Ivy

There is a newer version: 0.1152.0
Show newest version
package com.palantir.atlasdb.timelock.api.management;

import com.google.common.util.concurrent.ListenableFuture;
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(TimeLockManagementServiceAsync.Factory.class)
public interface TimeLockManagementServiceAsync {
    /**
     * 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")
    ListenableFuture> 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")
    ListenableFuture> 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")
    ListenableFuture 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")
    ListenableFuture 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")
    ListenableFuture 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")
    ListenableFuture 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")
    ListenableFuture fastForwardTimestamp(AuthHeader authHeader, @Safe String namespace, long currentTimestamp);

    /** Creates an asynchronous/non-blocking client for a TimeLockManagementService service. */
    static TimeLockManagementServiceAsync of(EndpointChannelFactory _endpointChannelFactory, ConjureRuntime _runtime) {
        return new TimeLockManagementServiceAsync() {
            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 ListenableFuture> getNamespaces(AuthHeader authHeader) {
                Request.Builder _request = Request.builder();
                _request.putHeaderParams("Authorization", authHeader.toString());
                return _runtime.clients().call(getNamespacesChannel, _request.build(), getNamespacesDeserializer);
            }

            @Override
            public ListenableFuture> getActiveNamespaces(AuthHeader authHeader) {
                Request.Builder _request = Request.builder();
                _request.putHeaderParams("Authorization", authHeader.toString());
                return _runtime.clients()
                        .call(getActiveNamespacesChannel, _request.build(), getActiveNamespacesDeserializer);
            }

            @Override
            public ListenableFuture achieveConsensus(AuthHeader authHeader, Set namespaces) {
                Request.Builder _request = Request.builder();
                _request.putHeaderParams("Authorization", authHeader.toString());
                _request.body(achieveConsensusSerializer.serialize(namespaces));
                return _runtime.clients().call(achieveConsensusChannel, _request.build(), achieveConsensusDeserializer);
            }

            @Override
            public ListenableFuture invalidateResources(AuthHeader authHeader, Set namespaces) {
                Request.Builder _request = Request.builder();
                _request.putHeaderParams("Authorization", authHeader.toString());
                _request.body(invalidateResourcesSerializer.serialize(namespaces));
                return _runtime.clients()
                        .call(invalidateResourcesChannel, _request.build(), invalidateResourcesDeserializer);
            }

            @Override
            public ListenableFuture getServerLifecycleId(AuthHeader authHeader) {
                Request.Builder _request = Request.builder();
                _request.putHeaderParams("Authorization", authHeader.toString());
                return _runtime.clients()
                        .call(getServerLifecycleIdChannel, _request.build(), getServerLifecycleIdDeserializer);
            }

            @Override
            public ListenableFuture forceKillTimeLockServer(AuthHeader authHeader) {
                Request.Builder _request = Request.builder();
                _request.putHeaderParams("Authorization", authHeader.toString());
                return _runtime.clients()
                        .call(forceKillTimeLockServerChannel, _request.build(), forceKillTimeLockServerDeserializer);
            }

            @Override
            public ListenableFuture 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));
                return _runtime.clients()
                        .call(fastForwardTimestampChannel, _request.build(), fastForwardTimestampDeserializer);
            }

            @Override
            public String toString() {
                return "TimeLockManagementServiceAsync{_endpointChannelFactory=" + _endpointChannelFactory
                        + ", runtime=" + _runtime + '}';
            }
        };
    }

    /** Creates an asynchronous/non-blocking client for a TimeLockManagementService service. */
    static TimeLockManagementServiceAsync 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 TimeLockManagementServiceAsync create(
                EndpointChannelFactory endpointChannelFactory, ConjureRuntime runtime) {
            return TimeLockManagementServiceAsync.of(endpointChannelFactory, runtime);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy