-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BIGTOP-4372: Adjust APIs related to cluster management for UI needs (#…
…180)
- Loading branch information
Showing
19 changed files
with
361 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...main/java/org/apache/bigtop/manager/server/command/validator/ClusterRestartValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.bigtop.manager.server.command.validator; | ||
|
||
import org.apache.bigtop.manager.common.enums.Command; | ||
import org.apache.bigtop.manager.dao.po.ServicePO; | ||
import org.apache.bigtop.manager.dao.repository.ServiceDao; | ||
import org.apache.bigtop.manager.server.command.CommandIdentifier; | ||
import org.apache.bigtop.manager.server.enums.ApiExceptionEnum; | ||
import org.apache.bigtop.manager.server.enums.CommandLevel; | ||
import org.apache.bigtop.manager.server.exception.ApiException; | ||
|
||
import org.apache.commons.collections4.CollectionUtils; | ||
|
||
import org.springframework.stereotype.Component; | ||
|
||
import jakarta.annotation.Resource; | ||
import java.util.List; | ||
|
||
@Component | ||
public class ClusterRestartValidator implements CommandValidator { | ||
|
||
@Resource | ||
private ServiceDao serviceDao; | ||
|
||
@Override | ||
public List<CommandIdentifier> getCommandIdentifiers() { | ||
return List.of(new CommandIdentifier(CommandLevel.CLUSTER, Command.RESTART)); | ||
} | ||
|
||
@Override | ||
public void validate(ValidatorContext context) { | ||
Long clusterId = context.getCommandDTO().getClusterId(); | ||
List<ServicePO> servicePOList = serviceDao.findByClusterId(clusterId); | ||
|
||
if (CollectionUtils.isEmpty(servicePOList)) { | ||
throw new ApiException(ApiExceptionEnum.CLUSTER_HAS_NO_SERVICES); | ||
} | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
...c/main/java/org/apache/bigtop/manager/server/command/validator/ClusterStartValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.bigtop.manager.server.command.validator; | ||
|
||
import org.apache.bigtop.manager.common.enums.Command; | ||
import org.apache.bigtop.manager.dao.po.ServicePO; | ||
import org.apache.bigtop.manager.dao.repository.ServiceDao; | ||
import org.apache.bigtop.manager.server.command.CommandIdentifier; | ||
import org.apache.bigtop.manager.server.enums.ApiExceptionEnum; | ||
import org.apache.bigtop.manager.server.enums.CommandLevel; | ||
import org.apache.bigtop.manager.server.exception.ApiException; | ||
|
||
import org.apache.commons.collections4.CollectionUtils; | ||
|
||
import org.springframework.stereotype.Component; | ||
|
||
import jakarta.annotation.Resource; | ||
import java.util.List; | ||
|
||
@Component | ||
public class ClusterStartValidator implements CommandValidator { | ||
|
||
@Resource | ||
private ServiceDao serviceDao; | ||
|
||
@Override | ||
public List<CommandIdentifier> getCommandIdentifiers() { | ||
return List.of(new CommandIdentifier(CommandLevel.CLUSTER, Command.START)); | ||
} | ||
|
||
@Override | ||
public void validate(ValidatorContext context) { | ||
Long clusterId = context.getCommandDTO().getClusterId(); | ||
List<ServicePO> servicePOList = serviceDao.findByClusterId(clusterId); | ||
|
||
if (CollectionUtils.isEmpty(servicePOList)) { | ||
throw new ApiException(ApiExceptionEnum.CLUSTER_HAS_NO_SERVICES); | ||
} | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
...rc/main/java/org/apache/bigtop/manager/server/command/validator/ClusterStopValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.bigtop.manager.server.command.validator; | ||
|
||
import org.apache.bigtop.manager.common.enums.Command; | ||
import org.apache.bigtop.manager.dao.po.ServicePO; | ||
import org.apache.bigtop.manager.dao.repository.ServiceDao; | ||
import org.apache.bigtop.manager.server.command.CommandIdentifier; | ||
import org.apache.bigtop.manager.server.enums.ApiExceptionEnum; | ||
import org.apache.bigtop.manager.server.enums.CommandLevel; | ||
import org.apache.bigtop.manager.server.exception.ApiException; | ||
|
||
import org.apache.commons.collections4.CollectionUtils; | ||
|
||
import org.springframework.stereotype.Component; | ||
|
||
import jakarta.annotation.Resource; | ||
import java.util.List; | ||
|
||
@Component | ||
public class ClusterStopValidator implements CommandValidator { | ||
|
||
@Resource | ||
private ServiceDao serviceDao; | ||
|
||
@Override | ||
public List<CommandIdentifier> getCommandIdentifiers() { | ||
return List.of(new CommandIdentifier(CommandLevel.CLUSTER, Command.STOP)); | ||
} | ||
|
||
@Override | ||
public void validate(ValidatorContext context) { | ||
Long clusterId = context.getCommandDTO().getClusterId(); | ||
List<ServicePO> servicePOList = serviceDao.findByClusterId(clusterId); | ||
|
||
if (CollectionUtils.isEmpty(servicePOList)) { | ||
throw new ApiException(ApiExceptionEnum.CLUSTER_HAS_NO_SERVICES); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,5 +35,7 @@ public class JobVO { | |
|
||
private String updateTime; | ||
|
||
private Integer progress; | ||
|
||
private List<StageVO> stages; | ||
} |
35 changes: 35 additions & 0 deletions
35
...ager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/ServiceClusterVO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.bigtop.manager.server.model.vo; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.List; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class ServiceClusterVO { | ||
|
||
private String serviceName; | ||
|
||
private List<ClusterVO> clusters; | ||
} |
33 changes: 33 additions & 0 deletions
33
...manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/ServiceUserVO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.bigtop.manager.server.model.vo; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class ServiceUserVO { | ||
|
||
private String displayName; | ||
|
||
private String user; | ||
|
||
private String userGroup; | ||
|
||
private String desc; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.