com.sun.sgs.impl.service.nodemap.affinity.dlpa.graph
Class BipartiteGraphBuilder

java.lang.Object
  extended by com.sun.sgs.impl.service.nodemap.affinity.BasicState
      extended by com.sun.sgs.impl.service.nodemap.affinity.graph.AbstractAffinityGraphBuilder
          extended by com.sun.sgs.impl.service.nodemap.affinity.dlpa.graph.BipartiteGraphBuilder
All Implemented Interfaces:
DLPAGraphBuilder, AffinityGraphBuilder

public class BipartiteGraphBuilder
extends AbstractAffinityGraphBuilder
implements DLPAGraphBuilder

A graph builder which builds a bipartite graph of identities and object ids, with edges between them. Identities are never linked with other edges, nor are object ids linked to other object ids.

This graph builder folds the graph upon request. The folded graph does not contain parallel edges.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.sun.sgs.impl.service.nodemap.affinity.BasicState
BasicState.State
 
Field Summary
 
Fields inherited from class com.sun.sgs.impl.service.nodemap.affinity.graph.AbstractAffinityGraphBuilder
DEFAULT_PERIOD, DEFAULT_PERIOD_COUNT, logger, PERIOD_COUNT_PROPERTY, PERIOD_PROPERTY, periodCount, PROP_BASE, snapshot, wrappedProps
 
Fields inherited from class com.sun.sgs.impl.service.nodemap.affinity.BasicState
state
 
Constructor Summary
BipartiteGraphBuilder(Properties properties, ComponentRegistry systemRegistry, TransactionProxy txnProxy)
          Constructs a new bipartite graph builder.
 
Method Summary
 void disable()
          Disables this builder.
 void enable()
          Enables this builder.
 edu.uci.ics.jung.graph.UndirectedGraph<LabelVertex,WeightedEdge> getAffinityGraph()
          Returns the current graph, with identities as vertices, and edges representing each object accessed by both identity endpoints.
 LPAAffinityGroupFinder getAffinityGroupFinder()
          Returns the affinity group finder created by this builder, or null if none was created.
 Map<Long,Map<Object,Long>> getConflictMap()
          Returns a map of detected cross node data conflicts.
 Map<Object,Map<Identity,Long>> getObjectUseMap()
          Returns a map of local object uses to the identities that used the objects, and a count of the number of uses.
 Runnable getPruneTask()
          Get the task which prunes the graph.
 LabelVertex getVertex(Identity id)
          Gets the graph vertex for the given Identity.
 void noteConflictDetected(Object objId, long nodeId, boolean forUpdate)
          TBD: This will be the implementation of our conflict detection listener.
 void removeNode(long nodeId)
          Note that a node has failed.
 void shutdown()
          Shuts down this builder.
 void updateGraph(Identity owner, AccessedObjectsDetail detail)
          Update the graph based on the objects accessed in a task.
 
Methods inherited from class com.sun.sgs.impl.service.nodemap.affinity.BasicState
checkForDisabledOrShutdownState, checkForShutdownState, setDisabledState, setEnabledState, setShutdownState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BipartiteGraphBuilder

public BipartiteGraphBuilder(Properties properties,
                             ComponentRegistry systemRegistry,
                             TransactionProxy txnProxy)
                      throws Exception
Constructs a new bipartite graph builder.

Parameters:
properties - the properties for configuring this builder
systemRegistry - the registry of available system components
txnProxy - the transaction proxy
Throws:
Exception - if an error occurs
Method Detail

updateGraph

public void updateGraph(Identity owner,
                        AccessedObjectsDetail detail)
Update the graph based on the objects accessed in a task. If the builder is disabled, does nothing.

Specified by:
updateGraph in interface AffinityGraphBuilder
Parameters:
owner - the task owner (the object making the accesses)
detail - detailed information about the object accesses, including a list of the accessed objects

getVertex

public LabelVertex getVertex(Identity id)
Gets the graph vertex for the given Identity.

Specified by:
getVertex in interface AffinityGraphBuilder
Parameters:
id - an identity
Returns:
the graph vertex for the identity, or null if there is no such vertex

getAffinityGraph

public edu.uci.ics.jung.graph.UndirectedGraph<LabelVertex,WeightedEdge> getAffinityGraph()
Returns the current graph, with identities as vertices, and edges representing each object accessed by both identity endpoints. An empty graph will be returned if there is no affinity data collected.

The returned graph can not be modified.

Specified by:
getAffinityGraph in interface AffinityGraphBuilder
Returns:
the graph of access information

getConflictMap

public Map<Long,Map<Object,Long>> getConflictMap()
Returns a map of detected cross node data conflicts. Conflicts occur when an object is in use by the current node but is needed by another node. This is a map of node IDs (the nodes requesting the object) to object IDs, and a count of the number of conflicts on the object with that node. An empty map will be returned if there are no conflicts. If more than one node needs an object at about the same time, it is only required that one node be recorded as a conflict.

Specified by:
getConflictMap in interface DLPAGraphBuilder
Returns:
the map of detected cross node data conflicts

getObjectUseMap

public Map<Object,Map<Identity,Long>> getObjectUseMap()
Returns a map of local object uses to the identities that used the objects, and a count of the number of uses. An empty map will be returned if there are no object uses.

Specified by:
getObjectUseMap in interface DLPAGraphBuilder
Returns:
the map of local object uses

noteConflictDetected

public void noteConflictDetected(Object objId,
                                 long nodeId,
                                 boolean forUpdate)
TBD: This will be the implementation of our conflict detection listener.

Parameters:
objId - the object that was evicted
nodeId - the node that caused the eviction
forUpdate - true if this eviction was for an update, false if it was for read only access

removeNode

public void removeNode(long nodeId)
Note that a node has failed. Does nothing if the nodeId is unknown or has already been noted as failed.

Specified by:
removeNode in interface DLPAGraphBuilder
Parameters:
nodeId - the id of the failed node

disable

public void disable()
Disables this builder. Disabled builders can be enabled or shutdown. Multiple calls to disable are allowed.

While disabled, no new graph updates are applied, but the graph pruners continue to discard old data.

Specified by:
disable in interface AffinityGraphBuilder

enable

public void enable()
Enables this builder. Enabled builders can be disabled or shutdown. Multiple calls to enable are allowed.

Specified by:
enable in interface AffinityGraphBuilder

shutdown

public void shutdown()
Shuts down this builder. Once shut down, a builder cannot be enabled or disabled. Multiple calls to shutdown are allowed.

Specified by:
shutdown in interface AffinityGraphBuilder

getAffinityGroupFinder

public LPAAffinityGroupFinder getAffinityGroupFinder()
Returns the affinity group finder created by this builder, or null if none was created. Some algorithms only create the finder on the server node.

Specified by:
getAffinityGroupFinder in interface AffinityGraphBuilder
Returns:
the affinity group finder or null

getPruneTask

public Runnable getPruneTask()
Get the task which prunes the graph. This is useful for testing.

Returns:
the runnable which prunes the graph.
Throws:
UnsupportedOperationException - if this builder does not support graph pruning.

RedDwarf, Version 0.10.1
2010-03-14 10:56:12

Copyright © 2010 The RedDwarf Authors. All rights reserved
Copyright © 2007-2010 Sun Microsystems, Inc. All rights reserved