Package org.apache.storm.utils

## Class LocalState

- java.lang.Object
- - org.apache.storm.utils.LocalState

-     public class LocalState
      extends Object

  A simple, durable, atomic K/V database. *Very inefficient*, should only be used for occasional reads/writes. Every read/write hits disk.

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static org.slf4j.Logger` | `LOG` |
    `static String` | `LS_APPROVED_WORKERS` |
    `static String` | `LS_ID` |
    `static String` | `LS_LOCAL_ASSIGNMENTS` |
    `static String` | `LS_TOPO_HISTORY` |
    `static String` | `LS_WORKER_HEARTBEAT` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `LocalState​(String backingDir, boolean createBackingDir)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `addTopologyHistory​(LSTopoHistory lsTopoHistory)` |
    `void` | `cleanup​(int keepVersions)` |
    `void` | `filterOldTopologies​(long cutOffAge)` | Remove topologies from local state which are older than cutOffAge.
    `org.apache.storm.thrift.TBase` | `get​(String key)` |
    `Map<String,​Integer>` | `getApprovedWorkers()` |
    `Map<Integer,​LocalAssignment>` | `getLocalAssignmentsMap()` |
    `String` | `getSupervisorId()` |
    `List<LSTopoHistory>` | `getTopoHistoryList()` |
    `LSWorkerHeartbeat` | `getWorkerHeartBeat()` |
    `void` | `put​(String key, org.apache.storm.thrift.TBase val)` |
    `void` | `put​(String key, org.apache.storm.thrift.TBase val, boolean cleanup)` |
    `void` | `remove​(String key)` |
    `void` | `remove​(String key, boolean cleanup)` |
    `void` | `setApprovedWorkers​(Map<String,​Integer> approvedWorkers)` |
    `void` | `setLocalAssignmentsMap​(Map<Integer,​LocalAssignment> localAssignmentMap)` |
    `void` | `setSupervisorId​(String supervisorId)` |
    `void` | `setWorkerHeartBeat​(LSWorkerHeartbeat workerHeartBeat)` |
    `Map<String,​org.apache.storm.thrift.TBase>` | `snapshot()` |

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### LOG

          public static final org.slf4j.Logger LOG

    - #### LS_WORKER_HEARTBEAT

          public static final String LS_WORKER_HEARTBEAT

      See Also:
        Constant Field Values

    - #### LS_ID

          public static final String LS_ID

      See Also:
        Constant Field Values

    - #### LS_LOCAL_ASSIGNMENTS

          public static final String LS_LOCAL_ASSIGNMENTS

      See Also:
        Constant Field Values

    - #### LS_APPROVED_WORKERS

          public static final String LS_APPROVED_WORKERS

      See Also:
        Constant Field Values

    - #### LS_TOPO_HISTORY

          public static final String LS_TOPO_HISTORY

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### LocalState

          public LocalState​(String backingDir,
                            boolean createBackingDir)
                     throws IOException

      Throws:
        `IOException`

  - ### Method Detail

    - #### snapshot

          public Map<String,​org.apache.storm.thrift.TBase> snapshot()

    - #### get

          public org.apache.storm.thrift.TBase get​(String key)

    - #### put

          public void put​(String key,
                          org.apache.storm.thrift.TBase val)

    - #### put

          public void put​(String key,
                          org.apache.storm.thrift.TBase val,
                          boolean cleanup)

    - #### remove

          public void remove​(String key)

    - #### remove

          public void remove​(String key,
                             boolean cleanup)

    - #### cleanup

          public void cleanup​(int keepVersions)
                       throws IOException

      Throws:
        `IOException`

    - #### getTopoHistoryList

          public List<LSTopoHistory> getTopoHistoryList()

    - #### filterOldTopologies

          public void filterOldTopologies​(long cutOffAge)

      Remove topologies from local state which are older than cutOffAge.

    - #### addTopologyHistory

          public void addTopologyHistory​(LSTopoHistory lsTopoHistory)

    - #### getSupervisorId

          public String getSupervisorId()

    - #### setSupervisorId

          public void setSupervisorId​(String supervisorId)

    - #### getApprovedWorkers

          public Map<String,​Integer> getApprovedWorkers()

    - #### setApprovedWorkers

          public void setApprovedWorkers​(Map<String,​Integer> approvedWorkers)

    - #### getWorkerHeartBeat

          public LSWorkerHeartbeat getWorkerHeartBeat()

    - #### setWorkerHeartBeat

          public void setWorkerHeartBeat​(LSWorkerHeartbeat workerHeartBeat)

    - #### getLocalAssignmentsMap

          public Map<Integer,​LocalAssignment> getLocalAssignmentsMap()

    - #### setLocalAssignmentsMap

          public void setLocalAssignmentsMap​(Map<Integer,​LocalAssignment> localAssignmentMap)