Neo4j

org.neo4j.kernel
Class AvailabilityGuard

java.lang.Object
  extended by org.neo4j.kernel.AvailabilityGuard

public class AvailabilityGuard
extends Object

The availability guard is what ensures that the database will only take calls when it is in an ok state. It allows query handling to easily determine if it is ok to call the database by calling isAvailable(long).

The implementation uses an atomic integer that is initialized to the nr of conditions that must be met for the database to be available. Each such condition will then call grant/deny accordingly, and if the integer becomes 0 access is granted.


Nested Class Summary
static interface AvailabilityGuard.AvailabilityListener
           
static interface AvailabilityGuard.AvailabilityRequirement
          Represents a description of why someone is denying access to the database, to help debugging.
 
Field Summary
static Function<AvailabilityGuard.AvailabilityRequirement,String> DESCRIPTION
           
 
Constructor Summary
AvailabilityGuard(Clock clock, int conditionCount)
           
 
Method Summary
 void addListener(AvailabilityGuard.AvailabilityListener listener)
           
 void deny(AvailabilityGuard.AvailabilityRequirement requirementNotMet)
           
 String describeWhoIsBlocking()
          Provide a textual description of what components, if any, are blocking access.
 void grant(AvailabilityGuard.AvailabilityRequirement requirementNowMet)
           
 boolean isAvailable(long millis)
          Determines if the database is available for transactions to use.
 void removeListener(AvailabilityGuard.AvailabilityListener listener)
           
 void shutdown()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DESCRIPTION

public static final Function<AvailabilityGuard.AvailabilityRequirement,String> DESCRIPTION
Constructor Detail

AvailabilityGuard

public AvailabilityGuard(Clock clock,
                         int conditionCount)
Method Detail

deny

public void deny(AvailabilityGuard.AvailabilityRequirement requirementNotMet)

grant

public void grant(AvailabilityGuard.AvailabilityRequirement requirementNowMet)

shutdown

public void shutdown()

isAvailable

public boolean isAvailable(long millis)
Determines if the database is available for transactions to use.

Parameters:
millis - to wait if not yet available.
Returns:
true if it is available, otherwise false. Returns false immediately if shutdown.

addListener

public void addListener(AvailabilityGuard.AvailabilityListener listener)

removeListener

public void removeListener(AvailabilityGuard.AvailabilityListener listener)

describeWhoIsBlocking

public String describeWhoIsBlocking()
Provide a textual description of what components, if any, are blocking access.


Neo4j

Copyright © 2002-2014 The Neo4j Graph Database Project. All Rights Reserved.