KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > dream > protocol > causality > MatrixClock


1 /**
2  * Dream
3  * Copyright (C) 2003-2004 INRIA Rhone-Alpes
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Contact : dream@objectweb.org
20  *
21  * Initial developer(s): Matthieu Leclercq
22  * Contributor(s):
23  */

24
25 package org.objectweb.dream.protocol.causality;
26
27 /**
28  * Component interfae to manipulate causal matrix clock. The causality protocol
29  * composite allows <i>n </i> processes to exchange causaly ordered messages.
30  * Each process has a identifier form <i>0 </i> to <i>n-1 </i>. When a process
31  * send a message to an other, this message is stamped by the causality
32  * protocol. Before to be delivered to the destination process, the stamp of a
33  * given message is analysed to know if other messages should be delivered
34  * before this one.
35  */

36 public interface MatrixClock
37 {
38
39   /** The default name of {@link MatrixClock }interfaces */
40   String JavaDoc MATRIX_CLOCK_ITF_NAME = "matrix-clock";
41
42   /**
43    * the value returned by
44    * {@link MatrixClock#testRecvMatrix(Object, short, short) }if the message
45    * can be delivred
46    */

47   int DELIVER = 0;
48
49   /**
50    * the value returned by
51    * {@link MatrixClock#testRecvMatrix(Object, short, short) }if there is other
52    * message in the causal ordering before this.
53    */

54   int WAIT_TO_DELIVER = 1;
55
56   /**
57    * the value returned by
58    * {@link MatrixClock#testRecvMatrix(Object, short, short) }if the message
59    * has already been delivred.
60    */

61   int ALREADY_DELIVERED = 2;
62
63   /**
64    * Test if the received message, the given stamp belong, can be delivered. If
65    * the message is ready to be delivered, the method returns
66    * <code>DELIVER</code> and the matrix clock is updated. If the message has
67    * already been delivered, the method returns <code>ALREADY_DELIVERED</code>,
68    * and if other messages are waited before this message the method returns
69    * <code>WAIT_TO_DELIVER</code>. In the last two case the matrix clock
70    * remains unchanged.
71    *
72    * @param stamp a stamp
73    * @param from the identifier of the sender process.
74    * @param to the identifier of the local process.
75    * @return <code>DELIVER</code>,<code>ALREADY_DELIVERED</code>, or
76    * <code>WAIT_TO_DELIVER</code> code.
77    */

78   int testRecvMatrix(Object JavaDoc stamp, short from, short to);
79
80   /**
81    * Generate a stamp for the specified destination identifier.
82    *
83    * @param from the local process identifier
84    * @param to the destination process identifier
85    * @return a stamp.
86    */

87   Object JavaDoc getStamp(short from, short to);
88
89 }
Popular Tags