Search in sources :

Example 16 with PrimitiveProxy

use of io.atomix.primitive.proxy.PrimitiveProxy in project atomix by atomix.

the class DefaultPrimaryElectionService method stop.

@Override
public CompletableFuture<Void> stop() {
    PrimitiveProxy proxy = this.proxy;
    if (proxy != null) {
        return proxy.close().whenComplete((result, error) -> {
            started.set(false);
        });
    }
    started.set(false);
    return CompletableFuture.completedFuture(null);
}
Also used : PrimitiveProxy(io.atomix.primitive.proxy.PrimitiveProxy)

Example 17 with PrimitiveProxy

use of io.atomix.primitive.proxy.PrimitiveProxy in project atomix by atomix.

the class RecoveringPrimitiveProxy method close.

@Override
public synchronized CompletableFuture<Void> close() {
    if (connected) {
        connected = false;
        if (recoverTask != null) {
            recoverTask.cancel();
        }
        PrimitiveProxy proxy = this.proxy;
        if (proxy != null) {
            return proxy.close();
        } else {
            return clientFuture.thenCompose(c -> c.close());
        }
    }
    return CompletableFuture.completedFuture(null);
}
Also used : PrimitiveProxy(io.atomix.primitive.proxy.PrimitiveProxy)

Example 18 with PrimitiveProxy

use of io.atomix.primitive.proxy.PrimitiveProxy in project atomix by atomix.

the class RecoveringPrimitiveProxy method removeEventListener.

@Override
public synchronized void removeEventListener(Consumer<PrimitiveEvent> consumer) {
    checkOpen();
    eventListeners.remove(consumer);
    PrimitiveProxy proxy = this.proxy;
    if (proxy != null) {
        proxy.removeEventListener(consumer);
    }
}
Also used : PrimitiveProxy(io.atomix.primitive.proxy.PrimitiveProxy)

Example 19 with PrimitiveProxy

use of io.atomix.primitive.proxy.PrimitiveProxy in project atomix by atomix.

the class RecoveringPrimitiveProxy method execute.

@Override
public CompletableFuture<byte[]> execute(PrimitiveOperation operation) {
    checkOpen();
    PrimitiveProxy proxy = this.proxy;
    if (proxy != null) {
        return proxy.execute(operation);
    } else {
        return clientFuture.thenCompose(c -> c.execute(operation));
    }
}
Also used : PrimitiveProxy(io.atomix.primitive.proxy.PrimitiveProxy)

Example 20 with PrimitiveProxy

use of io.atomix.primitive.proxy.PrimitiveProxy in project atomix by atomix.

the class RecoveringPrimitiveProxy method addEventListener.

@Override
public synchronized void addEventListener(Consumer<PrimitiveEvent> consumer) {
    checkOpen();
    eventListeners.add(consumer);
    PrimitiveProxy proxy = this.proxy;
    if (proxy != null) {
        proxy.addEventListener(consumer);
    }
}
Also used : PrimitiveProxy(io.atomix.primitive.proxy.PrimitiveProxy)

Aggregations

PrimitiveProxy (io.atomix.primitive.proxy.PrimitiveProxy)35 AtomicLong (java.util.concurrent.atomic.AtomicLong)5 Test (org.junit.Test)4 Endpoint (io.atomix.messaging.Endpoint)2 BlockingAwarePrimitiveProxy (io.atomix.primitive.proxy.impl.BlockingAwarePrimitiveProxy)2 RecoveringPrimitiveProxy (io.atomix.primitive.proxy.impl.RecoveringPrimitiveProxy)2 RetryingPrimitiveProxy (io.atomix.primitive.proxy.impl.RetryingPrimitiveProxy)2 Executor (java.util.concurrent.Executor)2 AtomicCounterProxy (io.atomix.core.counter.impl.AtomicCounterProxy)1 PrimitiveDescriptor (io.atomix.protocols.backup.protocol.PrimitiveDescriptor)1 PrimaryBackupProxy (io.atomix.protocols.backup.proxy.PrimaryBackupProxy)1 DefaultRaftProxy (io.atomix.protocols.raft.proxy.impl.DefaultRaftProxy)1 Scheduler (io.atomix.utils.concurrent.Scheduler)1 SingleThreadContext (io.atomix.utils.concurrent.SingleThreadContext)1 ThreadContext (io.atomix.utils.concurrent.ThreadContext)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ExecutionException (java.util.concurrent.ExecutionException)1