|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.sun.multicast.allocation.StaticAllocator
A MulticastAddressAllocator for statically allocated addresses. This class allocates, deallocates, and otherwise manages multicast addresses using a static configuration file. It implements the MulticastAddressAllocator interface, so it may be used with other JRMS allocators through the MulticastAddressManager class. Most applications should access this class through the MulticastAddressManager class.
Each StaticAllocator keeps its state in a Properties object (and a few other data structures). In order to provide maximum reliability and because address allocations often persist across a long period of time, you may set a configuration file into which the allocator will save its state whenever it is changed. This allows address allocations to be preserved across multiple sessions. Since some platforms do not handle simultaneous file access well, each configuration file should be used by only one StaticAllocator object at once.
The initial state of the allocator may be read from a configuration file or a Properties object or set up by calling the addAddress method. Often, the configuration file is created by hand by an administrator, who enters multicast addresses into this file.
CAUTION:The addresses in the file need not be administratively scoped. However, caution should be used to ensure that there is no possibility of collisions (two hosts accidentally using the same address at the same time).
The configuration file is a property file in the format used by the java.util.Properties class. This file represents a list of properties. Each property consists of a key and a value, each of which is a String. There are two types of properties: scope properties and address state properties.
A scope property represents a scope in the scope list. The key for a scope property is a string of the form "Scope-N", where N is a number indicating the scope's position in the scope list (starting with 1 as the first scope in the list). The value has the form "startAddr-endAddr ttl name lang-tag", where startAddr and endAddr are the first and last addresses in the scope, ttl is the maximum ttl to be used within the scope, name is the name of the scope (surrounded by double quotes), and lang-tag is the language tag to be associated with the name. This format can't handle scope names that contain double quotes or scopes that have more than one name.
A lease property represents an existing lease. The key for a lease property is a string consisting of the letter "L", followed by a base64 encoding of the lease identifier. The value has the form "addressSet startTime duration", where addressSet consists of a left parenthesis, zero or more addressRanges separated by spaces, and a right parenthesis. startTime is a long representing the number of milliseconds since midnight GMT on January 1, 1970. duration is an int number of seconds. An addressRange is a starting address, a hyphen, and an ending address. And the addresses are IPv4 addresses in dotted decimal format.
The exact format of a property file is defined in The Java Language Specification. A typical line in a StaticAllocator configuration file looks like "LnTtc4jhWKJQaZLHQyGgLwQ\=\==(239.255.0.1-239.255.0.1)\ 938465910522\ -1". This line indicates a lease whose lease identifier is base64 encoded as "nTtc4jhWKJQaZLHQyGgLwQ==", which contains the single address 239.255.0.1, allocated from Sep 27, 1999 20:58:30 GMT for an indefinite period of time.
MulticastAddressManager
,
MulticastAddressAllocator
Constructor Summary | |
StaticAllocator()
Create a new StaticAllocator with no configuration file and no initial configuration. |
|
StaticAllocator(java.util.Properties props)
Create a new StaticAllocator with no configuration file and the specified initial configuration. |
|
StaticAllocator(java.lang.String path)
Create a new StaticAllocator using the specified configuration file. |
Method Summary | |
Lease |
allocateAddresses(Scope scope,
int ttl,
int count,
java.util.Date requestedStartTime,
java.util.Date requiredStartTime,
int requestedDuration,
int requiredDuration,
AddressSet addressesRequested)
Allocate one or more multicast addresses, matching the specified parameters. |
java.lang.Object |
clone()
Creates a new StaticAllocator object that works like this one and returns it to the caller. |
java.lang.String |
getAllocatorName()
Get the name used to identify the allocator. |
java.lang.String |
getConfigFilePath()
Gets the configuration file's path name. |
java.util.Properties |
getConfiguration()
Gets a Properties object that represents the current state of this object. |
ScopeList |
getScopeList(AddressType addressType)
Get the multicast scope list. |
void |
init()
Inform the allocator that the MulticastAddressManager is now managing it. |
void |
setConfigFilePath(java.lang.String path)
Sets the configuration file's path name. |
void |
setConfiguration(java.util.Properties props)
Sets the current state of this object based on a Properties object. |
void |
term()
Inform the allocator that the MulticastAddressManager is no longer managing it. |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public StaticAllocator() throws AddressAllocationException
AddressAllocationException
- if the allocator
could not be createdpublic StaticAllocator(java.util.Properties props) throws AddressAllocationException
AddressAllocationException
- if the allocator
could not be createdpublic StaticAllocator(java.lang.String path) throws AddressAllocationException
path
- the pathname of the configuration fileAddressAllocationException
- if the allocator
could not be createdMethod Detail |
public java.lang.String getConfigFilePath()
public void setConfigFilePath(java.lang.String path) throws AddressAllocationException
path
- the configuration file's path nameAddressAllocationException
- if the allocator
could not be createdpublic java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
- if an error occurspublic java.util.Properties getConfiguration() throws AddressAllocationException
AddressAllocationException
- if an error occurspublic void setConfiguration(java.util.Properties props) throws AddressAllocationException
props
- a Properties object that is used to set the current state
of this objectAddressAllocationException
- if an error occurspublic void init() throws AddressAllocationException
Note: This method should not be used by any classes other than MulticastAddressManager.
init
in interface MulticastAddressAllocator
AddressAllocationException
- if the allocator does
not want to be managedpublic void term()
Note: This method should not be used by any classes other than MulticastAddressManager.
term
in interface MulticastAddressAllocator
public java.lang.String getAllocatorName()
getAllocatorName
in interface MulticastAddressAllocator
com.sun.multicast.allocation.MulticastAddressAllocator
public ScopeList getScopeList(AddressType addressType) throws AddressAllocationException
getScopeList
in interface MulticastAddressAllocator
AddressAllocationException
- if an exception was encounteredpublic Lease allocateAddresses(Scope scope, int ttl, int count, java.util.Date requestedStartTime, java.util.Date requiredStartTime, int requestedDuration, int requiredDuration, AddressSet addressesRequested) throws AddressAllocationException, NoAddressAvailableException
This method is used by the MulticastAddressManager when its allocateAddresses method has been called.
allocateAddresses
in interface MulticastAddressAllocator
scope
- the administrative scope requestedttl
- the maximum ttl that will be usedcount
- the number of multicast addresses requested (usually one)requestedStartTime
- the requested start time (null if now)requiredStartTime
- the latest acceptable start time (null if now)requestedDuration
- the requested duration in seconds
(-1 if indefinite)requiredDuration
- the required duration in seconds
(-1 if indefinite)addressesRequested
- a requested address set (null if any will do)javax.jrms.addralloc.AddressAllocationException
- if an error
occurredjavax.jrms.addralloc.NoAddressAvailableException
- if no
address was available that met the requirements
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
JavaTM Reliable MulticastTM Service version 1.1
Copyright (c) 2001, Sun Microsystems Laboratories, All rights reserved.