edu.isi.pegasus.planner.catalog.site.classes

## Class DirectoryLayout

- java.lang.Object
- - edu.isi.pegasus.planner.catalog.site.classes.SiteData
  - - edu.isi.pegasus.planner.catalog.site.classes.AbstractSiteData
    - - edu.isi.pegasus.planner.catalog.site.classes.DirectoryLayout

All Implemented Interfaces:
  java.lang.Cloneable

Direct Known Subclasses:
  Directory, LocalDirectory, SharedDirectory, WorkerSharedDirectory

    public abstract class DirectoryLayout
    extends AbstractSiteData

An abstract base class that creates a directory type. It associates multiple file servers and an internal mount point.

Author:
  Karan Vahi

### Field Summary

Fields
`protected java.util.Map<FileServerType.OPERATION,java.util.List<FileServer>>` `mFileServers` The list of file servers that can be used to write to access this directory indexed by operation type.
`protected InternalMountPoint` `mInternalMount` The internal mount point for the directory.

### Constructor Summary

Constructors
Constructor and Description
`DirectoryLayout()` The default constructor.
`DirectoryLayout(DirectoryLayout directory)` The copy constructor
`DirectoryLayout(java.util.Map<FileServerType.OPERATION,java.util.List<FileServer>> fs, InternalMountPoint imt)` The overloaded constructor

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `addFileServer(FileServer server)` Adds a FileServer that can access this directory.
`java.lang.Object` `clone()` Returns the clone of the object.
`java.util.List<FileServer>` `getFileServers(FileServerType.OPERATION operation)` Selects all file servers and returns it matching an operation type.
`java.util.Iterator<FileServer>` `getFileServersIterator(FileServerType.OPERATION operation)` Returns at iterator to the file servers.
`InternalMountPoint` `getInternalMountPoint()` Returns the internal mount point for the directory.
`boolean` `hasFileServerForGETOperations()` A convenience method that retrieves whether the directory has a file server for get operations ( file server with type get and all )
`boolean` `hasFileServerForOperations(FileServerType.OPERATION operation)` A convenience method that retrieves whether the directory has a file server for a particular operation.
`boolean` `hasFileServerForPUTOperations()` A convenience method that retrieves whether the directory has a file server for put operations ( file server with type put and all )
`private void` `initialize()` Initializes the object
`private void` `initialize(java.util.Map<FileServerType.OPERATION,java.util.List<FileServer>> fs, InternalMountPoint imt)` Initializes the object
`boolean` `isEmpty()` A convenience method that returns true if all the attributes values are uninitialized or empty strings.
`void` `resetFileServers()` Resets the internal collection of file servers
`FileServer` `selectFileServer(FileServerType.OPERATION operation)` Selects a random file server and returns it matching an operation type.
`void` `setFileServers(java.util.List<FileServer> servers)` Sets the list of FileServers that can access this directory.
`void` `setInternalMountPoint(InternalMountPoint mountPoint)` Sets the internal mount point for the directory.

### Methods inherited from class edu.isi.pegasus.planner.catalog.site.classes.AbstractSiteData

`accept, toString, toXML, toXML, writeAttribute`

### Methods inherited from class java.lang.Object

`equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Field Detail

#### mFileServers

    protected java.util.Map<FileServerType.OPERATION,java.util.List<FileServer>> mFileServers

The list of file servers that can be used to write to access this directory indexed by operation type.

#### mInternalMount

    protected InternalMountPoint mInternalMount

The internal mount point for the directory.

### Constructor Detail

#### DirectoryLayout

    public DirectoryLayout()

The default constructor.

#### DirectoryLayout

    public DirectoryLayout(DirectoryLayout directory)

The copy constructor

#### DirectoryLayout

    public DirectoryLayout(java.util.Map<FileServerType.OPERATION,java.util.List<FileServer>> fs,
                           InternalMountPoint imt)

The overloaded constructor

Parameters:
  `fs` - map of file servers indexed by FileServer operation
  `imt` - the internal mount point.

### Method Detail

#### initialize

    private void initialize()

Initializes the object

#### initialize

    private void initialize(java.util.Map<FileServerType.OPERATION,java.util.List<FileServer>> fs,
                            InternalMountPoint imt)

Initializes the object

Parameters:
  `fs` - list of file servers indexed by operation type
  `imt` - the internal mount point.

#### addFileServer

    public void addFileServer(FileServer server)

Adds a FileServer that can access this directory.

Parameters:
  `server` - the file server.

#### setFileServers

    public void setFileServers(java.util.List<FileServer> servers)

Sets the list of FileServers that can access this directory.

Parameters:
  `servers` - the list of servers

#### selectFileServer

    public FileServer selectFileServer(FileServerType.OPERATION operation)

Selects a random file server and returns it matching an operation type. If not found matching the operation type it defaults back to the all operation server.

Parameters:
  `operation` - the operation for which the file server is required
Returns:
  FileServer else null

#### getFileServers

    public java.util.List<FileServer> getFileServers(FileServerType.OPERATION operation)

Selects all file servers and returns it matching an operation type.

Parameters:
  `operation` - the operation for which the file server is required
Returns:
  List of FileServer else null

#### hasFileServerForGETOperations

    public boolean hasFileServerForGETOperations()

A convenience method that retrieves whether the directory has a file server for get operations ( file server with type get and all )

Returns:
  boolean

#### hasFileServerForPUTOperations

    public boolean hasFileServerForPUTOperations()

A convenience method that retrieves whether the directory has a file server for put operations ( file server with type put and all )

Returns:
  boolean

#### hasFileServerForOperations

    public boolean hasFileServerForOperations(FileServerType.OPERATION operation)

A convenience method that retrieves whether the directory has a file server for a particular operation. Servers with operation type as ALL are also considered.

Parameters:
  `operation` - the operation for which we need the file servers
Returns:
  boolean

#### getFileServersIterator

    public java.util.Iterator<FileServer> getFileServersIterator(FileServerType.OPERATION operation)

Returns at iterator to the file servers.

Returns:
  Iterator<FileServer>

#### setInternalMountPoint

    public void setInternalMountPoint(InternalMountPoint mountPoint)

Sets the internal mount point for the directory.

Parameters:
  `mountPoint` - the internal mount point.

#### getInternalMountPoint

    public InternalMountPoint getInternalMountPoint()

Returns the internal mount point for the directory.

Returns:
  the internal mount point.

#### isEmpty

    public boolean isEmpty()

A convenience method that returns true if all the attributes values are uninitialized or empty strings. Useful for serializing the object as XML.

Returns:
  boolean

#### resetFileServers

    public void resetFileServers()

Resets the internal collection of file servers

#### clone

    public java.lang.Object clone()

Returns the clone of the object.

Overrides:
  `clone` in class `AbstractSiteData`
Returns:
  the clone