Package org.apache.storm.assignments
Class InMemoryAssignmentBackend
java.lang.Object
org.apache.storm.assignments.InMemoryAssignmentBackend
- All Implemented Interfaces:
- AutoCloseable,- ILocalAssignmentsBackend
An assignment backend which will keep all assignments and id-info in memory. Only used if no backend is specified internal.
 
About thread safe: idToAssignment,idToName,nameToId are all memory cache in nimbus local, for
- idToAssignment: nimbus will modify it and supervisors will sync it at fixed interval, so the assignments would come to eventual consistency.
- idToName: storm submitting/killing is guarded by the same lock, a ConcurrentHashMapis ok.
- nameToId: same as idToName.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionList all the storm runtime ids of local assignments.Get all the local assignments of local state.voidclearStateForStorm(String stormId) Clear all the state for a storm.voidclose()Function to release resource.voiddeleteStormId(String stormName) Delete a local cache of stormId which is mapped to a specific storm name.getAssignment(String stormId) Get assignment asAssignmentfor a storm.getStormId(String stormName) Get storm runtime id from local.booleanDecide if the assignments is synchronized from remote state-store.voidkeepOrUpdateAssignment(String stormId, Assignment assignment) Keep a storm assignment to local state or update old assignment.voidkeepStormId(String stormName, String stormId) Keep a mapping storm-name -> storm-id to local state.voidInitial function for creating backend.voidremoveAssignment(String stormId) voidMark this backend as synchronized when sync work is done.voidsyncRemoteAssignments(Map<String, byte[]> remote) Sync remote assignments to local, if remote is null, we will sync it from zk.voidsyncRemoteIds(Map<String, String> remote) Sync remote storm ids to local, will just used for nimbus.
- 
Constructor Details- 
InMemoryAssignmentBackendpublic InMemoryAssignmentBackend()
 
- 
- 
Method Details- 
isSynchronizedpublic boolean isSynchronized()Description copied from interface:ILocalAssignmentsBackendDecide if the assignments is synchronized from remote state-store.- Specified by:
- isSynchronizedin interface- ILocalAssignmentsBackend
 
- 
setSynchronizedpublic void setSynchronized()Description copied from interface:ILocalAssignmentsBackendMark this backend as synchronized when sync work is done.- Specified by:
- setSynchronizedin interface- ILocalAssignmentsBackend
 
- 
prepareDescription copied from interface:ILocalAssignmentsBackendInitial function for creating backend.- Specified by:
- preparein interface- ILocalAssignmentsBackend
- Parameters:
- conf- config
 
- 
keepOrUpdateAssignmentDescription copied from interface:ILocalAssignmentsBackendKeep a storm assignment to local state or update old assignment.- Specified by:
- keepOrUpdateAssignmentin interface- ILocalAssignmentsBackend
- Parameters:
- stormId- storm runtime id
- assignment- assignment as thrift
 
- 
getAssignmentDescription copied from interface:ILocalAssignmentsBackendGet assignment asAssignmentfor a storm.- Specified by:
- getAssignmentin interface- ILocalAssignmentsBackend
- Parameters:
- stormId- storm runtime id
- Returns:
- assignment
 
- 
removeAssignment- Specified by:
- removeAssignmentin interface- ILocalAssignmentsBackend
 
- 
assignmentsDescription copied from interface:ILocalAssignmentsBackendList all the storm runtime ids of local assignments.- Specified by:
- assignmentsin interface- ILocalAssignmentsBackend
- Returns:
- a list of storm ids
 
- 
assignmentsInfoDescription copied from interface:ILocalAssignmentsBackendGet all the local assignments of local state.- Specified by:
- assignmentsInfoin interface- ILocalAssignmentsBackend
- Returns:
- mapping of storm-id -> assignment
 
- 
syncRemoteAssignmentsDescription copied from interface:ILocalAssignmentsBackendSync remote assignments to local, if remote is null, we will sync it from zk.- Specified by:
- syncRemoteAssignmentsin interface- ILocalAssignmentsBackend
- Parameters:
- remote- specific remote assignments, if it is null, it will sync from zookeeper[only used for nimbus]
 
- 
keepStormIdDescription copied from interface:ILocalAssignmentsBackendKeep a mapping storm-name -> storm-id to local state.- Specified by:
- keepStormIdin interface- ILocalAssignmentsBackend
- Parameters:
- stormName- storm name
- stormId- storm runtime id
 
- 
getStormIdDescription copied from interface:ILocalAssignmentsBackendGet storm runtime id from local.- Specified by:
- getStormIdin interface- ILocalAssignmentsBackend
- Parameters:
- stormName- name of a storm
- Returns:
- runtime storm id
 
- 
syncRemoteIdsDescription copied from interface:ILocalAssignmentsBackendSync remote storm ids to local, will just used for nimbus.- Specified by:
- syncRemoteIdsin interface- ILocalAssignmentsBackend
- Parameters:
- remote- remote ids from state store
 
- 
deleteStormIdDescription copied from interface:ILocalAssignmentsBackendDelete a local cache of stormId which is mapped to a specific storm name.- Specified by:
- deleteStormIdin interface- ILocalAssignmentsBackend
- Parameters:
- stormName- storm name
 
- 
clearStateForStormDescription copied from interface:ILocalAssignmentsBackendClear all the state for a storm.- Specified by:
- clearStateForStormin interface- ILocalAssignmentsBackend
- Parameters:
- stormId- storm id
 
- 
closepublic void close()Description copied from interface:ILocalAssignmentsBackendFunction to release resource.- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- ILocalAssignmentsBackend
 
 
-