-
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-4162: Add health check for components (#19)
- Loading branch information
Showing
10 changed files
with
227 additions
and
173 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
154 changes: 0 additions & 154 deletions
154
.../src/main/java/org/apache/bigtop/manager/agent/monitoring/ZookeeperHealthyMonitoring.java
This file was deleted.
Oops, something went wrong.
66 changes: 66 additions & 0 deletions
66
...src/main/java/org/apache/bigtop/manager/agent/service/ComponentStatusServiceGrpcImpl.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,66 @@ | ||
/* | ||
* 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.agent.service; | ||
|
||
import org.apache.bigtop.manager.common.enums.Command; | ||
import org.apache.bigtop.manager.common.message.entity.payload.CommandPayload; | ||
import org.apache.bigtop.manager.common.message.entity.pojo.ScriptInfo; | ||
import org.apache.bigtop.manager.common.shell.ShellResult; | ||
import org.apache.bigtop.manager.common.utils.JsonUtils; | ||
import org.apache.bigtop.manager.grpc.generated.ComponentStatusReply; | ||
import org.apache.bigtop.manager.grpc.generated.ComponentStatusRequest; | ||
import org.apache.bigtop.manager.grpc.generated.ComponentStatusServiceGrpc; | ||
import org.apache.bigtop.manager.stack.core.executor.StackExecutor; | ||
|
||
import io.grpc.Status; | ||
import io.grpc.stub.StreamObserver; | ||
import lombok.extern.slf4j.Slf4j; | ||
import net.devh.boot.grpc.server.service.GrpcService; | ||
|
||
@Slf4j | ||
@GrpcService | ||
public class ComponentStatusServiceGrpcImpl extends ComponentStatusServiceGrpc.ComponentStatusServiceImplBase { | ||
|
||
@Override | ||
public void getComponentStatus( | ||
ComponentStatusRequest request, StreamObserver<ComponentStatusReply> responseObserver) { | ||
|
||
try { | ||
CommandPayload commandPayload = new CommandPayload(); | ||
commandPayload.setCommand(Command.STATUS); | ||
commandPayload.setServiceName(request.getServiceName()); | ||
commandPayload.setComponentName(request.getComponentName()); | ||
commandPayload.setCommandScript(JsonUtils.readFromString(request.getCommandScript(), ScriptInfo.class)); | ||
commandPayload.setRoot(request.getRoot()); | ||
commandPayload.setStackName(request.getStackName()); | ||
commandPayload.setStackVersion(request.getStackVersion()); | ||
ShellResult shellResult = StackExecutor.execute(commandPayload); | ||
|
||
ComponentStatusReply reply = ComponentStatusReply.newBuilder() | ||
.setStatus(shellResult.getExitCode()) | ||
.build(); | ||
responseObserver.onNext(reply); | ||
responseObserver.onCompleted(); | ||
} catch (Exception e) { | ||
log.error("Error getting component status", e); | ||
Status status = Status.UNKNOWN.withDescription(e.getMessage()); | ||
responseObserver.onError(status.asRuntimeException()); | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
bigtop-manager-grpc/src/main/resources/proto/component_status.proto
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,41 @@ | ||
/* | ||
* 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. | ||
*/ | ||
syntax = "proto3"; | ||
|
||
option java_multiple_files = true; | ||
option java_package = "org.apache.bigtop.manager.grpc.generated"; | ||
option java_outer_classname = "ComponentStatusProto"; | ||
|
||
service ComponentStatusService { | ||
rpc GetComponentStatus (ComponentStatusRequest) returns (ComponentStatusReply) {} | ||
} | ||
|
||
message ComponentStatusRequest { | ||
string service_name = 1; | ||
string component_name = 2; | ||
string command_script = 3; | ||
// TODO Unnecessary, should be removed in the future | ||
string root = 4; | ||
string stack_name = 5; | ||
string stack_version = 6; | ||
} | ||
|
||
message ComponentStatusReply { | ||
int32 status = 1; | ||
} |
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.