public class InMemoryAssignmentBackend extends Object implements 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
ConcurrentHashMap
is ok.Constructor and Description |
---|
InMemoryAssignmentBackend() |
Modifier and Type | Method and Description |
---|---|
List<String> |
assignments()
List all the storm runtime ids of local assignments.
|
Map<String,Assignment> |
assignmentsInfo()
Get all the local assignments of local state.
|
void |
clearStateForStorm(String stormId)
Clear all the state for a storm.
|
void |
close()
Function to release resource.
|
void |
deleteStormId(String stormName)
Delete a local cache of stormId which is mapped to a specific storm name.
|
Assignment |
getAssignment(String stormId)
Get assignment as
Assignment for a storm. |
String |
getStormId(String stormName)
Get storm runtime id from local.
|
boolean |
isSynchronized()
Decide if the assignments is synchronized from remote state-store.
|
void |
keepOrUpdateAssignment(String stormId,
Assignment assignment)
Keep a storm assignment to local state or update old assignment.
|
void |
keepStormId(String stormName,
String stormId)
Keep a mapping storm-name -> storm-id to local state.
|
void |
prepare(Map conf)
Initial function for creating backend.
|
void |
removeAssignment(String stormId) |
void |
setSynchronized()
Mark this backend as synchronized when sync work is done.
|
void |
syncRemoteAssignments(Map<String,byte[]> remote)
Sync remote assignments to local, if remote is null, we will sync it from zk.
|
void |
syncRemoteIds(Map<String,String> remote)
Sync remote storm ids to local, will just used for nimbus.
|
public boolean isSynchronized()
ILocalAssignmentsBackend
Decide if the assignments is synchronized from remote state-store.
isSynchronized
in interface ILocalAssignmentsBackend
public void setSynchronized()
ILocalAssignmentsBackend
Mark this backend as synchronized when sync work is done.
setSynchronized
in interface ILocalAssignmentsBackend
public void prepare(Map conf)
ILocalAssignmentsBackend
Initial function for creating backend.
prepare
in interface ILocalAssignmentsBackend
conf
- configpublic void keepOrUpdateAssignment(String stormId, Assignment assignment)
ILocalAssignmentsBackend
Keep a storm assignment to local state or update old assignment.
keepOrUpdateAssignment
in interface ILocalAssignmentsBackend
stormId
- storm runtime idassignment
- assignment as thriftpublic Assignment getAssignment(String stormId)
ILocalAssignmentsBackend
Get assignment as Assignment
for a storm.
getAssignment
in interface ILocalAssignmentsBackend
stormId
- storm runtime idpublic void removeAssignment(String stormId)
removeAssignment
in interface ILocalAssignmentsBackend
public List<String> assignments()
ILocalAssignmentsBackend
List all the storm runtime ids of local assignments.
assignments
in interface ILocalAssignmentsBackend
public Map<String,Assignment> assignmentsInfo()
ILocalAssignmentsBackend
Get all the local assignments of local state.
assignmentsInfo
in interface ILocalAssignmentsBackend
public void syncRemoteAssignments(Map<String,byte[]> remote)
ILocalAssignmentsBackend
Sync remote assignments to local, if remote is null, we will sync it from zk.
syncRemoteAssignments
in interface ILocalAssignmentsBackend
remote
- specific remote assignments, if it is null, it will sync from zookeeper[only used for nimbus]public void keepStormId(String stormName, String stormId)
ILocalAssignmentsBackend
Keep a mapping storm-name -> storm-id to local state.
keepStormId
in interface ILocalAssignmentsBackend
stormName
- storm namestormId
- storm runtime idpublic String getStormId(String stormName)
ILocalAssignmentsBackend
Get storm runtime id from local.
getStormId
in interface ILocalAssignmentsBackend
stormName
- name of a stormpublic void syncRemoteIds(Map<String,String> remote)
ILocalAssignmentsBackend
Sync remote storm ids to local, will just used for nimbus.
syncRemoteIds
in interface ILocalAssignmentsBackend
remote
- remote ids from state storepublic void deleteStormId(String stormName)
ILocalAssignmentsBackend
Delete a local cache of stormId which is mapped to a specific storm name.
deleteStormId
in interface ILocalAssignmentsBackend
stormName
- storm namepublic void clearStateForStorm(String stormId)
ILocalAssignmentsBackend
Clear all the state for a storm.
clearStateForStorm
in interface ILocalAssignmentsBackend
stormId
- storm idpublic void close()
ILocalAssignmentsBackend
Function to release resource.
close
in interface AutoCloseable
close
in interface ILocalAssignmentsBackend
Copyright © 2022 The Apache Software Foundation. All rights reserved.