org.tranche.configuration
Class Configuration

java.lang.Object
  extended by org.tranche.configuration.Configuration

public class Configuration
extends java.lang.Object

Configuration for a server, kept in memory

Author:
Jayson Falkner - jfalkner@umich.edu, Bryan E Smith , James "Augie" Hill - augman85@gmail.com

Field Summary
static java.lang.String DEFAULT_GROUP
           
static int SIZE_MAX_HASH_SPANS
           
static int VERSION_ONE
          Flag for version one.
static int VERSION_TWO
          Flag for version two.
 
Constructor Summary
Configuration()
           
 
Method Summary
 void addDataDirectory(DataDirectoryConfiguration dataDirectory)
          Adds the given data directory to the set of data directories on this server.
 void addHashSpan(HashSpan hashSpan)
          Adds the given hash span to this server.
 void addServerConfig(ServerConfiguration serverConfig)
          Adds the given server configuration to the list of server configurations on this server.
 void addStickyProject(BigHash projectHash)
          Make the project with the given hash as a sticky to this server.
 void addTargetHashSpan(HashSpan targetHashSpan)
          Adds the given target hash span to this server.
 void addUser(User user)
          Adds the given user to the server.
 boolean canRead()
          Returns whether server mode flags are set to allow clients to read server's data.
 boolean canWrite()
          Returns whether server mode flags are set to allow clients to write data to server.
 void clearDataDirectories()
          Removes all the data directories from this server.
 void clearHashSpans()
          Removes all hash spans from this server.
 void clearServerConfigs()
          Clears the server configurations from this server.
 void clearStickyProjects()
          Remove all sticky projects from this server.
 void clearTargetHashSpans()
          Removes all hash spans from this server.
 void clearUsers()
          Clears the users from this server.
 Configuration clone()
          Create a deep copy of the configuration so in-memory copies aren't shared.
 java.util.Set<DataDirectoryConfiguration> getDataDirectories()
          Gets the data directories on this server.
 int getFlags()
          Gets the flags on this configuration.
 java.lang.String getGroup()
           
 java.util.Set<HashSpan> getHashSpans()
          Gets the hash spans for this server.
 java.lang.String getName()
           
 User getRecognizedUser(java.security.cert.X509Certificate cert)
          Get the User that corresponds to the given certificate.
 java.util.Set<ServerConfiguration> getServerConfigs()
          Gets the server configurations on this server.
 java.util.Set<BigHash> getStickyProjects()
          Gets the sticky projects for this server.
 java.util.Set<HashSpan> getTargetHashSpans()
          Gets the target hash spans for this server.
 java.util.Set<User> getUsers()
          Gets the set of users on the server.
 java.lang.String getValue(java.lang.String key)
          Retrieves value from configuration attributes.
 java.util.Set<java.lang.String> getValueKeys()
          Returns set of keys from local and network-wide attributes.
 java.util.Set<java.lang.String> getValueKeys(boolean includeNetworkKeys)
          Returns set of keys for attributes.
 boolean hasKey(java.lang.String key)
          Checks whether key is found in local or network-wide configuration attributes.
 boolean hasKey(java.lang.String key, boolean includeNetworkKeys)
          Checks whether key is found in network-wide configuration attributes.
 boolean isReadOnly()
          Deprecated. Use canRead() instead.
 boolean isVersionOne()
          Returns the flag for whether the configuration is first version.
static boolean isVersionOne(int flagVal)
          Checks the supplied flag for whether the configuration is first version.
 boolean isVersionTwo()
          Returns the flag for whether the configuration is second version.
static boolean isVersionTwo(int flagVal)
          Checks the supplied flag for whether the configuration is second version.
 boolean isWriteOnly()
          Deprecated. Use canWrite() instead.
 int numberKeyValuePairs()
          Returns total number of attribute pairs, including local and network-wide.
 int numberKeyValuePairs(boolean includeNetworkKeys)
          Returns total number of attribute pairs.
 void removeDataDirectory(DataDirectoryConfiguration dataDirectory)
          Removes the given data directory from the set of data directories on this server.
 void removeHashSpan(HashSpan hashSpan)
          Removes the given hash span from this server.
 boolean removeKeyValuePair(java.lang.String key)
          Removes a key/value pair from local server configuration attributes.
 void removeServerConfig(ServerConfiguration serverConfig)
          Removes the given server configuration to the list of server configurations on this server.
 void removeStickyProject(BigHash projectHash)
          Remove the sticky project with the given hash from this server.
 void removeTargetHashSpan(HashSpan targetHashSpan)
          Removes the given hash span from this server.
 void removeUser(User user)
          Removes the given user from the server.
 void setDataDirectories(java.util.Set<DataDirectoryConfiguration> dataDirectories)
          Sets the data directories for this server.
 void setFlags(int flags)
          Sets the flags for this configuration.
 void setHashSpans(java.util.Set<HashSpan> hashSpans)
          Sets the hash spans for this server.
 void setServerConfigs(java.util.Set<ServerConfiguration> serverConfigs)
          Sets the server configurations on this server.
 void setStickyProjects(java.util.Set<BigHash> stickyProjects)
          Makes the projects with the given hashes as sticky projects to this servers.
 void setTargetHashSpans(java.util.Set<HashSpan> newTargetHashSpans)
          Sets the target hash spans for this server.
 void setUsers(java.util.Set<User> users)
          Sets the given users on the server.
 void setValue(java.lang.String key, java.lang.String value)
          Add a key/value pair to local server's configuration.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION_ONE

public static final int VERSION_ONE

Flag for version one.


VERSION_TWO

public static final int VERSION_TWO

Flag for version two. Changes include:


SIZE_MAX_HASH_SPANS

public static final int SIZE_MAX_HASH_SPANS
See Also:
Constant Field Values

DEFAULT_GROUP

public static final java.lang.String DEFAULT_GROUP
See Also:
Constant Field Values
Constructor Detail

Configuration

public Configuration()
Method Detail

getDataDirectories

public java.util.Set<DataDirectoryConfiguration> getDataDirectories()

Gets the data directories on this server.

Returns:

setDataDirectories

public void setDataDirectories(java.util.Set<DataDirectoryConfiguration> dataDirectories)

Sets the data directories for this server.

Parameters:
dataDirectories -

addDataDirectory

public void addDataDirectory(DataDirectoryConfiguration dataDirectory)

Adds the given data directory to the set of data directories on this server.

Parameters:
dataDirectory -

removeDataDirectory

public void removeDataDirectory(DataDirectoryConfiguration dataDirectory)

Removes the given data directory from the set of data directories on this server.

Parameters:
dataDirectory -

clearDataDirectories

public void clearDataDirectories()

Removes all the data directories from this server.


getUsers

public java.util.Set<User> getUsers()

Gets the set of users on the server.

Returns:

setUsers

public void setUsers(java.util.Set<User> users)

Sets the given users on the server.

Parameters:
users -

addUser

public void addUser(User user)

Adds the given user to the server.

Parameters:
user -

removeUser

public void removeUser(User user)

Removes the given user from the server.

Parameters:
user -

clearUsers

public void clearUsers()

Clears the users from this server.


getServerConfigs

public java.util.Set<ServerConfiguration> getServerConfigs()

Gets the server configurations on this server.

Returns:

setServerConfigs

public void setServerConfigs(java.util.Set<ServerConfiguration> serverConfigs)

Sets the server configurations on this server.

Parameters:
serverConfigs -

addServerConfig

public void addServerConfig(ServerConfiguration serverConfig)

Adds the given server configuration to the list of server configurations on this server.

Parameters:
serverConfig -

removeServerConfig

public void removeServerConfig(ServerConfiguration serverConfig)

Removes the given server configuration to the list of server configurations on this server.

Parameters:
serverConfig -

clearServerConfigs

public void clearServerConfigs()

Clears the server configurations from this server.


getFlags

public int getFlags()

Gets the flags on this configuration.

Returns:

setFlags

public void setFlags(int flags)

Sets the flags for this configuration.

Parameters:
flags -

isVersionOne

public boolean isVersionOne()

Returns the flag for whether the configuration is first version.

Returns:

isVersionTwo

public boolean isVersionTwo()

Returns the flag for whether the configuration is second version.

Returns:

isVersionOne

public static boolean isVersionOne(int flagVal)

Checks the supplied flag for whether the configuration is first version.

Returns:

isVersionTwo

public static boolean isVersionTwo(int flagVal)

Checks the supplied flag for whether the configuration is second version.

Returns:

getRecognizedUser

public User getRecognizedUser(java.security.cert.X509Certificate cert)

Get the User that corresponds to the given certificate.

Parameters:
cert -
Returns:

getHashSpans

public java.util.Set<HashSpan> getHashSpans()

Gets the hash spans for this server.

Returns:

setHashSpans

public void setHashSpans(java.util.Set<HashSpan> hashSpans)
                  throws java.lang.Exception

Sets the hash spans for this server.

Parameters:
hashSpans -
Throws:
java.lang.Exception

addHashSpan

public void addHashSpan(HashSpan hashSpan)
                 throws java.lang.Exception

Adds the given hash span to this server.

Parameters:
hashSpan -
Throws:
java.lang.Exception

removeHashSpan

public void removeHashSpan(HashSpan hashSpan)

Removes the given hash span from this server.

Parameters:
hashSpan -

clearHashSpans

public void clearHashSpans()

Removes all hash spans from this server.


getTargetHashSpans

public java.util.Set<HashSpan> getTargetHashSpans()

Gets the target hash spans for this server.

Returns:

setTargetHashSpans

public void setTargetHashSpans(java.util.Set<HashSpan> newTargetHashSpans)
                        throws java.lang.Exception

Sets the target hash spans for this server.

Parameters:
newTargetHashSpans -
Throws:
java.lang.Exception

addTargetHashSpan

public void addTargetHashSpan(HashSpan targetHashSpan)
                       throws java.lang.Exception

Adds the given target hash span to this server.

Parameters:
targetHashSpan -
Throws:
java.lang.Exception

removeTargetHashSpan

public void removeTargetHashSpan(HashSpan targetHashSpan)

Removes the given hash span from this server.

Parameters:
targetHashSpan -

clearTargetHashSpans

public void clearTargetHashSpans()

Removes all hash spans from this server.


getStickyProjects

public java.util.Set<BigHash> getStickyProjects()

Gets the sticky projects for this server.

Returns:

setStickyProjects

public void setStickyProjects(java.util.Set<BigHash> stickyProjects)

Makes the projects with the given hashes as sticky projects to this servers.

Parameters:
stickyProjects -

addStickyProject

public void addStickyProject(BigHash projectHash)

Make the project with the given hash as a sticky to this server.

Parameters:
projectHash -

removeStickyProject

public void removeStickyProject(BigHash projectHash)

Remove the sticky project with the given hash from this server.

Parameters:
projectHash -

clearStickyProjects

public void clearStickyProjects()

Remove all sticky projects from this server.


getName

public java.lang.String getName()
Returns:

getGroup

public java.lang.String getGroup()
Returns:

isReadOnly

public boolean isReadOnly()
Deprecated. Use canRead() instead.

Is configuration set to read-only?

Returns:
See Also:
canRead(), canWrite()

isWriteOnly

public boolean isWriteOnly()
Deprecated. Use canWrite() instead.

Is configuration set to write-only?

Returns:
See Also:
canRead(), canWrite()

canRead

public boolean canRead()

Returns whether server mode flags are set to allow clients to read server's data.

Returns:

canWrite

public boolean canWrite()

Returns whether server mode flags are set to allow clients to write data to server.

Returns:

setValue

public void setValue(java.lang.String key,
                     java.lang.String value)

Add a key/value pair to local server's configuration.

Has no impact on server-wide configuration attributes. However, if set key is equal to key in server-wide configuration attributes, then local value is selected over network-wide value.

Parameters:
key -
value -

getValue

public java.lang.String getValue(java.lang.String key)

Retrieves value from configuration attributes. Looks for value first in local server attributes, and if not found, checks network-wide attributes.

Parameters:
key -
Returns:
Null if not found; otherwise, retruns value found in local or network-wide attributes

getValueKeys

public java.util.Set<java.lang.String> getValueKeys()

Returns set of keys from local and network-wide attributes.

Returns:

getValueKeys

public java.util.Set<java.lang.String> getValueKeys(boolean includeNetworkKeys)

Returns set of keys for attributes.

Parameters:
includeNetworkKeys - If true, will also include keys from network-wide attributes; otherwise, they will be excluded
Returns:

numberKeyValuePairs

public int numberKeyValuePairs()

Returns total number of attribute pairs, including local and network-wide.

If an attribute pair is found in both, it will only be counted once, since only one value will be used (the local value).

Returns:

numberKeyValuePairs

public int numberKeyValuePairs(boolean includeNetworkKeys)

Returns total number of attribute pairs.

Parameters:
includeNetworkKeys - If true, will also include keys from network-wide attributes; otherwise, they will be excluded
Returns:

hasKey

public boolean hasKey(java.lang.String key)

Checks whether key is found in local or network-wide configuration attributes.

Parameters:
key -
Returns:

hasKey

public boolean hasKey(java.lang.String key,
                      boolean includeNetworkKeys)

Checks whether key is found in network-wide configuration attributes.

Parameters:
key -
includeNetworkKeys - If true, will also include keys from network-wide attributes; otherwise, they will be excluded
Returns:

removeKeyValuePair

public boolean removeKeyValuePair(java.lang.String key)

Removes a key/value pair from local server configuration attributes. Has no effect if not present.

This has no impact on server-wide attributes. However, if remove a value that overrides network value, then the network value will be used.

Parameters:
key -
Returns:

clone

public Configuration clone()

Create a deep copy of the configuration so in-memory copies aren't shared.

Useful if want a separate copy of Configuration to edit without editting the original.

Overrides:
clone in class java.lang.Object
Returns:


This code is free for use both commercially and non-commercially as stated in the project's license