Package com.jalios.jstore.jsync
Class JSyncUtil
java.lang.Object
com.jalios.jstore.jsync.JSyncUtil
- All Implemented Interfaces:
JSyncConstants,JaliosConstants
This class provides utility methods
- Author:
- Olivier Dedieu
-
Field Summary
FieldsFields inherited from interface com.jalios.util.JaliosConstants
CRLF, MILLIS_IN_ONE_DAY, MILLIS_IN_ONE_HOUR, MILLIS_IN_ONE_MINUTE, MILLIS_IN_ONE_MONTH, MILLIS_IN_ONE_SECOND, MILLIS_IN_ONE_WEEK, MILLIS_IN_ONE_YEARFields inherited from interface com.jalios.jstore.jsync.JSyncConstants
HEADER_SECRET, SC_BAD_ADDRESS, SC_BAD_LEADER, SC_BAD_LOG_PREFIX, SC_BAD_MESSAGE, SC_CHECK_COMMIT_WORK_FAILED, SC_COMMIT_WORK_FAILED, SC_DISCONNECTED, SC_EMPTY_PT, SC_INCOMPATIBLE_LOG_FORMAT, SC_INTERNAL_SERVER_ERROR, SC_JOIN_REJECTED, SC_LEADER_CANNOT_JOIN, SC_NO_ACK, SC_NO_SEND, SC_OK, SC_UNKNOWN, SC_UNKNOWN_URID, SC_URID_ALREADY_ADDED, STATUS_DISCONNECTED, STATUS_LEADER, STATUS_LONE, STATUS_MEMBER, STATUS_SUBLEADER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancheckIP(javax.servlet.ServletRequest request, org.apache.oro.text.regex.Pattern ipPattern) static intcleanStatusCode(int status) static StringgetStatusPhrase(int status) Returns an english phrase associated to the given status code.static voidstatic AckMessagereadAck(InputStream in) Read and parse an AckMessagestatic AckMessageRead and parse an AckMessagestatic MessageRead and parse a Messagestatic MessagereadMessage(String responseBody) Read and parse a Messagestatic AckMessagesendMessage(String url, Message msg, String secret, int timeout) Send a messagestatic voidwriteAck(OutputStream out, String urid, int status, StampTable progressTable) Write an AckMessagestatic voidwriteMessage(OutputStream out, Message msg) Write a Message
-
Field Details
-
logger
public static final org.apache.log4j.Logger logger
-
-
Constructor Details
-
JSyncUtil
public JSyncUtil()
-
-
Method Details
-
sendMessage
Send a message- Parameters:
url- the url the message must be sent tomsg- the message to be sentsecret- the sharedSecrettimeout- request timeout- Returns:
- the AckMessage
- Since:
- jcms-4.1
-
writeAck
Write an AckMessage- Parameters:
out- the OutputStream to use for writing the messageurid- the URID of the senderstatus- the status codeprogressTable- the progressTable of the sender- Since:
- jcms-4.1
-
readAck
Read and parse an AckMessage- Parameters:
in- the InputStream that contains the message to be read- Returns:
- an AckMessage or null if the message have not been correctly parsed
- Since:
- jcms-4.1
-
readAck
Read and parse an AckMessage- Parameters:
responseBody- a string containing the message to be read, usually the response body of JSync http request.- Returns:
- an AckMessage or null if the message could not be parsed
- Since:
- jcms-5.7.5
-
writeMessage
Write a Message- Parameters:
out- the OutputStream to use for writing the messagemsg- the message to write- Since:
- jcms-4.1
-
readMessage
Read and parse a Message- Parameters:
in- the InputStream that contains the message to be read- Returns:
- an instance of a sub class of Message class, or null if the message have not been correctly parsed
- Throws:
org.jdom.JDOMException- if an error occursIOException- if an error occurs- Since:
- jcms-4.1
-
readMessage
Read and parse a Message- Parameters:
responseBody- a string containing the message to be read, usually the response body of JSync http request.- Returns:
- an instance of a sub class of Message class, or null if the message could not be parsed
- Throws:
org.jdom.JDOMException- if an error occursIOException- if an error occurs- Since:
- jcms-5.7.5
-
cleanStatusCode
public static int cleanStatusCode(int status) -
getStatusPhrase
Returns an english phrase associated to the given status code.- Parameters:
status- the status code- Returns:
- an english phrase associated to the given status code.
- Since:
- jcms-4.1
-
checkIP
public static boolean checkIP(javax.servlet.ServletRequest request, org.apache.oro.text.regex.Pattern ipPattern) -
main
-