Products | Versions |
---|---|
TIBCO DataSynapse GridServer | - |
Not Applicable | - |
Resolution:
The following Java code can be used to ping a Manager from an Engine.
import java.net.*;
import java.util.*;
import java.io.*;/*
* ManagerHttpPing.java
*
* Utility class to get the 'ping' HTML page from a given manager. Useful for checking network connectivity and
* basic manager health.
*
* javac ManagerHttpPing.java
* java ManagerHttpPing manager.my.domain.com:port
*/ public class ManagerHttpPing {
public static void main(String [] args) throws Exception {
if (args.length != 1) {
throw new Exception("Incorrect args count");
}
if (args[0].indexOf(':') == -1) {
throw new Exception("You must specify host:port");
}
long startmillis = System.currentTimeMillis();
StringTokenizer tok = new StringTokenizer(args[0], ":");
String host = tok.nextToken();
String port = tok.nextToken();
URL url = new URL("http", host, Integer.parseInt(port), "/livecluster/public_html/ping/ping.jsp");
URLConnection conn = url.openConnection();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
InputStream is = conn.getInputStream();
byte [] buf = new byte[4096];
int n;
int bytes = 0;
while ((n = is.read(buf)) != -1) {
baos.write(buf, 0, n);
bytes += n;
}
System.out.println("ManagerHttpPing retrieved " + bytes + " bytes from " + url.toString() + " in " +
(System.currentTimeMillis() - startmillis) + " milliseconds.");
}
}