org.edg.data.reptor.catalog
Class ReplicaCatalogLrcOnlyImpl

java.lang.Object
  extended byorg.edg.data.reptor.catalog.ReplicaCatalogLrcOnlyImpl
All Implemented Interfaces:
ReplicaCatalog

public final class ReplicaCatalogLrcOnlyImpl
extends java.lang.Object
implements ReplicaCatalog

The implementation of the high-level ReplicaCatalog interface using a single instance of each of the EDG replica location and replica metadata catalogs.

Version:
$Id: ReplicaCatalogLrcOnlyImpl.java,v 1.26 2004/08/10 15:56:46 jamesc Exp $
Author:
Peter Kunszt, James Casey

Constructor Summary
ReplicaCatalogLrcOnlyImpl(InfoService info)
          Create a new Single LRC Replica Catalog.
ReplicaCatalogLrcOnlyImpl(java.net.URI rlsUri, java.net.URI rmcUri)
           
 
Method Summary
 void addAlias(java.net.URI guid, java.net.URI lfn)
          add an alias to the rmc
 void addCatalogEntry(java.net.URI guid, java.net.URI surl)
          Create a new mapping in the catalog.
 void addFileInfo(java.net.URI guid, java.net.URI surl, FileInfo info, boolean consistencyCheck)
          Add the file info to the file identified by an SURL.
 void addLfnSurlMapping(java.net.URI lfn, java.net.URI surl)
          Create a logical name ot physical name mapping in the catalogs.
 boolean exists(java.net.URI uri)
          Given a URI, check if it is in the grid catalogs.
 boolean existsInRmc(java.net.URI uri)
          Given a URI, check if it is in the RMC.
 java.util.List getAllStorageFileNames(java.net.URI file)
          Returns the SURLs matching LFN or GUID in the LRC catalog.
 java.util.List getAllStorageFileNames(java.net.URI file, java.lang.String hostname)
          For this impl, the RLI is not there.
 FileInfo getFileInfo(java.net.URI file)
          Get the file info of a given file.
 org.edg.data.rls.EdgLocalReplicaCatalog getLocalLRC()
           
 java.util.Set getLogicalFileNames(java.net.URI uri)
          Retrieve all LFNs for a GUID, a SURL or an LFN.
 org.edg.data.rmc.EdgReplicaMetadataCatalog getRMC()
           
 java.util.List getSurlForHost(java.net.URI guid, java.lang.String seHost)
           
 void removeAlias(java.net.URI guid, java.net.URI lfn)
          remove an alias from the rmc
 void removeCatalogEntry(java.net.URI guid, java.net.URI surl)
          remove an entry from the local replica catalog
 void removeMetadataCatalogEntry(java.net.URI guid, java.net.URI lfn)
          Remove an entry from the Metadata Catalog.
static java.util.List reorderReplicas(java.util.List replicas, java.lang.String hostname)
           
 void setIgnorePrefixing()
          Set the value "ignorePrefix" to yes and thus ignore internal prefixes LFNs and GUIDs when contacting RLS/RMC
 java.net.URI translateToGuid(java.net.URI uri)
          Given a URI, find a guid that represents it, using the grid catalogs if needed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReplicaCatalogLrcOnlyImpl

public ReplicaCatalogLrcOnlyImpl(InfoService info)
Create a new Single LRC Replica Catalog. Always use the ReplicaCatalogFactory to create an instance of this object.

Parameters:
info - The InfoService to get the RLS by.

ReplicaCatalogLrcOnlyImpl

public ReplicaCatalogLrcOnlyImpl(java.net.URI rlsUri,
                                 java.net.URI rmcUri)
                          throws CatalogCommunicationException
Method Detail

exists

public boolean exists(java.net.URI uri)
               throws CatalogCommunicationException
Given a URI, check if it is in the grid catalogs. Note: If the URI is a GUID we check for it's existence in the replica location catalog.

Specified by:
exists in interface ReplicaCatalog
Parameters:
uri - the uri to check for.
Returns:
true if the uri exists in the catalog.
Throws:
CatalogCommunicationException

existsInRmc

public boolean existsInRmc(java.net.URI uri)
                    throws CatalogCommunicationException
Description copied from interface: ReplicaCatalog
Given a URI, check if it is in the RMC. Note: If the URI is a GUID we check for it's existence in the replica metadat catalog.

Specified by:
existsInRmc in interface ReplicaCatalog
Parameters:
uri - the uri to check for.
Returns:
true if the uri exists in the catalog.
Throws:
CatalogCommunicationException

translateToGuid

public java.net.URI translateToGuid(java.net.URI uri)
                             throws CatalogCommunicationException,
                                    org.edg.data.util.InvalidFileTypeException,
                                    LfnDoesNotExistException,
                                    SurlDoesNotExistException
Given a URI, find a guid that represents it, using the grid catalogs if needed.

Specified by:
translateToGuid in interface ReplicaCatalog
Parameters:
uri - the LFN or SURL to retrieve the GUID of
Returns:
the GUID
Throws:
CatalogCommunicationException - if the there is a problem with the lookup
org.edg.data.util.InvalidFileTypeException
LfnDoesNotExistException
SurlDoesNotExistException

getLogicalFileNames

public java.util.Set getLogicalFileNames(java.net.URI uri)
                                  throws CatalogCommunicationException,
                                         org.edg.data.util.InvalidFileTypeException,
                                         SurlDoesNotExistException,
                                         GUIDDoesNotExistException,
                                         IllegalArgumentException,
                                         LfnDoesNotExistException
Retrieve all LFNs for a GUID, a SURL or an LFN. Returns null if uri is null.

Specified by:
getLogicalFileNames in interface ReplicaCatalog
Parameters:
uri - the GUID, LFN or SURL to retrieve the LFNs of.
Returns:
a List of LFN URIs, not containing the GUID.
Throws:
CatalogCommunicationException - if the there is a problem with the lookup.
org.edg.data.util.InvalidFileTypeException - If the uri is not a recognised scheme
SurlDoesNotExistException
GUIDDoesNotExistException
IllegalArgumentException
LfnDoesNotExistException

getAllStorageFileNames

public java.util.List getAllStorageFileNames(java.net.URI file)
                                      throws CatalogCommunicationException,
                                             org.edg.data.util.InvalidFileTypeException,
                                             GUIDDoesNotExistException,
                                             LfnDoesNotExistException,
                                             SurlDoesNotExistException
Returns the SURLs matching LFN or GUID in the LRC catalog. If it gets passed an SURL, it returns all its replicas. (protocol prefixes like gsiftp are converted to 'srm'). Returns null if an invalid file type is specified.

Specified by:
getAllStorageFileNames in interface ReplicaCatalog
Parameters:
file - the LFN or GUID or SURL to get all replica SURLs of. This should not be null
Returns:
a list of SURL URI objects.
Throws:
CatalogCommunicationException
org.edg.data.util.InvalidFileTypeException
GUIDDoesNotExistException
LfnDoesNotExistException
SurlDoesNotExistException

getAllStorageFileNames

public java.util.List getAllStorageFileNames(java.net.URI file,
                                             java.lang.String hostname)
                                      throws CatalogCommunicationException,
                                             org.edg.data.util.InvalidFileTypeException,
                                             GUIDDoesNotExistException,
                                             SurlDoesNotExistException,
                                             LfnDoesNotExistException
For this impl, the RLI is not there. All == local.

Specified by:
getAllStorageFileNames in interface ReplicaCatalog
Parameters:
file - the LFN or GUID or SURL to get all replica SURLs of. This should not be null
Returns:
a Set of SURL URI objects.
Throws:
CatalogCommunicationException
org.edg.data.util.InvalidFileTypeException
GUIDDoesNotExistException
SurlDoesNotExistException
LfnDoesNotExistException

reorderReplicas

public static java.util.List reorderReplicas(java.util.List replicas,
                                             java.lang.String hostname)

addCatalogEntry

public void addCatalogEntry(java.net.URI guid,
                            java.net.URI surl)
                     throws CatalogCommunicationException,
                            SurlExistsException,
                            org.edg.data.util.InvalidFileTypeException
Create a new mapping in the catalog. If the guid already exists, all of the logical names are also updated with this mapping.

Specified by:
addCatalogEntry in interface ReplicaCatalog
Parameters:
guid - the guid to add
surl - the surl it is mapped to
Throws:
CatalogCommunicationException - on failure
SurlExistsException - surl already exists
org.edg.data.util.InvalidFileTypeException

addLfnSurlMapping

public void addLfnSurlMapping(java.net.URI lfn,
                              java.net.URI surl)
                       throws org.edg.data.util.InvalidFileTypeException,
                              CatalogCommunicationException,
                              LfnExistsException,
                              SurlDoesNotExistException,
                              LfnDoesNotExistException
Create a logical name ot physical name mapping in the catalogs. If the lfn already exists but for a different GUID, an exception is thrown. If it is a new lfn, the mappings of all replicas to the surl are also updated.

Specified by:
addLfnSurlMapping in interface ReplicaCatalog
Parameters:
lfn -
surl -
Throws:
org.edg.data.util.InvalidFileTypeException
CatalogCommunicationException
LfnExistsException
SurlDoesNotExistException
LfnDoesNotExistException

removeMetadataCatalogEntry

public void removeMetadataCatalogEntry(java.net.URI guid,
                                       java.net.URI lfn)
                                throws CatalogCommunicationException
Remove an entry from the Metadata Catalog.

Specified by:
removeMetadataCatalogEntry in interface ReplicaCatalog
Parameters:
guid - The guid for the metadata catalog mapping to remove
lfn - The alias for the mapping to remove
Throws:
CatalogCommunicationException

removeCatalogEntry

public void removeCatalogEntry(java.net.URI guid,
                               java.net.URI surl)
                        throws CatalogCommunicationException,
                               GUIDDoesNotExistException,
                               IllegalArgumentException
remove an entry from the local replica catalog

Specified by:
removeCatalogEntry in interface ReplicaCatalog
Parameters:
guid -
surl -
Throws:
CatalogCommunicationException
GUIDDoesNotExistException
IllegalArgumentException

addAlias

public void addAlias(java.net.URI guid,
                     java.net.URI lfn)
              throws org.edg.data.util.InvalidFileTypeException,
                     CatalogCommunicationException,
                     LfnExistsException
add an alias to the rmc

Specified by:
addAlias in interface ReplicaCatalog
Parameters:
guid -
lfn -
Throws:
CatalogCommunicationException
org.edg.data.util.InvalidFileTypeException
LfnExistsException

removeAlias

public void removeAlias(java.net.URI guid,
                        java.net.URI lfn)
                 throws org.edg.data.util.InvalidFileTypeException,
                        CatalogCommunicationException
remove an alias from the rmc

Specified by:
removeAlias in interface ReplicaCatalog
Parameters:
guid -
lfn -
Throws:
CatalogCommunicationException
org.edg.data.util.InvalidFileTypeException

addFileInfo

public void addFileInfo(java.net.URI guid,
                        java.net.URI surl,
                        FileInfo info,
                        boolean consistencyCheck)
                 throws CatalogCommunicationException,
                        org.edg.data.util.InvalidFileTypeException,
                        InvalidInfoException,
                        GUIDDoesNotExistException
Add the file info to the file identified by an SURL. The file info will be updated if it already exists! Implement it here with RLS attributes.

Specified by:
addFileInfo in interface ReplicaCatalog
Parameters:
surl - an SURL.
guid - the GUID.
info -
Throws:
CatalogCommunicationException - if file does not exist.
org.edg.data.util.InvalidFileTypeException
InvalidInfoException
GUIDDoesNotExistException

getSurlForHost

public java.util.List getSurlForHost(java.net.URI guid,
                                     java.lang.String seHost)
                              throws CatalogCommunicationException,
                                     GUIDDoesNotExistException
Specified by:
getSurlForHost in interface ReplicaCatalog
Throws:
CatalogCommunicationException
GUIDDoesNotExistException

getFileInfo

public FileInfo getFileInfo(java.net.URI file)
                     throws CatalogCommunicationException,
                            org.edg.data.util.InvalidFileTypeException,
                            SurlDoesNotExistException,
                            LfnDoesNotExistException
Get the file info of a given file. It can be a surl, lfn or guid. The SEInfo object will only be filled if the file is a surl, i.e. its host is a recognized SE host. Returns null if file does not exist.

Specified by:
getFileInfo in interface ReplicaCatalog
Parameters:
file - SURL, GUID or LFN.
Returns:
FileInfo object
Throws:
CatalogCommunicationException - if file is not valid or if it does not exist.
org.edg.data.util.InvalidFileTypeException
SurlDoesNotExistException
LfnDoesNotExistException

getLocalLRC

public org.edg.data.rls.EdgLocalReplicaCatalog getLocalLRC()
                                                    throws CatalogCommunicationException
Specified by:
getLocalLRC in interface ReplicaCatalog
Throws:
CatalogCommunicationException

getRMC

public org.edg.data.rmc.EdgReplicaMetadataCatalog getRMC()
                                                  throws CatalogCommunicationException
Specified by:
getRMC in interface ReplicaCatalog
Throws:
CatalogCommunicationException

setIgnorePrefixing

public void setIgnorePrefixing()
Set the value "ignorePrefix" to yes and thus ignore internal prefixes LFNs and GUIDs when contacting RLS/RMC

Specified by:
setIgnorePrefixing in interface ReplicaCatalog