Search in sources :

Example 1 with MachineGroup

use of com.aliyun.openservices.log.common.MachineGroup in project opscloud4 by ixrjog.

the class AliyunLogFacadeImpl method pushLogMemberById.

@Override
public void pushLogMemberById(Integer id) {
    AliyunLogMember aliyunLogMember = aliyunLogMemberService.getById(id);
    if (aliyunLogMember == null)
        return;
    AliyunLogMemberVO.LogMember logMember = BeanCopierUtil.copyProperties(aliyunLogMember, AliyunLogMemberVO.LogMember.class);
    aliyunLogMemberPacker.wrap(logMember, SimpleExtend.EXTEND);
    AliyunConfig aliyunDsInstanceConfig = (AliyunConfig) getConfig(logMember.getLog().getDatasourceInstanceId());
    MachineGroup machineGroup = aliyunLogMachineGroupHandler.getMachineGroup(aliyunDsInstanceConfig.getAliyun(), logMember.getLog().getProject(), logMember.getServerGroupName());
    if (machineGroup == null) {
        // 创建
        aliyunLogMachineGroupHandler.createMachineGroup(aliyunDsInstanceConfig.getAliyun(), logMember);
    } else {
        // 更新
        aliyunLogMachineGroupHandler.updateMachineGroup(aliyunDsInstanceConfig.getAliyun(), logMember);
    }
    updateAliyunLogMemberLastPushTime(aliyunLogMember);
}
Also used : MachineGroup(com.aliyun.openservices.log.common.MachineGroup) AliyunLogMemberVO(com.baiyi.opscloud.domain.vo.datasource.aliyun.AliyunLogMemberVO) AliyunConfig(com.baiyi.opscloud.common.datasource.AliyunConfig)

Example 2 with MachineGroup

use of com.aliyun.openservices.log.common.MachineGroup in project opscloud4 by ixrjog.

the class AliyunLogMachineGroupDriver method createMachineGroup.

public void createMachineGroup(AliyunConfig.Aliyun aliyun, AliyunLogMemberVO.LogMember logMember) {
    MachineGroup machineGroup = new MachineGroup(logMember.getServerGroupName(), MACHINE_IDENTIFY_TYPE, logMember.getMachineList());
    machineGroup.SetGroupTopic(StringUtils.isEmpty(logMember.getTopic()) ? logMember.getServerGroupName() : logMember.getTopic());
    try {
        Client client = buildClient(aliyun);
        CreateMachineGroupRequest req = new CreateMachineGroupRequest(logMember.getLog().getProject(), machineGroup);
        client.CreateMachineGroup(req);
    } catch (LogException lg) {
        log.error("阿里云日志服务创建MachineGroup错误! , {}", lg.GetErrorMessage());
    }
}
Also used : MachineGroup(com.aliyun.openservices.log.common.MachineGroup) Client(com.aliyun.openservices.log.Client) LogException(com.aliyun.openservices.log.exception.LogException)

Example 3 with MachineGroup

use of com.aliyun.openservices.log.common.MachineGroup in project opscloud4 by ixrjog.

the class AliyunLogMachineGroupDriver method updateMachineGroup.

public void updateMachineGroup(AliyunConfig.Aliyun aliyun, AliyunLogMemberVO.LogMember logMember) {
    MachineGroup machineGroup = new MachineGroup(logMember.getServerGroupName(), MACHINE_IDENTIFY_TYPE, logMember.getMachineList());
    machineGroup.SetGroupTopic(StringUtils.isEmpty(logMember.getTopic()) ? logMember.getServerGroupName() : logMember.getTopic());
    try {
        Client client = buildClient(aliyun);
        UpdateMachineGroupRequest req = new UpdateMachineGroupRequest(logMember.getLog().getProject(), machineGroup);
        client.UpdateMachineGroup(req);
    } catch (LogException lg) {
        log.error("阿里云日志服务更新MachineGroup错误! , {}", lg.GetErrorMessage());
    }
}
Also used : MachineGroup(com.aliyun.openservices.log.common.MachineGroup) Client(com.aliyun.openservices.log.Client) LogException(com.aliyun.openservices.log.exception.LogException)

Aggregations

MachineGroup (com.aliyun.openservices.log.common.MachineGroup)3 Client (com.aliyun.openservices.log.Client)2 LogException (com.aliyun.openservices.log.exception.LogException)2 AliyunConfig (com.baiyi.opscloud.common.datasource.AliyunConfig)1 AliyunLogMemberVO (com.baiyi.opscloud.domain.vo.datasource.aliyun.AliyunLogMemberVO)1