public class

ControllerContextProvider

extends Object
java.lang.Object
   ↳ org.apache.helix.controller.context.ControllerContextProvider

Class Overview

An interface for getting and setting ControllerContext objects, which will eventually be persisted and accessible across runs of the controller pipeline.

Summary

Public Constructors
ControllerContextProvider(Map<ContextIdControllerContext> contexts)
Instantiate with already-persisted controller contexts
Public Methods
boolean exists(ContextId contextId)
Check if a context exists
<T extends ControllerContext> T getContext(ContextId contextId, Class<T> contextClass)
Get a typed ControllerContext
ControllerContext getContext(ContextId contextId)
Get a base ControllerContext
Map<ContextIdControllerContext> getContexts()
Get all contexts, both persisted and pending
Map<ContextIdControllerContext> getPendingContexts()
Get all contexts that have been put, but not yet persisted
Set<ContextId> getRemovedContexts()
Get all context ids that have been marked for removal
void putContext(ContextId contextId, ControllerContext context)
Put a controller context, overwriting any existing ones
boolean putContext(ContextId contextId, ControllerContext context, boolean overwriteAllowed)
Put a controller context, specifying overwrite behavior
ControllerContext removeContext(ContextId contextId)
Remove a controller context
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public ControllerContextProvider (Map<ContextIdControllerContext> contexts)

Instantiate with already-persisted controller contexts

Public Methods

public boolean exists (ContextId contextId)

Check if a context exists

Parameters
contextId the id to look up
Returns
  • true if a context exists with that id, false otherwise

public T getContext (ContextId contextId, Class<T> contextClass)

Get a typed ControllerContext

Parameters
contextId the context id to look up
contextClass the class which the context should be returned as
Returns
  • a typed ControllerContext, or null if no context with given id is available for this type

public ControllerContext getContext (ContextId contextId)

Get a base ControllerContext

Parameters
contextId the context id to look up
Returns
  • a ControllerContext, or null if not found

public Map<ContextIdControllerContext> getContexts ()

Get all contexts, both persisted and pending

Returns
  • an immutable map of context id to context

public Map<ContextIdControllerContext> getPendingContexts ()

Get all contexts that have been put, but not yet persisted

Returns
  • an immutable map of context id to context

public Set<ContextId> getRemovedContexts ()

Get all context ids that have been marked for removal

Returns
  • a set of context ids

public void putContext (ContextId contextId, ControllerContext context)

Put a controller context, overwriting any existing ones

Parameters
contextId the id to set
context the context object

public boolean putContext (ContextId contextId, ControllerContext context, boolean overwriteAllowed)

Put a controller context, specifying overwrite behavior

Parameters
contextId the id to set
context the context object
overwriteAllowed true if existing objects can be overwritten, false otherwise
Returns
  • true if saved, false if an object with that id exists and overwrite is not allowed

public ControllerContext removeContext (ContextId contextId)

Remove a controller context

Parameters
contextId the id to remove
Returns
  • ControllerContext that was removed, or null