use of org.apache.hadoop.hdds.scm.container.states.ContainerStateMap in project ozone by apache.
the class ContainerStateManagerImpl method reinitialize.
@Override
public void reinitialize(Table<ContainerID, ContainerInfo> store) throws IOException {
lock.writeLock().lock();
try {
close();
this.containerStore = store;
this.containers = new ContainerStateMap();
this.lastUsedMap = new ConcurrentHashMap<>();
initialize();
} finally {
lock.writeLock().unlock();
}
}
use of org.apache.hadoop.hdds.scm.container.states.ContainerStateMap in project ozone by apache.
the class ContainerStateManagerImpl method updateContainerState.
@Override
public void updateContainerState(final HddsProtos.ContainerID containerID, final LifeCycleEvent event) throws IOException, InvalidStateTransitionException {
// TODO: Remove the protobuf conversion after fixing ContainerStateMap.
final ContainerID id = ContainerID.getFromProtobuf(containerID);
lock.writeLock().lock();
try {
if (containers.contains(id)) {
final ContainerInfo oldInfo = containers.getContainerInfo(id);
final LifeCycleState oldState = oldInfo.getState();
final LifeCycleState newState = stateMachine.getNextState(oldInfo.getState(), event);
if (newState.getNumber() > oldState.getNumber()) {
ExecutionUtil.create(() -> {
containers.updateState(id, oldState, newState);
transactionBuffer.addToBuffer(containerStore, id, containers.getContainerInfo(id));
}).onException(() -> {
transactionBuffer.addToBuffer(containerStore, id, oldInfo);
containers.updateState(id, newState, oldState);
}).execute();
containerStateChangeActions.getOrDefault(event, info -> {
}).execute(oldInfo);
}
}
} finally {
lock.writeLock().unlock();
}
}
Aggregations