com.sun.sgs.impl.service.nodemap.affinity.single
Class SingleGraphBuilder

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.single.SingleGraphBuilder
All Implemented Interfaces:
AffinityGraphBuilder

public class SingleGraphBuilder
extends AbstractAffinityGraphBuilder
implements AffinityGraphBuilder

A minimal graph builder for single node testing. This is mostly a copy of the WeightedGraphBuilder, with the parts about node conflicts deleted.


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
SingleGraphBuilder(Properties properties, ComponentRegistry systemRegistry, TransactionProxy txnProxy)
          Creates a weighted graph builder and its JMX MBean.
SingleGraphBuilder(Properties properties, ComponentRegistry systemRegistry, TransactionProxy txnProxy, boolean needStats)
          Creates a weighted 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.
 Runnable getPruneTask()
          Get the task which prunes the graph.
 LabelVertex getVertex(Identity id)
          Gets the graph vertex for the given Identity.
 void setStats(AffinityGraphBuilderStats stats)
          Sets the JMX MBean for this builder.
 void shutdown()
          Shuts down this builder.
 void updateGraph(Identity owner, AccessedObjectsDetail detail)
          Update the graph based on the objects accessed in a task.
 void updateGraph(Identity owner, Object[] objIds)
          Updates the graph with the given identity and object ids.
 
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

SingleGraphBuilder

public SingleGraphBuilder(Properties properties,
                          ComponentRegistry systemRegistry,
                          TransactionProxy txnProxy)
                   throws Exception
Creates a weighted graph builder and its JMX MBean.

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

SingleGraphBuilder

public SingleGraphBuilder(Properties properties,
                          ComponentRegistry systemRegistry,
                          TransactionProxy txnProxy,
                          boolean needStats)
                   throws Exception
Creates a weighted graph builder. The JMX stats object may not be created; this is useful for wrapper objects to break object dependencies. If needStats is false, the stats object must be provided with a call to setStats or a NullPointerException will be thrown on the first call to updateGraph.

Parameters:
properties - the properties for configuring this builder
systemRegistry - the registry of available system components
txnProxy - the transaction proxy
needStats - true if stats should be constructed
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

updateGraph

public void updateGraph(Identity owner,
                        Object[] objIds)
Updates the graph with the given identity and object ids.

This method may be called by multiple threads and must protect itself from changes to data structures made by the pruner.

Parameters:
owner - the identity which accessed the objects
objIds - the object ids of objects accessed by the identity

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

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

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

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

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

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

setStats

public void setStats(AffinityGraphBuilderStats stats)
Sets the JMX MBean for this builder. This is useful for classes which wrap this object. Note that stats must be set before the first call to updateGraph, or a NullPointerException will occur.

Parameters:
stats - our JMX information

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