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

org.wildfly.clustering.singleton.server.SingletonElectionCommand Maven / Gradle / Ivy

There is a newer version: 35.0.0.Final
Show newest version
/*
 * Copyright The WildFly Authors
 * SPDX-License-Identifier: Apache-2.0
 */

package org.wildfly.clustering.singleton.server;

import java.util.List;

import org.wildfly.clustering.server.GroupMember;
import org.wildfly.clustering.server.dispatcher.Command;
import org.wildfly.clustering.singleton.election.SingletonElectionListener;

/**
 * @author Paul Ferraro
 */
public class SingletonElectionCommand implements Command {

    private final List candidates;
    private final Integer index;

    public SingletonElectionCommand(List candidates, GroupMember elected) {
        this(candidates, (elected != null) ? candidates.indexOf(elected) : null);
    }

    SingletonElectionCommand(List candidates, Integer index) {
        this.candidates = candidates;
        this.index = index;
    }

    List getCandidates() {
        return this.candidates;
    }

    Integer getIndex() {
        return this.index;
    }

    @Override
    public Void execute(SingletonElectionListener context) {
        context.elected(this.candidates, (this.index != null) ? this.candidates.get(this.index) : null);
        return null;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy