Package me.ahoo.cosid.spring.redis
Class SpringRedisMachineIdDistributor
java.lang.Object
me.ahoo.cosid.machine.AbstractMachineIdDistributor
me.ahoo.cosid.spring.redis.SpringRedisMachineIdDistributor
- All Implemented Interfaces:
MachineIdDistributor
Spring Redis MachineIdDistributor.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final org.springframework.data.redis.core.script.RedisScript<List>
static final org.springframework.core.io.Resource
static final org.springframework.data.redis.core.script.RedisScript<Long>
static final org.springframework.core.io.Resource
static final org.springframework.data.redis.core.script.RedisScript<Long>
static final org.springframework.core.io.Resource
static final org.springframework.data.redis.core.script.RedisScript<Long>
static final org.springframework.core.io.Resource
Fields inherited from class me.ahoo.cosid.machine.AbstractMachineIdDistributor
NOT_FOUND_LAST_STAMP
Fields inherited from interface me.ahoo.cosid.machine.MachineIdDistributor
FOREVER_SAFE_GUARD_DURATION
-
Constructor Summary
ConstructorDescriptionSpringRedisMachineIdDistributor
(org.springframework.data.redis.core.StringRedisTemplate redisTemplate, MachineStateStorage machineStateStorage, ClockBackwardsSynchronizer clockBackwardsSynchronizer) -
Method Summary
Modifier and TypeMethodDescriptionprotected MachineState
distributeRemote
(String namespace, int machineBit, InstanceId instanceId, Duration safeGuardDuration) protected void
guardRemote
(String namespace, InstanceId instanceId, MachineState machineState, Duration safeGuardDuration) static String
redis hash-tag for redis-cluster.protected void
revertRemote
(String namespace, InstanceId instanceId, MachineState machineState) whenInstanceId.isStable()
is true,do not revert machineId.Methods inherited from class me.ahoo.cosid.machine.AbstractMachineIdDistributor
distribute, guard, revert
-
Field Details
-
MACHINE_ID_DISTRIBUTE_SOURCE
public static final org.springframework.core.io.Resource MACHINE_ID_DISTRIBUTE_SOURCE -
MACHINE_ID_DISTRIBUTE
public static final org.springframework.data.redis.core.script.RedisScript<List> MACHINE_ID_DISTRIBUTE -
MACHINE_ID_REVERT_SOURCE
public static final org.springframework.core.io.Resource MACHINE_ID_REVERT_SOURCE -
MACHINE_ID_REVERT
-
MACHINE_ID_REVERT_STABLE_SOURCE
public static final org.springframework.core.io.Resource MACHINE_ID_REVERT_STABLE_SOURCE -
MACHINE_ID_REVERT_STABLE
public static final org.springframework.data.redis.core.script.RedisScript<Long> MACHINE_ID_REVERT_STABLE -
MACHINE_ID_GUARD_SOURCE
public static final org.springframework.core.io.Resource MACHINE_ID_GUARD_SOURCE -
MACHINE_ID_GUARD
-
-
Constructor Details
-
SpringRedisMachineIdDistributor
public SpringRedisMachineIdDistributor(org.springframework.data.redis.core.StringRedisTemplate redisTemplate, MachineStateStorage machineStateStorage, ClockBackwardsSynchronizer clockBackwardsSynchronizer)
-
-
Method Details
-
distributeRemote
protected MachineState distributeRemote(String namespace, int machineBit, InstanceId instanceId, Duration safeGuardDuration) - Specified by:
distributeRemote
in classAbstractMachineIdDistributor
-
revertRemote
whenInstanceId.isStable()
is true,do not revert machineId.- Specified by:
revertRemote
in classAbstractMachineIdDistributor
-
guardRemote
protected void guardRemote(String namespace, InstanceId instanceId, MachineState machineState, Duration safeGuardDuration) - Specified by:
guardRemote
in classAbstractMachineIdDistributor
-
hashTag
redis hash-tag for redis-cluster.- Parameters:
key
- key- Returns:
- hash-tag key
-