Search in sources :

Example 1 with SourceState

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);
}
Also used : SourceState(org.apache.inlong.manager.common.enums.SourceState) StreamSourceEntity(org.apache.inlong.manager.dao.entity.StreamSourceEntity) Date(java.util.Date)

Example 2 with SourceState

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);
}
Also used : SourceState(org.apache.inlong.manager.common.enums.SourceState) StreamSourceEntity(org.apache.inlong.manager.dao.entity.StreamSourceEntity) Date(java.util.Date)

Example 3 with SourceState

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);
}
Also used : SourceState(org.apache.inlong.manager.common.enums.SourceState) StreamSourceEntity(org.apache.inlong.manager.dao.entity.StreamSourceEntity) Date(java.util.Date)

Aggregations

Date (java.util.Date)3 SourceState (org.apache.inlong.manager.common.enums.SourceState)3 StreamSourceEntity (org.apache.inlong.manager.dao.entity.StreamSourceEntity)3