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

org.wildfly.clustering.infinispan.affinity.impl.SimpleKeyAffinityService Maven / Gradle / Ivy

/*
 * Copyright The WildFly Authors
 * SPDX-License-Identifier: Apache-2.0
 */

package org.wildfly.clustering.infinispan.affinity.impl;

import org.infinispan.affinity.KeyAffinityService;
import org.infinispan.affinity.KeyGenerator;
import org.infinispan.remoting.transport.Address;

/**
 * Simple {@link KeyAffinityService} implementation for use when co-location is not a requirement.
 * @author Paul Ferraro
 */
public class SimpleKeyAffinityService implements KeyAffinityService {

    private final KeyGenerator generator;
    private volatile boolean started = false;

    SimpleKeyAffinityService(KeyGenerator generator) {
        this.generator = generator;
    }

    @Override
    public void start() {
        this.started = true;
    }

    @Override
    public void stop() {
        this.started = false;
    }

    @Override
    public K getKeyForAddress(Address address) {
        return this.generator.getKey();
    }

    @Override
    public K getCollocatedKey(K otherKey) {
        return this.generator.getKey();
    }

    @Override
    public boolean isStarted() {
        return this.started;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy