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.ha;
019:
020: import org.apache.catalina.Manager;
021: import java.io.IOException;
022: import org.apache.catalina.tribes.io.ReplicationStream;
023:
024: /**
025: * The common interface used by all cluster manager.
026: * This is so that we can have a more pluggable way
027: * of swapping session managers for different algorithms.
028: *
029: * @author Filip Hanik
030: * @author Peter Rossbach
031: */
032: public interface ClusterManager extends Manager {
033:
034: /**
035: * A message was received from another node, this
036: * is the callback method to implement if you are interested in
037: * receiving replication messages.
038: * @param msg - the message received.
039: */
040: public void messageDataReceived(ClusterMessage msg);
041:
042: /**
043: * When the request has been completed, the replication valve
044: * will notify the manager, and the manager will decide whether
045: * any replication is needed or not.
046: * If there is a need for replication, the manager will
047: * create a session message and that will be replicated.
048: * The cluster determines where it gets sent.
049: * @param sessionId - the sessionId that just completed.
050: * @return a SessionMessage to be sent.
051: */
052: public ClusterMessage requestCompleted(String sessionId);
053:
054: /**
055: * When the manager expires session not tied to a request.
056: * The cluster will periodically ask for a list of sessions
057: * that should expire and that should be sent across the wire.
058: * @return String[] The invalidated sessions
059: */
060: public String[] getInvalidatedSessions();
061:
062: /**
063: * Return the name of the manager, at host /context name and at engine hostname+/context.
064: * @return String
065: * @since 5.5.10
066: */
067: public String getName();
068:
069: /**
070: * Set the name of the manager, at host /context name and at engine hostname+/context
071: * @param name
072: * @since 5.5.10
073: */
074: public void setName(String name);
075:
076: public CatalinaCluster getCluster();
077:
078: public void setCluster(CatalinaCluster cluster);
079:
080: /**
081: * @return Manager send only to same cluster domain.
082: * @since 5.5.10
083: */
084: public boolean doDomainReplication();
085:
086: /**
087: * @param sendClusterDomainOnly Flag value.
088: * @since 5.5.10
089: */
090: public void setDomainReplication(boolean domainReplication);
091:
092: /**
093: * @param mode The mode
094: * @since 5.5.10
095: */
096: public void setDefaultMode(boolean mode);
097:
098: /**
099: * @since 5.5.10
100: */
101: public boolean isDefaultMode();
102:
103: public ReplicationStream getReplicationStream(byte[] data)
104: throws IOException;
105:
106: public ReplicationStream getReplicationStream(byte[] data,
107: int offset, int length) throws IOException;
108:
109: public boolean isNotifyListenersOnReplication();
110:
111: public ClusterManager cloneFromTemplate();
112: }
|