public class ReplicationService extends BaseService
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
FORCEREPLICATEDELETE |
static java.lang.String |
FORCEREPLICATEDELETEALL |
static java.lang.String |
METACAT_REPL_ERROR_MSG |
static java.lang.String |
REPLICATION_LOG_FILE_NAME |
static java.lang.String |
REPLICATIONUSER |
_serviceName
Modifier and Type | Method and Description |
---|---|
protected void |
doRefresh() |
static java.lang.String |
getCatalogXML()
Returns the xml_catalog table encoded in xml
|
static java.lang.String |
getDocumentInfo(java.lang.String docid)
Gets a docInfo XML snippet for the replication API
|
static java.util.Hashtable<java.lang.String,java.lang.String> |
getDocumentInfoMap(java.lang.String docid) |
static int |
getHomeServerCodeForDocId(java.lang.String accNum)
Returns a home server location given a accnum
|
static java.util.Hashtable<java.lang.String,java.lang.String> |
getHomeServerInfoForDocId(java.lang.String docId)
Method to get a host server information for given docid
|
static ReplicationService |
getInstance()
Get the single instance of SessionService.
|
static int |
getServerCodeForServerName(java.lang.String server)
Returns a server code given a server name
|
static java.util.Map<java.lang.Integer,java.lang.String> |
getServerCodes()
Returns a Map of serverCode=serverName
|
static java.lang.String |
getServerNameForServerCode(int serverCode)
Returns the name of a server given a serverCode
|
static byte[] |
getURLBytes(java.net.URL u)
This method returns a byte array after opening a url
|
static java.lang.String |
getURLContent(java.net.URL u)
This method returns the content of a url
|
static java.io.InputStream |
getURLStream(java.net.URL u)
This method returns the InputStream after opening a url
|
protected static void |
handleForceReplicateDataFileRequest(java.util.Hashtable<java.lang.String,java.lang.String[]> params,
javax.servlet.http.HttpServletRequest request)
when a forcereplication data file request comes in, local host sends a
readdata request to the requesting server (remote server) for the specified
docid.
|
protected static void |
handleForceReplicateDeleteRequest(java.util.Hashtable<java.lang.String,java.lang.String[]> params,
javax.servlet.http.HttpServletResponse response,
javax.servlet.http.HttpServletRequest request,
boolean removeAll) |
protected static void |
handleForceReplicateRequest(java.util.Hashtable<java.lang.String,java.lang.String[]> params,
javax.servlet.http.HttpServletResponse response,
javax.servlet.http.HttpServletRequest request)
when a forcereplication request comes in, local host sends a read request
to the requesting server (remote server) for the specified docid.
|
protected static void |
handleForceReplicateSystemMetadataRequest(java.util.Hashtable<java.lang.String,java.lang.String[]> params,
javax.servlet.http.HttpServletResponse response,
javax.servlet.http.HttpServletRequest request)
when a forcereplication request comes in, local host sends a read request
to the requesting server (remote server) for the specified docid.
|
protected static java.lang.String |
handleGetCatalogRequest(java.util.Hashtable<java.lang.String,java.lang.String[]> params,
javax.servlet.http.HttpServletResponse response,
boolean printFlag)
Sends the contents of the xml_catalog table encoded in xml
The xml format is:
All of the sub elements of row are #PCDATA
If printFlag == false then do not print to out.
|
protected static void |
handleGetDataFileRequest(java.io.OutputStream outPut,
java.util.Hashtable<java.lang.String,java.lang.String[]> params,
javax.servlet.http.HttpServletResponse response)
Sends a datafile to a remote host
|
protected static void |
handleGetDocumentInfoRequest(java.util.Hashtable<java.lang.String,java.lang.String[]> params,
javax.servlet.http.HttpServletResponse response)
Sends all of the xml_documents information encoded in xml to a requestor
the format is:
all of the subelements of document info are #PCDATA
|
protected static void |
handleGetDocumentRequest(java.util.Hashtable<java.lang.String,java.lang.String[]> params,
javax.servlet.http.HttpServletResponse response)
Sends a document to a remote host
|
protected static void |
handleGetLockRequest(java.util.Hashtable<java.lang.String,java.lang.String[]> params,
javax.servlet.http.HttpServletResponse response)
Grants or denies a lock to a requesting host.
|
protected static void |
handleGetSystemMetadataRequest(java.util.Hashtable<java.lang.String,java.lang.String[]> params,
javax.servlet.http.HttpServletResponse response)
Sends System Metadata as XML
|
protected static void |
handleGetTimeRequest(java.util.Hashtable<java.lang.String,java.lang.String[]> params,
javax.servlet.http.HttpServletResponse response)
Sends the current system date to the remote server.
|
static void |
handleServerControlRequest(java.util.Hashtable<java.lang.String,java.lang.String[]> params,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
This method can add, delete and list the servers currently included in
xml_replication.
|
protected static void |
handleUpdateRequest(java.util.Hashtable<java.lang.String,java.lang.String[]> params,
javax.servlet.http.HttpServletResponse response)
Sends a list of all of the documents on this sever along with their
revision numbers.
|
boolean |
refreshable() |
static boolean |
replToServer(java.lang.String server)
Returns true if the replicate field for server in xml_replication is 1.
|
void |
run()
this method handles the timeout for a file lock.
|
void |
runOnce() |
void |
startReplication(java.util.Hashtable<java.lang.String,java.lang.String[]> params) |
void |
stop() |
void |
stopReplication() |
static void |
updateUserOwner(DBConnection dbConn,
java.lang.String docid,
java.lang.String owner,
java.lang.String updater) |
refresh
public static final java.lang.String FORCEREPLICATEDELETE
public static final java.lang.String FORCEREPLICATEDELETEALL
public static final java.lang.String REPLICATIONUSER
public static final java.lang.String REPLICATION_LOG_FILE_NAME
public static java.lang.String METACAT_REPL_ERROR_MSG
public static ReplicationService getInstance() throws ServiceException
ServiceException
public boolean refreshable()
refreshable
in class BaseService
protected void doRefresh() throws ServiceException
doRefresh
in class BaseService
ServiceException
public void stop() throws ServiceException
stop
in class BaseService
ServiceException
public void stopReplication() throws ServiceException
ServiceException
public void startReplication(java.util.Hashtable<java.lang.String,java.lang.String[]> params) throws ServiceException
ServiceException
public void runOnce() throws ServiceException
ServiceException
public static void handleServerControlRequest(java.util.Hashtable<java.lang.String,java.lang.String[]> params, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
protected static void handleForceReplicateRequest(java.util.Hashtable<java.lang.String,java.lang.String[]> params, javax.servlet.http.HttpServletResponse response, javax.servlet.http.HttpServletRequest request)
protected static void handleForceReplicateDeleteRequest(java.util.Hashtable<java.lang.String,java.lang.String[]> params, javax.servlet.http.HttpServletResponse response, javax.servlet.http.HttpServletRequest request, boolean removeAll)
protected static void handleForceReplicateDataFileRequest(java.util.Hashtable<java.lang.String,java.lang.String[]> params, javax.servlet.http.HttpServletRequest request)
protected static void handleGetLockRequest(java.util.Hashtable<java.lang.String,java.lang.String[]> params, javax.servlet.http.HttpServletResponse response)
protected static void handleGetDocumentInfoRequest(java.util.Hashtable<java.lang.String,java.lang.String[]> params, javax.servlet.http.HttpServletResponse response)
public static java.util.Hashtable<java.lang.String,java.lang.String> getDocumentInfoMap(java.lang.String docid) throws HandlerException, AccessControlException, org.dataone.exceptions.MarshallingException, java.io.IOException, McdbException, org.xml.sax.SAXException
HandlerException
AccessControlException
org.dataone.exceptions.MarshallingException
java.io.IOException
McdbException
org.xml.sax.SAXException
public static java.lang.String getDocumentInfo(java.lang.String docid) throws AccessControlException, org.dataone.exceptions.MarshallingException, java.io.IOException, McdbException
docid
- AccessControlException
JiBXException
java.io.IOException
McdbException
org.dataone.exceptions.MarshallingException
protected static void handleGetSystemMetadataRequest(java.util.Hashtable<java.lang.String,java.lang.String[]> params, javax.servlet.http.HttpServletResponse response)
protected static void handleForceReplicateSystemMetadataRequest(java.util.Hashtable<java.lang.String,java.lang.String[]> params, javax.servlet.http.HttpServletResponse response, javax.servlet.http.HttpServletRequest request)
protected static void handleGetDataFileRequest(java.io.OutputStream outPut, java.util.Hashtable<java.lang.String,java.lang.String[]> params, javax.servlet.http.HttpServletResponse response)
protected static void handleGetDocumentRequest(java.util.Hashtable<java.lang.String,java.lang.String[]> params, javax.servlet.http.HttpServletResponse response)
protected static void handleUpdateRequest(java.util.Hashtable<java.lang.String,java.lang.String[]> params, javax.servlet.http.HttpServletResponse response)
public static void updateUserOwner(DBConnection dbConn, java.lang.String docid, java.lang.String owner, java.lang.String updater) throws java.sql.SQLException
dbConn
- connection for doing the updatedocid
- the document id to updateowner
- the user_ownerupdater
- the user_updatedjava.sql.SQLException
public static java.lang.String getCatalogXML()
protected static java.lang.String handleGetCatalogRequest(java.util.Hashtable<java.lang.String,java.lang.String[]> params, javax.servlet.http.HttpServletResponse response, boolean printFlag)
protected static void handleGetTimeRequest(java.util.Hashtable<java.lang.String,java.lang.String[]> params, javax.servlet.http.HttpServletResponse response)
public void run()
public static java.lang.String getServerNameForServerCode(int serverCode)
serverCode
- the serverid of the serverpublic static int getServerCodeForServerName(java.lang.String server) throws ServiceException
server
- the name of the serverServiceException
public static java.util.Map<java.lang.Integer,java.lang.String> getServerCodes() throws ServiceException
ServiceException
public static java.util.Hashtable<java.lang.String,java.lang.String> getHomeServerInfoForDocId(java.lang.String docId)
conn
- a connection to the databasepublic static int getHomeServerCodeForDocId(java.lang.String accNum) throws ServiceException
accNum
- , given accNum for a documentServiceException
public static java.lang.String getURLContent(java.net.URL u) throws java.lang.Exception
u
- the url to return the content fromjava.io.IOException
java.lang.Exception
public static java.io.InputStream getURLStream(java.net.URL u) throws java.lang.Exception
u
- the url to return the content fromjava.io.IOException
java.lang.Exception
public static byte[] getURLBytes(java.net.URL u) throws java.lang.Exception
u
- the url to return the content fromjava.io.IOException
java.lang.Exception
public static boolean replToServer(java.lang.String server)
Copyright © 2020 Regents of the University of California. All Rights Reserved.