org.lockss.protocol.V3LcapMessage Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lockss-core Show documentation
Show all versions of lockss-core Show documentation
The Slimmed Down LOCKSS Daemon Core
The newest version!
/*
Copyright (c) 2000-2024 Board of Trustees of Leland Stanford Jr. University,
all rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
STANFORD UNIVERSITY BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of Stanford University shall not
be used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from Stanford University.
*/
package org.lockss.protocol;
import java.io.*;
import java.util.*;
import org.mortbay.util.*;
import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream;
import org.lockss.app.*;
import org.lockss.config.*;
import org.lockss.plugin.*;
import org.lockss.poller.*;
import org.lockss.util.*;
import org.lockss.util.StringUtil;
import org.lockss.util.io.FileUtil;
import org.lockss.util.io.LockssSerializable;
import org.lockss.util.time.TimeBase;
/**
* Class that encapsulates a V3 LCAP message that has been received or will be
* sent over the wire.
*
* V3 LCAP Messages are not carried over UDP, so their encoded forms are not
* required to fit in one UDP packet. They do not have Lower and Upper bounds
* or remainders like V1 LCAP Messages.
*/
public class V3LcapMessage extends LcapMessage implements LockssSerializable {
/** Maximum allowable size of repair data before storing on disk */
public static final String PARAM_REPAIR_DATA_THRESHOLD =
Configuration.PREFIX + "poll.v3.repairDataThreshold";
public static final int DEFAULT_REPAIR_DATA_THRESHOLD = 1024*32; // 32K
static final int EST_ENCODED_HEADER_LENGTH = 100;
public static final int MSG_POLL = 10;
public static final int MSG_POLL_ACK = 11;
public static final int MSG_POLL_PROOF = 12;
public static final int MSG_NOMINATE = 13;
public static final int MSG_VOTE_REQ = 14;
public static final int MSG_VOTE = 15;
public static final int MSG_REPAIR_REQ = 16;
public static final int MSG_REPAIR_REP = 17;
public static final int MSG_EVALUATION_RECEIPT = 18;
public static final int MSG_NO_OP = 19;
public static final int POLL_MESSAGES_BASE = 10;
public static final String[] POLL_MESSAGES = { "Poll", "PollAck", "PollProof",
"Nominate", "VoteRequest", "Vote", "RepairReq", "RepairRep",
"EvaluationReceipt", "NoOp" };
private static Logger log = Logger.getLogger();
// Poll rejection codes.
public static enum PollNak {
NAK_GROUP_MISMATCH {
public String toString() { return "Wrong Group"; }
},
NAK_VERSION_MISMATCH {
public String toString() { return "Incompatible minor poll version"; }
},
NAK_NO_TIME {
public String toString() { return "Too Busy"; }
},
NAK_UNKNOWN {
public String toString() { return "Unknown"; }
},
NAK_NO_AU {
public String toString() { return "No AU"; }
},
NAK_NO_SUBSTANCE {
public String toString() {
return "AU has no files containing substantial content"; }
},
NAK_PLUGIN_VERSION_MISMATCH {
public String toString() { return "Plugin Version Mismatch"; }
},
NAK_DISABLED {
public String toString() { return "Disabled"; }
},
NAK_NOT_CRAWLED {
public String toString() { return "Not crawled"; }
},
NAK_TOO_MANY_VOTERS {
public String toString() { return "Voter Limit"; }
},
NAK_HASH_TIMEOUT {
public String toString() { return "Hash Timeout"; }
},
NAK_HASH_ERROR {
public String toString() { return "Hash Error"; }
},
NAK_INSUFFICIENT_VOTE_DURATION {
public String toString() { return "Insufficient Vote Duration"; }
},
NAK_HAVE_SUFFICIENT_REPAIRERS {
public String toString() { return "AU is safe"; }
},
NAK_NOT_READY {
public String toString() { return "Not ready"; }
}
};
// V3 Protocol revision history:
// 6 - LOCKSS 1.0 - 2.0 compatibility. V1 handles URLs with
// trailing slash correctly
// 5 - Changed HtmlParser to scan the content of