use of com.ctrip.xpipe.redis.meta.server.cluster.SlotInfo in project x-pipe by ctripcorp.
the class MoveSlotFromDeadOrEmpty method doExecute.
@Override
protected void doExecute() throws Exception {
logger.info("[doExecute]{},{}->{}", slot, from, to);
setSlotInfo(new SlotInfo(getTo().getServerId()));
to.addSlot(slot);
future().setSuccess(null);
}
use of com.ctrip.xpipe.redis.meta.server.cluster.SlotInfo in project x-pipe by ctripcorp.
the class MoveSlotFromLiving method setSuccess.
private void setSuccess() throws ShardingException {
logger.info("[setSuccess]{},{},{}", getSlot(), getFrom(), getTo());
setSlotInfo(new SlotInfo(to.getServerId()));
getTo().addSlot(slot);
getFrom().deleteSlot(slot);
future().setSuccess(null);
}
use of com.ctrip.xpipe.redis.meta.server.cluster.SlotInfo in project x-pipe by ctripcorp.
the class RollbackMovingTask method doExecute.
@Override
protected void doExecute() throws Exception {
setSlotInfo(new SlotInfo(from.getServerId()));
ClusterServer from = getFrom();
ClusterServer to = getTo();
if (from != null) {
from.addSlot(slot);
}
if (to != null) {
to.deleteSlot(slot);
}
future().setSuccess();
}
use of com.ctrip.xpipe.redis.meta.server.cluster.SlotInfo in project x-pipe by ctripcorp.
the class DefaultSlotManager method allMoveingSlots.
@Override
public Map<Integer, SlotInfo> allMoveingSlots() {
try {
lock.readLock().lock();
Map<Integer, SlotInfo> result = new HashMap<>();
for (Entry<Integer, SlotInfo> entry : slotsMap.entrySet()) {
Integer slot = entry.getKey();
SlotInfo slotInfo = entry.getValue();
if (slotInfo.getSlotState() == SLOT_STATE.MOVING) {
result.put(slot, slotInfo.clone());
}
}
return result;
} catch (CloneNotSupportedException e) {
throw new IllegalStateException(e);
} finally {
lock.readLock().unlock();
}
}
use of com.ctrip.xpipe.redis.meta.server.cluster.SlotInfo in project x-pipe by ctripcorp.
the class DefaultSlotManager method move.
@Override
public void move(int slotId, int fromServer, int toServer) {
try {
lock.writeLock().lock();
if (serverMap.get(fromServer) == null) {
logger.error("[fromServer not Found]" + fromServer);
return;
}
slotsMap.put(slotId, new SlotInfo(toServer));
serverMap.get(fromServer).remove(slotId);
Set<Integer> toSlots = MapUtils.getOrCreate(serverMap, toServer, new ObjectFactory<Set<Integer>>() {
@Override
public Set<Integer> create() {
return new HashSet<>();
}
});
toSlots.add(slotId);
} finally {
lock.writeLock().unlock();
}
}
Aggregations