001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package org.apache.catalina.tribes;
019:
020: /**
021: * The Member interface, defines a member in the group.
022: * Each member can carry a set of properties, defined by the actual implementation.<BR>
023: * A member is identified by the host/ip/uniqueId<br>
024: * The host is what interface the member is listening to, to receive data<br>
025: * The port is what port the member is listening to, to receive data<br>
026: * The uniqueId defines the session id for the member. This is an important feature
027: * since a member that has crashed and the starts up again on the same port/host is
028: * not guaranteed to be the same member, so no state transfers will ever be confused
029: * @author Filip Hanik
030: * @version $Revision: 467222 $, $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
031: */
032:
033: public interface Member {
034:
035: /**
036: * When a member leaves the cluster, the payload of the memberDisappeared member
037: * will be the following bytes. This indicates a soft shutdown, and not a crash
038: */
039: public static final byte[] SHUTDOWN_PAYLOAD = new byte[] { 66, 65,
040: 66, 89, 45, 65, 76, 69, 88 };
041:
042: /**
043: * Returns the name of this node, should be unique within the group.
044: */
045: public String getName();
046:
047: /**
048: * Returns the listen host for the ChannelReceiver implementation
049: * @return IPv4 or IPv6 representation of the host address this member listens to incoming data
050: * @see ChannelReceiver
051: */
052: public byte[] getHost();
053:
054: /**
055: * Returns the listen port for the ChannelReceiver implementation
056: * @return the listen port for this member, -1 if its not listening on an unsecure port
057: * @see ChannelReceiver
058: */
059: public int getPort();
060:
061: /**
062: * Returns the secure listen port for the ChannelReceiver implementation.
063: * Returns -1 if its not listening to a secure port.
064: * @return the listen port for this member, -1 if its not listening on a secure port
065: * @see ChannelReceiver
066: */
067: public int getSecurePort();
068:
069: /**
070: * Contains information on how long this member has been online.
071: * The result is the number of milli seconds this member has been
072: * broadcasting its membership to the group.
073: * @return nr of milliseconds since this member started.
074: */
075: public long getMemberAliveTime();
076:
077: /**
078: * The current state of the member
079: * @return boolean - true if the member is functioning correctly
080: */
081: public boolean isReady();
082:
083: /**
084: * The current state of the member
085: * @return boolean - true if the member is suspect, but the crash has not been confirmed
086: */
087: public boolean isSuspect();
088:
089: /**
090: *
091: * @return boolean - true if the member has been confirmed to malfunction
092: */
093: public boolean isFailing();
094:
095: /**
096: * returns a UUID unique for this member over all sessions.
097: * If the member crashes and restarts, the uniqueId will be different.
098: * @return byte[]
099: */
100: public byte[] getUniqueId();
101:
102: /**
103: * returns the payload associated with this member
104: * @return byte[]
105: */
106: public byte[] getPayload();
107:
108: /**
109: * returns the command associated with this member
110: * @return byte[]
111: */
112: public byte[] getCommand();
113:
114: /**
115: * Domain for this cluster
116: * @return byte[]
117: */
118: public byte[] getDomain();
119: }
|