001: /**
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 2006 Bull S.A.S.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * Initial developer: Benoit Pelletier
022: * --------------------------------------------------------------------------
023: * $Id: HaCluster.java 8231 2006-04-11 14:23:27Z pelletib $
024: * --------------------------------------------------------------------------
025: */package org.objectweb.jonas.ant.cluster;
026:
027: import java.io.File;
028: import java.util.Iterator;
029:
030: import org.objectweb.jonas.ant.jonasbase.BaseTaskItf;
031: import org.objectweb.jonas.ant.jonasbase.Ha;
032:
033: /**
034: * Define HaCluster task
035: * @author Benoit Pelletier
036: */
037: public class HaCluster extends ClusterTasks {
038:
039: /**
040: * Info for the logger
041: */
042: private static final String INFO = "[HaCluster] ";
043:
044: /**
045: * multicast addr
046: */
047: private String mcastAddr = null;
048:
049: /**
050: * multicast port
051: */
052: private String mcastPort = null;
053:
054: /**
055: * Default constructor
056: */
057: public HaCluster() {
058: super ();
059: }
060:
061: /**
062: * Set mcastAddr
063: * @param mcastAddr multicast address to set
064: */
065: public void setMcastAddr(String mcastAddr) {
066: this .mcastAddr = mcastAddr;
067: }
068:
069: /**
070: * Set mcastPort
071: * @param mcastPort multicast port to set
072: */
073: public void setMcastPort(String mcastPort) {
074: this .mcastPort = mcastPort;
075: }
076:
077: /**
078: * Generates the carol tasks for each JOnAS's instances
079: */
080: public void generatesTasks() {
081:
082: int portInd = 0;
083:
084: for (int i = getDestDirSuffixIndFirst(); i <= getDestDirSuffixIndLast(); i++) {
085:
086: String destDir = getDestDir(getDestDirPrefix(), i);
087:
088: // creation of the Ha tasks
089: Ha ha = new Ha();
090: log(INFO + "tasks generation for " + destDir);
091: ha.setMcastAddr(mcastAddr);
092: ha.setMcastPort(mcastPort);
093:
094: // set destDir for each carol task
095: for (Iterator it = ha.getTasks().iterator(); it.hasNext();) {
096: BaseTaskItf task = (BaseTaskItf) it.next();
097: task.setDestDir(new File(destDir));
098: }
099:
100: addTasks(ha);
101:
102: portInd++;
103:
104: }
105: }
106: }
|