FailoverMethod.java
01 /*
02  *
03  * Licensed to the Apache Software Foundation (ASF) under one
04  * or more contributor license agreements.  See the NOTICE file
05  * distributed with this work for additional information
06  * regarding copyright ownership.  The ASF licenses this file
07  * to you under the Apache License, Version 2.0 (the
08  * "License"); you may not use this file except in compliance
09  * with the License.  You may obtain a copy of the License at
10  
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  */
21 
22 package org.apache.qpid.jms.failover;
23 
24 import org.apache.qpid.jms.BrokerDetails;
25 
26 public interface FailoverMethod
27 {
28     public static final String SINGLE_BROKER = "singlebroker";
29     public static final String ROUND_ROBIN = "roundrobin";
30     public static final String FAILOVER_EXCHANGE= "failover_exchange";
31     public static final String RANDOM = "random";
32     /**
33      * Reset the Failover to initial conditions
34      */
35     void reset();
36 
37     /**
38      *  Check if failover is possible for this method
39      *
40      @return true if failover is allowed
41      */
42     boolean failoverAllowed();
43 
44     /**
45      * Notification to the Failover method that a connection has been attained.
46      */
47     void attainedConnection();
48 
49     /**
50      * If there is no current BrokerDetails the null will be returned.
51      @return The current BrokerDetail value to use
52      */
53     BrokerDetails getCurrentBrokerDetails();
54 
55     /**
56      *  Move to the next BrokerDetails if one is available.
57      @return the next BrokerDetail or null if there is none.
58      */
59     BrokerDetails getNextBrokerDetails();
60 
61     /**
62      * Set the currently active broker to be the new value.
63      @param broker The new BrokerDetail value
64      */
65     void setBroker(BrokerDetails broker);
66 
67     /**
68      * Set the retries for this method
69      @param maxRetries the maximum number of time to retry this Method
70      */
71     void setRetries(int maxRetries);
72 
73     /**
74      @return The name of this method for display purposes.
75      */
76     String methodName();
77 }