Ila

org.topoweb.ila.server.spi
Class MirrorImpl

java.lang.Object
  |
  +--org.topoweb.ila.server.spi.MirrorImpl
All Implemented Interfaces:
LocalMirror, Mirror, NodeConstants, StateConstants

public class MirrorImpl
extends java.lang.Object
implements LocalMirror, StateConstants

Base local Mirror implementation class. The methods in this class throw the following more specific IlaExceptions:

.

Author:
Babak Farhang
See Also:
DataAccessor

Field Summary
 
Fields inherited from interface org.topoweb.ila.NodeConstants
BACK, FIRST_PAGE, FORE, LAST_PAGE, LINK_MASK, PAGE_MASK
 
Fields inherited from interface org.topoweb.ila.StateConstants
NF, NK, NV, OK
 
Constructor Summary
MirrorImpl(DataAccessor db, ServiceProviderResolver resolver, CoLinkPolicy colinkPolicy)
          Creates a new instance with the given data accessor and co-link policy.
 
Method Summary
 void removeBacklink(org.topoweb.net.Ori src, Node dtn)
          Removes the specified backlink.
protected  Node setBacklink(org.topoweb.net.Ori src, Node dtn)
          Sets the specified backlink.
 Node setLink(org.topoweb.net.Ori src, int type, Node dtn)
          Sets a link of the specified type from the given source to destination node.
protected  Node updateForelink(org.topoweb.net.Ori src, Node dtn)
          Updates the specified forelink.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MirrorImpl

public MirrorImpl(DataAccessor db,
                  ServiceProviderResolver resolver,
                  CoLinkPolicy colinkPolicy)
Creates a new instance with the given data accessor and co-link policy. The resolver is used to ensure that the instance is the authority server for any given src ORI.

Parameters:
db - a data accessor implementation
resolver - the service resolver (used to do sanity checks on the arguments)
colinkPolicy - a co-link policy implementation
Method Detail

setLink

public Node setLink(org.topoweb.net.Ori src,
                    int type,
                    Node dtn)
             throws ResolutionException,
                    IntegrityException,
                    DataAccessorException,
                    IlaException
Description copied from interface: Mirror
Sets a link of the specified type from the given source to destination node. The caller is the authority on the destination node (dtn) and passes in state information about that node; the callee is the authority on the source node (src) and returns state information about the source. The callee typically updates state information about the src node (as a result of the invocation), as well as updating link entries before returning the src node.

Specified by:
setLink in interface Mirror
Parameters:
src - the ORI of the source node
type - the link type (either FORE or BACK)
dtn - information about the destination node
Returns:
a Node instance encapsulating authoritative knowledge about the state of the specified src node
Throws:
ResolutionException - if this server is not the authority on the src ORI
IlaException - if an error occurs
IntegrityException
DataAccessorException
See Also:
updateForelink(org.topoweb.net.Ori, org.topoweb.ila.Node), setBacklink(org.topoweb.net.Ori, org.topoweb.ila.Node)

updateForelink

protected Node updateForelink(org.topoweb.net.Ori src,
                              Node dtn)
                       throws DataAccessorException,
                              IntegrityException,
                              IlaException
Updates the specified forelink.

Parameters:
src - the ORI of the source node
dtn - the object encapsulating the state of the destination node.
Returns:
a node encapsulating the state of src; in the event the forelink no longer exists (this happens on a occasion before information has propagated across the system), then the returned Node will have NK status
Throws:
DataAccessorException - if the underlying data accessor throws it
IntegrityException - if there is a link w/o a corresponding entry for the State of the src
IlaException

setBacklink

protected Node setBacklink(org.topoweb.net.Ori src,
                           Node dtn)
                    throws DataAccessorException,
                           IntegrityException,
                           IlaException
Sets the specified backlink.

Parameters:
src - the ORI of the source node
dtn - the object encapsulating the state of the destination node.
Returns:
a node encapsulating the state of src; if nothing was known about src prior to this invocation, then it will be in the NV state; if the link didn't exist before, then the backlink count is incremented.
Throws:
DataAccessorException - if the underlying data accessor throws it
IntegrityException - if there is a link w/o a corresponding entry for the State of the src; if dtn is not in the OK state
IlaException

removeBacklink

public void removeBacklink(org.topoweb.net.Ori src,
                           Node dtn)
                    throws ResolutionException,
                           IntegrityException,
                           DataAccessorException,
                           IlaException
Description copied from interface: Mirror
Removes the specified backlink. Backlinks are removed when the destination node (dtn) no longer points to (no longer has a forelink to) to the source node (src).

Note

If the semantics of this seems confusing, recall that methods in this interface are named from the perspective of the callee, not the caller. It is the caller who is the authority on the dtn node and who knows that it no longer points to the src. Also, recall that we are removing a backlink, not a forelink: the forelink is handled directly by the callee.

Specified by:
removeBacklink in interface Mirror
Parameters:
src - the ORI of the source node
dtn - information about the destination node
Throws:
ResolutionException - if this server is not the authority on the src ORI
DataAccessorException - if the underlying data accessor throws it
IntegrityException - if there is a link w/o a corresponding entry for the State of the src; if dtn is in the NV state
IlaException - if an error occurs

Ila

Copyright (C) 2002 Babak Farhang

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.