Package org.apache.storm.container.oci

## Class OciContainerManager

- java.lang.Object
- - org.apache.storm.container.oci.OciContainerManager

- All Implemented Interfaces:
    `ResourceIsolationInterface`
  Direct Known Subclasses:
    `DockerManager`, `RuncLibContainerManager`

      public abstract class OciContainerManager
      extends Object
      implements ResourceIsolationInterface

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `protected static class` | `OciContainerManager.CmdType` |

  - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected String` | `cgroupParent` |
    `protected String` | `cgroupRootPath` |
    `protected Map<String,​Object>` | `conf` |
    `protected String` | `memoryCgroupRootPath` |
    `protected MemoryCore` | `memoryCoreAtRoot` |
    `protected String` | `nscdPath` |
    `protected List<String>` | `readonlyBindmounts` |
    `protected List<String>` | `readwriteBindmounts` |
    `protected String` | `seccompJsonFile` |
    `protected String` | `stormHome` |
    `protected static String` | `TMP_DIR` |
    `protected Map<String,​Object>` | `validatedNumaMap` |
    `protected Map<String,​List<String>>` | `workerToCores` |
    `protected Map<String,​Integer>` | `workerToCpu` |
    `protected Map<String,​Integer>` | `workerToMemoryMb` |
    `protected Map<String,​String>` | `workerToMemoryZone` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `OciContainerManager()` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `cleanup​(String user, String workerId, int port)` | This function will be called when the worker needs to shutdown.
    `protected String` | `commandFilePath​(String dir, String commandTag)` |
    `protected String` | `getImageName​(Map<String,​Object> topoConf)` | Get image name from topology Conf.
    `long` | `getSystemFreeMemoryMb()` | Get the amount of free memory in MB.
    `void` | `prepare​(Map<String,​Object> conf)` | Called when starting up.
    `void` | `reserveResourcesForWorker​(String workerId, Integer workerMemoryMb, Integer workerCpu, String numaId)` | This function should be used prior to starting the worker to reserve resources for the worker.
    `protected String` | `writeToCommandFile​(String workerDir, String command, String commandTag)` |

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

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

    - ### Methods inherited from interface org.apache.storm.container.ResourceIsolationInterface

      `areAllProcessesDead, forceKill, getMemoryUsage, isResourceManaged, kill, launchWorkerProcess, runProfilingCommand`

- - ### Field Detail

    - #### conf

          protected Map<String,​Object> conf

    - #### readonlyBindmounts

          protected List<String> readonlyBindmounts

    - #### readwriteBindmounts

          protected List<String> readwriteBindmounts

    - #### seccompJsonFile

          protected String seccompJsonFile

    - #### nscdPath

          protected String nscdPath

    - #### TMP_DIR

          protected static final String TMP_DIR

    - #### stormHome

          protected String stormHome

    - #### cgroupRootPath

          protected String cgroupRootPath

    - #### cgroupParent

          protected String cgroupParent

    - #### memoryCgroupRootPath

          protected String memoryCgroupRootPath

    - #### memoryCoreAtRoot

          protected MemoryCore memoryCoreAtRoot

    - #### workerToCpu

          protected Map<String,​Integer> workerToCpu

    - #### workerToMemoryMb

          protected Map<String,​Integer> workerToMemoryMb

    - #### validatedNumaMap

          protected Map<String,​Object> validatedNumaMap

    - #### workerToCores

          protected Map<String,​List<String>> workerToCores

    - #### workerToMemoryZone

          protected Map<String,​String> workerToMemoryZone

  - ### Constructor Detail

    - #### OciContainerManager

          public OciContainerManager()

  - ### Method Detail

    - #### prepare

          public void prepare​(Map<String,​Object> conf)
                       throws IOException

      Description copied from interface: `ResourceIsolationInterface`
      Called when starting up.
      Specified by:
        `prepare` in interface `ResourceIsolationInterface`
      Parameters:
        `conf` - the cluster config
      Throws:
        `IOException` - on any error.

    - #### reserveResourcesForWorker

          public void reserveResourcesForWorker​(String workerId,
                                                Integer workerMemoryMb,
                                                Integer workerCpu,
                                                String numaId)

      Description copied from interface: `ResourceIsolationInterface`
      This function should be used prior to starting the worker to reserve resources for the worker.
      Specified by:
        `reserveResourcesForWorker` in interface `ResourceIsolationInterface`
      Parameters:
        `workerId` - worker id of the worker to start
        `workerMemoryMb` - the amount of memory for the worker or null if not enforced
        `workerCpu` - the amount of cpu for the worker or null if not enforced
        `numaId` - NUMA zone if applicable the worker should be bound to

    - #### cleanup

          public void cleanup​(String user,
                              String workerId,
                              int port)
                       throws IOException

      Description copied from interface: `ResourceIsolationInterface`
      This function will be called when the worker needs to shutdown. This function should include logic to clean up after a worker is shutdown.
      Specified by:
        `cleanup` in interface `ResourceIsolationInterface`
      Parameters:
        `user` - the user of the worker
        `workerId` - worker id to shutdown and clean up after
        `port` - the port of the worker
      Throws:
        `IOException`

    - #### getSystemFreeMemoryMb

          public long getSystemFreeMemoryMb()
                                     throws IOException

      Description copied from interface: `ResourceIsolationInterface`
      Get the amount of free memory in MB. This might not be the entire box, it might be within a parent resource group.
      Specified by:
        `getSystemFreeMemoryMb` in interface `ResourceIsolationInterface`
      Returns:
        The amount of memory in MB that are free on the system.
      Throws:
        `IOException` - on I/O exception

    - #### getImageName

          protected String getImageName​(Map<String,​Object> topoConf)

      Get image name from topology Conf.
      Parameters:
        `topoConf` - topology configuration
      Returns:
        the image name

    - #### commandFilePath

          protected String commandFilePath​(String dir,
                                           String commandTag)

    - #### writeToCommandFile

          protected String writeToCommandFile​(String workerDir,
                                              String command,
                                              String commandTag)
                                       throws IOException

      Throws:
        `IOException`