1 /* 2 * Copyright (c) 1998-2002 The Jgroup Team. 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License version 2 as 6 * published by the Free Software Foundation. 7 * 8 * This program is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * GNU Lesser General Public License for more details. 12 * 13 * You should have received a copy of the GNU Lesser General Public License 14 * along with this program; if not, write to the Free Software 15 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 16 * 17 */ 18 19 package jgroup.relacs.events; 20 21 import java.io.IOException; 22 import java.io.ObjectInput; 23 import java.io.ObjectOutput; 24 25 import jgroup.relacs.types.GroupIndex; 26 27 /** 28 * The <code>DeliveryAck</code> class represents a local message 29 * exchanged between members and the daemon; it is used by the member 30 * to notify the daemon that a view has been successfully installed. 31 * 32 * @author Alberto Montresor 33 * @since Jgroup 0.1 34 */ 35 public final class InstallAck 36 extends Event 37 { 38 39 //////////////////////////////////////////////////////////////////////////////////////////// 40 // Fields 41 //////////////////////////////////////////////////////////////////////////////////////////// 42 43 private static final long serialVersionUID = -6124650592732535593L; 44 45 /** Member position */ 46 private int memberIndex; 47 48 49 //////////////////////////////////////////////////////////////////////////////////////////// 50 // Constructors 51 //////////////////////////////////////////////////////////////////////////////////////////// 52 53 /** 54 * Default constructor for externalization. 55 */ 56 public InstallAck() 57 { 58 } 59 60 /** 61 * Creates an <code>InstallAck</code> object storing the local 62 * identifier of the last installed view, and the member's 63 * position index in the array containing the view members. 64 * 65 * @param gid group identifier 66 * @param memberIndex index of the member position in the 67 * array containing the members of the last installed view 68 * @param lastInstalled local identifier of the last installed 69 * view 70 */ 71 public InstallAck(int gid, int memberIndex) 72 { 73 super(INSTALL_ACK, gid); 74 this.memberIndex = memberIndex; 75 } 76 77 78 //////////////////////////////////////////////////////////////////////////////////////////// 79 // Accessor methods 80 //////////////////////////////////////////////////////////////////////////////////////////// 81 82 /** 83 * Returns the position index of the member generating this <CODE>InstallAck</CODE> 84 * event in the array containing the members of the last installed view. 85 */ 86 public int getMemberIndex() 87 { 88 return memberIndex; 89 } 90 91 92 //////////////////////////////////////////////////////////////////////////////////////////// 93 // Methods from Externalizable 94 //////////////////////////////////////////////////////////////////////////////////////////// 95 96 /** 97 * Restores the content of this object from the marshalled data contained 98 * in the specified input stream. 99 * 100 * @param in the stream to be read 101 */ 102 public void readExternal(ObjectInput in) 103 throws IOException, ClassNotFoundException 104 { 105 super.readExternal(in); 106 memberIndex = GroupIndex.unmarshal(in); 107 } 108 109 /** 110 * Marshals the content of this object to the specified output stream. 111 * 112 * @param out the stream to be written 113 */ 114 public void writeExternal(ObjectOutput out) 115 throws IOException 116 { 117 super.writeExternal(out); 118 GroupIndex.marshal(out, memberIndex); 119 } 120 121 } // END InstallAck 122