001: /**
002: * This file or a portion of this file is licensed under the terms of
003: * the Globus Toolkit Public License, found at $PEGASUS_HOME/GTPL or
004: * http://www.globus.org/toolkit/download/license.html.
005: * This notice must appear in redistributions of this file
006: * with or without modification.
007: *
008: * Redistributions of this Software, with or without modification, must reproduce
009: * the GTPL in:
010: * (1) the Software, or
011: * (2) the Documentation or
012: * some other similar material which is provided with the Software (if any).
013: *
014: * Copyright 1999-2004
015: * University of Chicago and The University of Southern California.
016: * All rights reserved.
017: */package org.griphyn.cPlanner.classes;
018:
019: /**
020: * This is a data class to store information about gridftp bandwidths between
021: * various sites. The class is no longer used, and is there for compilation
022: * purposes.
023: *
024: * @author Saurabh Khurana
025: * @author Karan Vahi
026: *
027: * @version $Revision: 50 $
028: */
029:
030: public class GridFTPBandwidth {
031:
032: // private String host_subnet_id = null;
033: private String dest_subnet_id = null;
034: private String avg_bandwidth_range1 = null;
035: private String avg_bandwidth_range2 = null;
036: private String avg_bandwidth_range3 = null;
037: private String avg_bandwidth_range4 = null;
038: private String avg_bandwidth = null;
039: private String max_bandwidth = null;
040: private String min_bandwidth = null;
041:
042: public static final String GRIDFTPBANDWIDTHINFO[] = {
043: "dest-subnet", "avg-bandwidth-range1",
044: "avg-bandwidth-range2", "avg-bandwidth-range3",
045: "avg-bandwidth-range4", "avg-bandwidth", "max-bandwidth",
046: "min-bandwidth" };
047:
048: public static final int DEST_ID = 0;
049: public static final int AVG_BW_RANGE1 = 1;
050: public static final int AVG_BW_RANGE2 = 2;
051: public static final int AVG_BW_RANGE3 = 3;
052: public static final int AVG_BW_RANGE4 = 4;
053: public static final int AVG_BW = 5;
054: public static final int MAX_BW = 6;
055: public static final int MIN_BW = 7;
056:
057: //constructor
058: public GridFTPBandwidth() {
059: }
060:
061: /**
062: * This method sets the info about gridftpbw based on the gridftpbwkey
063: * @param gridftpbwkey the key for indicating the information
064: * @param gridftpbwvalue is the information
065: */
066: public void setInfo(int gridftpbwkey, String gridftpbwvalue)
067: throws Exception {
068: switch (gridftpbwkey) {
069: case 0:
070: dest_subnet_id = gridftpbwvalue == null ? null
071: : new String(gridftpbwvalue);
072: break;
073: case 1:
074: avg_bandwidth_range1 = gridftpbwvalue == null ? null
075: : new String(gridftpbwvalue);
076: break;
077: case 2:
078: avg_bandwidth_range2 = gridftpbwvalue == null ? null
079: : new String(gridftpbwvalue);
080: break;
081: case 3:
082: avg_bandwidth_range3 = gridftpbwvalue == null ? null
083: : new String(gridftpbwvalue);
084: break;
085: case 4:
086: avg_bandwidth_range4 = gridftpbwvalue == null ? null
087: : new String(gridftpbwvalue);
088: break;
089: case 5:
090: avg_bandwidth = gridftpbwvalue == null ? null : new String(
091: gridftpbwvalue);
092: break;
093: case 6:
094: max_bandwidth = gridftpbwvalue == null ? null : new String(
095: gridftpbwvalue);
096: break;
097: case 7:
098: min_bandwidth = gridftpbwvalue == null ? null : new String(
099: gridftpbwvalue);
100: break;
101:
102: default:
103: throw new Exception(
104: "Wrong gridftpbwkey = "
105: + GRIDFTPBANDWIDTHINFO[gridftpbwkey]
106: + " specified. Gridftpbwkey must be one of the predefined types");
107: }
108: }
109:
110: /**
111: * This method gets the info about gridftpbw based on the gridftpbwkey
112: * @param gridftpbwkey the key for requesting the information
113: * @return String
114: */
115: public String getInfo(int gridftpbwkey) throws Exception {
116: switch (gridftpbwkey) {
117: case 0:
118: return dest_subnet_id;
119: case 1:
120: return avg_bandwidth_range1;
121: case 2:
122: return avg_bandwidth_range2;
123: case 3:
124: return avg_bandwidth_range3;
125: case 4:
126: return avg_bandwidth_range4;
127: case 5:
128: return avg_bandwidth;
129: case 6:
130: return max_bandwidth;
131: case 7:
132: return min_bandwidth;
133:
134: default:
135: throw new Exception(
136: "Wrong gridftpbwkey = "
137: + GRIDFTPBANDWIDTHINFO[gridftpbwkey]
138: + " specified. Gridftpbwkey must be one of the predefined types");
139: }
140: }
141:
142: public String toString() {
143: String output = "GRIDFTPBANDWIDTH(";
144: if (dest_subnet_id != null) {
145: output += " " + GRIDFTPBANDWIDTHINFO[DEST_ID] + "="
146: + dest_subnet_id;
147: }
148: if (avg_bandwidth_range1 != null) {
149: output += " " + GRIDFTPBANDWIDTHINFO[AVG_BW_RANGE1] + "="
150: + avg_bandwidth_range1;
151: }
152: if (avg_bandwidth_range2 != null) {
153: output += " " + GRIDFTPBANDWIDTHINFO[AVG_BW_RANGE2] + "="
154: + avg_bandwidth_range2;
155: }
156: if (avg_bandwidth_range3 != null) {
157: output += " " + GRIDFTPBANDWIDTHINFO[AVG_BW_RANGE3] + "="
158: + avg_bandwidth_range3;
159: }
160: if (avg_bandwidth_range4 != null) {
161: output += " " + GRIDFTPBANDWIDTHINFO[AVG_BW_RANGE4] + "="
162: + avg_bandwidth_range4;
163: }
164: if (avg_bandwidth != null) {
165: output += " " + GRIDFTPBANDWIDTHINFO[AVG_BW] + "="
166: + avg_bandwidth;
167: }
168: if (max_bandwidth != null) {
169: output += " " + GRIDFTPBANDWIDTHINFO[MAX_BW] + "="
170: + max_bandwidth;
171: }
172: if (min_bandwidth != null) {
173: output += " " + GRIDFTPBANDWIDTHINFO[MIN_BW] + "="
174: + min_bandwidth;
175: }
176:
177: output += " )";
178: // System.out.println(output);
179: return output;
180: }
181:
182: /**
183: * Returns the XML description of the contents of Gridftp object.
184: *
185: * @return the xml description.
186: */
187: public String toXML() {
188:
189: String output = " <bandwidth";
190:
191: if (dest_subnet_id != null) {
192: output += " " + GRIDFTPBANDWIDTHINFO[DEST_ID] + "=\""
193: + dest_subnet_id + "\"";
194: }
195: if (avg_bandwidth_range1 != null) {
196: output += " " + GRIDFTPBANDWIDTHINFO[AVG_BW_RANGE1] + "=\""
197: + avg_bandwidth_range1.trim() + "\"";
198: }
199: if (avg_bandwidth_range2 != null) {
200: output += " " + GRIDFTPBANDWIDTHINFO[AVG_BW_RANGE2] + "=\""
201: + avg_bandwidth_range2.trim() + "\"";
202: }
203: if (avg_bandwidth_range3 != null) {
204: output += " " + GRIDFTPBANDWIDTHINFO[AVG_BW_RANGE3] + "=\""
205: + avg_bandwidth_range3.trim() + "\"";
206: }
207: if (avg_bandwidth_range4 != null) {
208: output += " " + GRIDFTPBANDWIDTHINFO[AVG_BW_RANGE4] + "=\""
209: + avg_bandwidth_range4.trim() + "\"";
210: }
211: if (avg_bandwidth != null) {
212: output += " " + GRIDFTPBANDWIDTHINFO[AVG_BW] + "=\""
213: + avg_bandwidth.trim() + "\"";
214: }
215: if (max_bandwidth != null) {
216: output += " " + GRIDFTPBANDWIDTHINFO[MAX_BW] + "=\""
217: + max_bandwidth.trim() + "\"";
218: }
219: if (min_bandwidth != null) {
220: output += " " + GRIDFTPBANDWIDTHINFO[MIN_BW] + "=\""
221: + min_bandwidth.trim() + "\"";
222: }
223:
224: output += " />\n";
225:
226: /**
227: * TODO:sk need to add code which picks up elements from gridftp_bandwidth
228: * and prints them out or adds them to the output String .
229: */
230:
231: return output;
232: }
233:
234: }
|