Search in sources :

Example 1 with ClusterAppAssignResultVO

use of com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterAppAssignResultVO in project Sentinel by alibaba.

the class ClusterAssignServiceImpl method unbindClusterServers.

@Override
public ClusterAppAssignResultVO unbindClusterServers(String app, Set<String> machineIdSet) {
    AssertUtil.assertNotBlank(app, "app cannot be blank");
    AssertUtil.isTrue(machineIdSet != null && !machineIdSet.isEmpty(), "machineIdSet cannot be empty");
    ClusterAppAssignResultVO result = new ClusterAppAssignResultVO().setFailedClientSet(new HashSet<>()).setFailedServerSet(new HashSet<>());
    for (String machineId : machineIdSet) {
        ClusterAppAssignResultVO resultVO = unbindClusterServer(app, machineId);
        result.getFailedClientSet().addAll(resultVO.getFailedClientSet());
        result.getFailedServerSet().addAll(resultVO.getFailedServerSet());
    }
    return result;
}
Also used : ClusterAppAssignResultVO(com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterAppAssignResultVO) HashSet(java.util.HashSet)

Example 2 with ClusterAppAssignResultVO

use of com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterAppAssignResultVO in project spring-boot-student by wyh-spring-ecosystem-student.

the class ClusterAssignServiceImpl method unbindClusterServer.

@Override
public ClusterAppAssignResultVO unbindClusterServer(String app, String machineId) {
    AssertUtil.assertNotBlank(app, "app cannot be blank");
    AssertUtil.assertNotBlank(machineId, "machineId cannot be blank");
    if (isMachineInApp(machineId)) {
        return handleUnbindClusterServerNotInApp(app, machineId);
    }
    Set<String> failedSet = new HashSet<>();
    try {
        ClusterGroupEntity entity = clusterConfigService.getClusterUniversalStateForAppMachine(app, machineId).get(10, TimeUnit.SECONDS);
        Set<String> toModifySet = new HashSet<>();
        toModifySet.add(machineId);
        if (entity.getClientSet() != null) {
            toModifySet.addAll(entity.getClientSet());
        }
        // Modify mode to NOT-STARTED for all chosen token servers and associated token clients.
        modifyToNonStarted(toModifySet, failedSet);
    } catch (Exception ex) {
        Throwable e = ex instanceof ExecutionException ? ex.getCause() : ex;
        LOGGER.error("Failed to unbind machine <{}>", machineId, e);
        failedSet.add(machineId);
    }
    return new ClusterAppAssignResultVO().setFailedClientSet(failedSet).setFailedServerSet(new HashSet<>());
}
Also used : ClusterGroupEntity(com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterGroupEntity) ExecutionException(java.util.concurrent.ExecutionException) ClusterAppAssignResultVO(com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterAppAssignResultVO) ExecutionException(java.util.concurrent.ExecutionException) HashSet(java.util.HashSet)

Example 3 with ClusterAppAssignResultVO

use of com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterAppAssignResultVO in project XHuiCloud by sindaZeng.

the class ClusterAssignServiceImpl method unbindClusterServers.

@Override
public ClusterAppAssignResultVO unbindClusterServers(String app, Set<String> machineIdSet) {
    AssertUtil.assertNotBlank(app, "app cannot be blank");
    AssertUtil.isTrue(machineIdSet != null && !machineIdSet.isEmpty(), "machineIdSet cannot be empty");
    ClusterAppAssignResultVO result = new ClusterAppAssignResultVO().setFailedClientSet(new HashSet<>()).setFailedServerSet(new HashSet<>());
    for (String machineId : machineIdSet) {
        ClusterAppAssignResultVO resultVO = unbindClusterServer(app, machineId);
        result.getFailedClientSet().addAll(resultVO.getFailedClientSet());
        result.getFailedServerSet().addAll(resultVO.getFailedServerSet());
    }
    return result;
}
Also used : ClusterAppAssignResultVO(com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterAppAssignResultVO) HashSet(java.util.HashSet)

Example 4 with ClusterAppAssignResultVO

use of com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterAppAssignResultVO in project Sentinel by alibaba.

the class ClusterAssignServiceImpl method unbindClusterServer.

@Override
public ClusterAppAssignResultVO unbindClusterServer(String app, String machineId) {
    AssertUtil.assertNotBlank(app, "app cannot be blank");
    AssertUtil.assertNotBlank(machineId, "machineId cannot be blank");
    if (isMachineInApp(machineId)) {
        return handleUnbindClusterServerNotInApp(app, machineId);
    }
    Set<String> failedSet = new HashSet<>();
    try {
        ClusterGroupEntity entity = clusterConfigService.getClusterUniversalStateForAppMachine(app, machineId).get(10, TimeUnit.SECONDS);
        Set<String> toModifySet = new HashSet<>();
        toModifySet.add(machineId);
        if (entity.getClientSet() != null) {
            toModifySet.addAll(entity.getClientSet());
        }
        // Modify mode to NOT-STARTED for all chosen token servers and associated token clients.
        modifyToNonStarted(toModifySet, failedSet);
    } catch (Exception ex) {
        Throwable e = ex instanceof ExecutionException ? ex.getCause() : ex;
        LOGGER.error("Failed to unbind machine <{}>", machineId, e);
        failedSet.add(machineId);
    }
    return new ClusterAppAssignResultVO().setFailedClientSet(failedSet).setFailedServerSet(new HashSet<>());
}
Also used : ClusterGroupEntity(com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterGroupEntity) ExecutionException(java.util.concurrent.ExecutionException) ClusterAppAssignResultVO(com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterAppAssignResultVO) ExecutionException(java.util.concurrent.ExecutionException) HashSet(java.util.HashSet)

Example 5 with ClusterAppAssignResultVO

use of com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterAppAssignResultVO in project pig by pig-mesh.

the class ClusterAssignServiceImpl method unbindClusterServers.

@Override
public ClusterAppAssignResultVO unbindClusterServers(String app, Set<String> machineIdSet) {
    AssertUtil.assertNotBlank(app, "app cannot be blank");
    AssertUtil.isTrue(machineIdSet != null && !machineIdSet.isEmpty(), "machineIdSet cannot be empty");
    ClusterAppAssignResultVO result = new ClusterAppAssignResultVO().setFailedClientSet(new HashSet<>()).setFailedServerSet(new HashSet<>());
    for (String machineId : machineIdSet) {
        ClusterAppAssignResultVO resultVO = unbindClusterServer(app, machineId);
        result.getFailedClientSet().addAll(resultVO.getFailedClientSet());
        result.getFailedServerSet().addAll(resultVO.getFailedServerSet());
    }
    return result;
}
Also used : ClusterAppAssignResultVO(com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterAppAssignResultVO) HashSet(java.util.HashSet)

Aggregations

ClusterAppAssignResultVO (com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterAppAssignResultVO)10 HashSet (java.util.HashSet)10 ClusterGroupEntity (com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterGroupEntity)5 ExecutionException (java.util.concurrent.ExecutionException)5