Class DisposableWorkerIdAssigner

java.lang.Object
com.bytedesk.core.uid.worker.DisposableWorkerIdAssigner
All Implemented Interfaces:
WorkerIdAssigner

public class DisposableWorkerIdAssigner extends Object implements WorkerIdAssigner
Represents an implementation of WorkerIdAssigner, the worker id will be discarded after assigned to the UidGenerator
Author:
yutianbao
  • Field Details

  • Constructor Details

    • DisposableWorkerIdAssigner

      public DisposableWorkerIdAssigner()
  • Method Details

    • assignWorkerId

      @Transactional(rollbackFor=java.lang.Exception.class) public long assignWorkerId()
      Assign worker id base on database.<p> If there is host name and port in the environment, we considered that the node runs in Docker container<br> Otherwise, the node runs on an actual machine.
      Specified by:
      assignWorkerId in interface WorkerIdAssigner
      Returns:
      assigned worker id
    • assignFakeWorkerId

      @Transactional(rollbackFor=java.lang.Exception.class) public long assignFakeWorkerId()
      Description copied from interface: WorkerIdAssigner
      Assign fake worker id
      Specified by:
      assignFakeWorkerId in interface WorkerIdAssigner
      Returns:
      assigned fake worker id
    • buildWorkerNode

      private UidGeneratorEntity buildWorkerNode()
      Build worker node entity by IP and PORT
    • buildFakeWorkerNode

      private UidGeneratorEntity buildFakeWorkerNode()