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.deploy;
019:
020: import java.io.Serializable;
021:
022: import org.apache.catalina.ha.ClusterMessage;
023: import org.apache.catalina.tribes.Member;
024: import org.apache.catalina.ha.ClusterMessageBase;
025:
026: /**
027: * Contains the data for a file being transferred over TCP, this is
028: * essentially a fragment of a file, read and written by the FileMessageFactory
029: * @author Filip Hanik
030: * @version 1.0
031: */
032:
033: public class FileMessage extends ClusterMessageBase implements
034: ClusterMessage, Serializable {
035: private int messageNumber;
036: private byte[] data;
037: private int dataLength;
038:
039: private long totalLength;
040: private long totalNrOfMsgs;
041: private String fileName;
042: private String contextPath;
043:
044: public FileMessage(Member source, String fileName,
045: String contextPath) {
046: this .address = source;
047: this .fileName = fileName;
048: this .contextPath = contextPath;
049: }
050:
051: /*
052: public void writeExternal(ObjectOutput out) throws IOException {
053:
054: }
055:
056: public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
057:
058: }
059: */
060:
061: public int getMessageNumber() {
062: return messageNumber;
063: }
064:
065: public void setMessageNumber(int messageNumber) {
066: this .messageNumber = messageNumber;
067: }
068:
069: public long getTotalNrOfMsgs() {
070: return totalNrOfMsgs;
071: }
072:
073: public void setTotalNrOfMsgs(long totalNrOfMsgs) {
074: this .totalNrOfMsgs = totalNrOfMsgs;
075: }
076:
077: public byte[] getData() {
078: return data;
079: }
080:
081: public void setData(byte[] data, int length) {
082: this .data = data;
083: this .dataLength = length;
084: }
085:
086: public int getDataLength() {
087: return dataLength;
088: }
089:
090: public void setDataLength(int dataLength) {
091: this .dataLength = dataLength;
092: }
093:
094: public long getTotalLength() {
095: return totalLength;
096: }
097:
098: public void setTotalLength(long totalLength) {
099: this .totalLength = totalLength;
100: }
101:
102: public String getUniqueId() {
103: StringBuffer result = new StringBuffer(getFileName());
104: result.append("#-#");
105: result.append(getMessageNumber());
106: result.append("#-#");
107: result.append(System.currentTimeMillis());
108: return result.toString();
109: }
110:
111: public String getFileName() {
112: return fileName;
113: }
114:
115: public void setFileName(String fileName) {
116: this .fileName = fileName;
117: }
118:
119: public String getContextPath() {
120: return contextPath;
121: }
122:
123: }
|