IIOPPrimaryToContactInfo.java revision 608:7e06bf1dcb09
1/*
2 * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.  Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26package com.sun.corba.se.spi.transport;
27
28import java.util.List;
29
30import com.sun.corba.se.pept.transport.ContactInfo;
31
32/**
33 * This interface is the "sticky manager" for IIOP failover.  The default
34 * ORB does NOT contain a sticky manager.  One is registered by supplying
35 * a class via the com.sun.CORBA.transport.ORBIIOPPrimaryToContactInfoClass.
36 *
37 * It uses the IIOP primary host/port (with a SocketInfo.IIOP_CLEAR_TEXT type)
38 * as a key to map to the last ContactInfo that resulted in successful'
39 * communication.
40 *
41 * It mainly prevents "fallback" - if a previously failed replica comes
42 * back up we do NOT want to switch back to using it - particularly in the
43 * case of statefull session beans.
44 *
45 * Note: This assumes static lists of replicas (e.g., AS 8.1 EE).
46 * This does NOT work well with LOCATION_FORWARD.
47 *
48 * @author Harold Carr
49 */
50public interface IIOPPrimaryToContactInfo
51{
52    /**
53     * @param primary - clear any state relating to primary.
54     */
55    public void reset(ContactInfo primary);
56
57    /**
58     * @param primary - the key.
59     * @param previous - if null return true.  Otherwise, find previous in
60     * <code>contactInfos</code> and if another <code>ContactInfo</code>
61     * follows it in the list then return true.  Otherwise false.
62     * @param contactInfos - the list of replicas associated with the
63     * primary.
64     */
65    public boolean hasNext(ContactInfo primary,
66                           ContactInfo previous,
67                           List contactInfos);
68
69    /**
70     * @param primary - the key.
71     * @param previous - if null then map primary to failover.  If failover is
72     * empty then map primary to primary and return primary.  If failover is
73     * non-empty then return failover.  If previous is non-null that
74     * indicates that the previous failed.  Therefore, find previous in
75     * contactInfos.  Map the <code>ContactInfo</code> following
76     * previous to primary and return that <code>ContactInfo</code>.
77     */
78    public ContactInfo next(ContactInfo primary,
79                            ContactInfo previous,
80                            List contactInfos);
81
82}
83
84// End of file.
85