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

com.hazelcast.core.Cluster Maven / Gradle / Ivy

There is a newer version: 5.0-BETA-1
Show newest version
/*
 * Copyright (c) 2008-2015, Hazelcast, Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.hazelcast.core;

import java.util.Set;

/**
 * Hazelcast cluster interface. It provides access to the members in the cluster and one can register for changes in the
 * cluster members.
 * 

* All the methods on the Cluster are thread-safe. */ public interface Cluster { /** * Adds MembershipListener to listen for membership updates. *

* The addMembershipListener method returns a register-id. This id is needed to remove the MembershipListener using the * {@link #removeMembershipListener(String)} method. *

* If the MembershipListener implements the {@link InitialMembershipListener} interface, it will also receive * the {@link InitialMembershipEvent}. *

* There is no check for duplicate registrations, so if you register the listener twice, it will get events twice. * * @param listener membership listener * @return the registration id. * @throws java.lang.NullPointerException if listener is null. * @see #removeMembershipListener(String) */ String addMembershipListener(MembershipListener listener); /** * Removes the specified MembershipListener. *

* If the same MembershipListener is registered multiple times, it needs to be removed multiple times. * * This method can safely be called multiple times for the same registration-id; subsequent calls are ignored. * * @param registrationId the registrationId of MembershipListener to remove. * @return true if the registration is removed, false otherwise. * @throws java.lang.NullPointerException if the registration id is null. * @see #addMembershipListener(MembershipListener) */ boolean removeMembershipListener(String registrationId); /** * Set of the current members in the cluster. The returned set is an immutable set; it can't be modified. *

* The returned set is backed by an ordered set. Every member in the cluster returns the 'members' in the same order. * To obtain the oldest member (the master) in the cluster, you can retrieve the first item in the set using * 'getMembers().iterator().next()'. * * @return current members in the cluster */ Set getMembers(); /** * Returns this Hazelcast instance member. * * @return this Hazelcast instance member */ Member getLocalMember(); /** * Returns the cluster-wide time in milliseconds. *

* Cluster tries to keep a cluster-wide time which might be different than the member's own system time. * Cluster-wide time is -almost- the same on all members of the cluster. * * @return cluster-wide time */ long getClusterTime(); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy