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

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

There is a newer version: 0.1152.0
Show newest version
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.tokens.auth.AuthHeader;
import java.lang.Override;
import java.lang.String;
import java.lang.Void;
import java.util.Set;
import java.util.UUID;
import javax.annotation.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.
     * @apiNote {@code POST /tl/management/getNamespaces}
     */
    @ClientEndpoint(method = "POST", path = "/tl/management/getNamespaces")
    Set getNamespaces(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, Set namespaces);

    /**
     * Invalidates existing resources for a given TimeLock namespace. 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.
     * @apiNote {@code POST /tl/management/invalidateResources}
     */
    @ClientEndpoint(method = "POST", path = "/tl/management/invalidateResources")
    void invalidateResources(AuthHeader authHeader, 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);

    /**
     * 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 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() {});

            @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 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 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);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy