Monday 20 June 2022

Atlas Client: Check whether server is ready or not

AtlasClientV2#isServerReady() method return true if the server is up and running, else false.

 

Example

if (atlasClient.isServerReady()) {
  System.out.println("Server is ready to accept requests");
} else {
  System.out.println("Server is ready");
}

 

Step 1: Define atlas-application.properties file under src/main/resources folder.

 

atlas-application.properties

atlas.client.readTimeoutMSecs=30000
atlas.client.connectTimeoutMSecs=30000

 

Step 2: Define ServerReadyCheck class.

 

ServerReadyCheck.java

package com.sample.app.server;

import org.apache.atlas.AtlasClientV2;
import org.apache.atlas.AtlasServiceException;

public class ServerReadyCheck {
  public static void main(String[] args) throws AtlasServiceException {
    AtlasClientV2 atlasClient = new AtlasClientV2(new String[] { "http://localhost:21000" },
        new String[] { "admin", "admin" });

    if (atlasClient.isServerReady()) {
      System.out.println("Server is ready to accept requests");
    } else {
      System.out.println("Server is ready");
    }

  }
}

 

 


 

Previous                                                    Next                                                    Home

No comments:

Post a Comment