com.waveset.provision
Class OpBucket

java.lang.Object
  extended bycom.waveset.provision.OpBucket

public class OpBucket
extends java.lang.Object

A helper class created to hold lists of ResourceOps. The "ordered" flag indicats that the ops must be processed in the order they appear in the list.

One of these will be created for each Application object encountered during a breadth first search that is marked as being ordered.

A single unordered bucket is created for those resources that are not contained in ordered applications.

A single bucket for delete ops is currently created, order will be specified according to dependency pointers between the ops themselves.


Field Summary
static java.lang.String code_id
           
 
Constructor Summary
OpBucket(boolean ordered)
           
 
Method Summary
 void add(ResourceOp op)
          Add an op to this bucket.
 void assimilate(OpBucket other)
          Merge one bucket with another.
 int checkFinished()
          Return the number of OPs in this bucket that are not yet finished.
 void clear()
          Clear the ops list in this bucket.
 void clearDependencies()
          Remove any resource dependnecies between OPs in this bucket, and the corresponding ResourceInfo objects.
 void dumpFile(java.lang.String file)
           
 void failDependentOps(ResourceOp failedOp)
          This op has failed, so we should fail all dependent ops
 ResourceOp find(java.lang.String id)
          Search for an OP in this bucket that references the resource with the given ID.
 ResourceOp getNextDependentOp()
          Return the next delete OP that may be processed.
 ResourceOp getNextOp()
          Return the next available OP for processing, or null if we're waiting for processing of a previous OP to complete.
 int getOpCount()
          Return the number of ops in the bucket.
 java.util.List getOps()
          Return the list of ops.
 void init()
          Called by provisioning engine when we're clearing processing state for another pass.
 boolean isFinished()
          Return true if this bucket is finished processing.
 boolean isOrdered()
          Test to see if the bucket is ordered.
 void remove(ResourceOp op)
          Remove an op from this bucket.
 void setDependencies()
          Set ResourceInfo dependencies according to the order of the ops in this bucket.
 java.lang.String toIdentityString()
           
 java.lang.String toVerboseString()
           
 java.lang.String toVerboseString(java.lang.String indent)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

code_id

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

OpBucket

public OpBucket(boolean ordered)
Method Detail

add

public void add(ResourceOp op)
Add an op to this bucket.


remove

public void remove(ResourceOp op)
Remove an op from this bucket.


getOpCount

public int getOpCount()
Return the number of ops in the bucket.


getOps

public java.util.List getOps()
Return the list of ops.


isOrdered

public boolean isOrdered()
Test to see if the bucket is ordered.


clear

public void clear()
Clear the ops list in this bucket. Leave ordered status intact.


init

public void init()
Called by provisioning engine when we're clearing processing state for another pass. Do NOT disrupt dependencies.


find

public ResourceOp find(java.lang.String id)
Search for an OP in this bucket that references the resource with the given ID. If there is more than one account on this resource we return the first one.


clearDependencies

public void clearDependencies()
Remove any resource dependnecies between OPs in this bucket, and the corresponding ResourceInfo objects.


setDependencies

public void setDependencies()
                     throws WavesetException
Set ResourceInfo dependencies according to the order of the ops in this bucket.

Throws:
WavesetException

assimilate

public void assimilate(OpBucket other)
Merge one bucket with another.


getNextOp

public ResourceOp getNextOp()
Return the next available OP for processing, or null if we're waiting for processing of a previous OP to complete. The op index is currently pointing at the next OP available for processing. We can return it if it is the first on the list, or the previous op is marked finished.

This was written prior to the introduction of the _dependentOp pointer in the ResourceOp. We could now combine this with getNextDependentOp, but the original implementation here is faster.


checkFinished

public int checkFinished()
Return the number of OPs in this bucket that are not yet finished.


isFinished

public boolean isFinished()
Return true if this bucket is finished processing.


getNextDependentOp

public ResourceOp getNextDependentOp()
Return the next delete OP that may be processed. I tried to think of a way to do this using multiple buckets, but my brain hurt, and it was faster just to do the dependency calculation at runtime. Can think about this again later, but this shouldn't be too bad. The dependencies will have been resolved, and cycles will have been broken.

We expect to be called only from getNextOp or another synchronized method.

If this list is long, there are certainly more optimal ways to search it. Might want to maintain a separate list of unprocessed ops?


failDependentOps

public void failDependentOps(ResourceOp failedOp)
This op has failed, so we should fail all dependent ops


dumpFile

public void dumpFile(java.lang.String file)

toIdentityString

public java.lang.String toIdentityString()

toVerboseString

public java.lang.String toVerboseString()

toVerboseString

public java.lang.String toVerboseString(java.lang.String indent)