001: /*
002: * Copyright 1999,2004 The Apache Software Foundation.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.apache.catalina.cluster.deploy;
018:
019: import org.apache.catalina.cluster.ClusterMessage;
020: import org.apache.catalina.cluster.Member;
021: import java.io.Externalizable;
022: import java.io.Serializable;
023: import java.io.IOException;
024: import java.io.ObjectOutput;
025: import java.io.ObjectInput;
026:
027: /**
028: * Contains the data for a file being transferred over TCP, this is
029: * essentially a fragment of a file, read and written by the FileMessageFactory
030: * @author Filip Hanik
031: * @version 1.0
032: */
033:
034: public class FileMessage implements ClusterMessage, Serializable {
035: private int messageNumber;
036: private byte[] data;
037: private int dataLength;
038: private org.apache.catalina.cluster.Member address;
039:
040: private long timestamp;
041: private long totalLength;
042: private long totalNrOfMsgs;
043: private String fileName;
044: private String contextPath;
045:
046: public FileMessage(Member source, String fileName,
047: String contextPath) {
048: this .address = source;
049: this .fileName = fileName;
050: this .contextPath = contextPath;
051: }
052:
053: /*
054: public void writeExternal(ObjectOutput out) throws IOException {
055:
056: }
057:
058: public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
059:
060: }
061: */
062:
063: public int getMessageNumber() {
064: return messageNumber;
065: }
066:
067: public void setMessageNumber(int messageNumber) {
068: this .messageNumber = messageNumber;
069: }
070:
071: public long getTotalNrOfMsgs() {
072: return totalNrOfMsgs;
073: }
074:
075: public void setTotalNrOfMsgs(long totalNrOfMsgs) {
076: this .totalNrOfMsgs = totalNrOfMsgs;
077: }
078:
079: public byte[] getData() {
080: return data;
081: }
082:
083: public void setData(byte[] data, int length) {
084: this .data = data;
085: this .dataLength = length;
086: }
087:
088: public int getDataLength() {
089: return dataLength;
090: }
091:
092: public void setDataLength(int dataLength) {
093: this .dataLength = dataLength;
094: }
095:
096: public long getTotalLength() {
097: return totalLength;
098: }
099:
100: public void setTotalLength(long totalLength) {
101: this .totalLength = totalLength;
102: }
103:
104: public org.apache.catalina.cluster.Member getAddress() {
105: return address;
106: }
107:
108: public void setAddress(org.apache.catalina.cluster.Member address) {
109: this .address = address;
110: }
111:
112: public String getUniqueId() {
113: StringBuffer result = new StringBuffer(getFileName());
114: result.append("#-#");
115: result.append(getMessageNumber());
116: result.append("#-#");
117: result.append(System.currentTimeMillis());
118: return result.toString();
119: }
120:
121: public long getTimestamp() {
122: return timestamp;
123: }
124:
125: public void setTimestamp(long timestamp) {
126: this .timestamp = timestamp;
127: }
128:
129: public String getFileName() {
130: return fileName;
131: }
132:
133: public void setFileName(String fileName) {
134: this .fileName = fileName;
135: }
136:
137: public String getContextPath() {
138: return contextPath;
139: }
140:
141: }
|