use of org.apache.inlong.manager.common.enums.SourceState in project incubator-inlong by apache.
the class AbstractStreamSourceOperation method deleteOpt.
@Override
public void deleteOpt(SourceRequest request, String operator) {
Integer id = request.getId();
StreamSourceEntity existEntity = sourceMapper.selectByPrimaryKey(id);
SourceState curState = SourceState.forCode(existEntity.getStatus());
SourceState nextState = SourceState.TO_BE_ISSUED_DELETE;
if (!SourceState.isAllowedTransition(curState, nextState)) {
throw new RuntimeException(String.format("Source=%s is not allowed to delete", existEntity));
}
StreamSourceEntity curEntity = CommonBeanUtils.copyProperties(request, StreamSourceEntity::new);
curEntity.setModifyTime(new Date());
curEntity.setPreviousStatus(curState.getCode());
curEntity.setStatus(nextState.getCode());
curEntity.setIsDeleted(id);
sourceMapper.updateByPrimaryKeySelective(curEntity);
}
use of org.apache.inlong.manager.common.enums.SourceState in project incubator-inlong by apache.
the class AbstractStreamSourceOperation method restartOpt.
@Override
public void restartOpt(SourceRequest request, String operator) {
StreamSourceEntity snapshot = sourceMapper.selectByPrimaryKey(request.getId());
SourceState curState = SourceState.forCode(snapshot.getStatus());
SourceState nextState = SourceState.TO_BE_ISSUED_ACTIVE;
if (!SourceState.isAllowedTransition(curState, nextState)) {
throw new RuntimeException(String.format("Source=%s is not allowed to restart", snapshot));
}
StreamSourceEntity curEntity = CommonBeanUtils.copyProperties(request, StreamSourceEntity::new);
curEntity.setModifyTime(new Date());
curEntity.setPreviousStatus(curState.getCode());
curEntity.setStatus(nextState.getCode());
sourceMapper.updateByPrimaryKeySelective(curEntity);
}
use of org.apache.inlong.manager.common.enums.SourceState in project incubator-inlong by apache.
the class AbstractStreamSourceOperation method stopOpt.
@Override
public void stopOpt(SourceRequest request, String operator) {
StreamSourceEntity snapshot = sourceMapper.selectByPrimaryKey(request.getId());
SourceState curState = SourceState.forCode(snapshot.getStatus());
SourceState nextState = SourceState.TO_BE_ISSUED_FROZEN;
if (!SourceState.isAllowedTransition(curState, nextState)) {
throw new RuntimeException(String.format("Source=%s is not allowed to stop", snapshot));
}
StreamSourceEntity curEntity = CommonBeanUtils.copyProperties(request, StreamSourceEntity::new);
curEntity.setModifyTime(new Date());
curEntity.setPreviousStatus(curState.getCode());
curEntity.setStatus(nextState.getCode());
sourceMapper.updateByPrimaryKeySelective(curEntity);
}
Aggregations