Skip to content

Commit

Permalink
HDDS-4047. OzoneManager met NPE exception while getServiceList (#1277)
Browse files Browse the repository at this point in the history
  • Loading branch information
maobaolong committed Jul 30, 2020
1 parent 30ec0e2 commit a95b0b8
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1147,15 +1147,17 @@ public void start() throws IOException {
metricsTimer.schedule(scheduleOMMetricsWriteTask, 0, period);

keyManager.start(configuration);
omRpcServer.start();
isOmRpcServerRunning = true;

try {
httpServer = new OzoneManagerHttpServer(configuration, this);
httpServer.start();
} catch (Exception ex) {
// Allow OM to start as Http Server failure is not fatal.
LOG.error("OM HttpServer failed to start.", ex);
}
omRpcServer.start();
isOmRpcServerRunning = true;

registerMXBean();

startJVMPauseMonitor();
Expand Down Expand Up @@ -1201,8 +1203,6 @@ public void restart() throws IOException {
}

omRpcServer = getRpcServer(configuration);
omRpcServer.start();
isOmRpcServerRunning = true;

try {
httpServer = new OzoneManagerHttpServer(configuration, this);
Expand All @@ -1211,6 +1211,10 @@ public void restart() throws IOException {
// Allow OM to start as Http Server failure is not fatal.
LOG.error("OM HttpServer failed to start.", ex);
}

omRpcServer.start();
isOmRpcServerRunning = true;

registerMXBean();

startJVMPauseMonitor();
Expand Down Expand Up @@ -2503,13 +2507,15 @@ public List<ServiceInfo> getServiceList() throws IOException {
.setType(ServicePort.Type.RPC)
.setValue(omRpcAddress.getPort())
.build());
if (httpServer.getHttpAddress() != null) {
if (httpServer != null
&& httpServer.getHttpAddress() != null) {
omServiceInfoBuilder.addServicePort(ServicePort.newBuilder()
.setType(ServicePort.Type.HTTP)
.setValue(httpServer.getHttpAddress().getPort())
.build());
}
if (httpServer.getHttpsAddress() != null) {
if (httpServer != null
&& httpServer.getHttpsAddress() != null) {
omServiceInfoBuilder.addServicePort(ServicePort.newBuilder()
.setType(ServicePort.Type.HTTPS)
.setValue(httpServer.getHttpsAddress().getPort())
Expand Down

0 comments on commit a95b0b8

Please sign in to comment.