%@ page import="org.apache.solr.core.SolrConfig,
org.apache.solr.core.SolrCore,
org.apache.solr.schema.IndexSchema,
java.io.File
"%>
<%@ page import="java.net.InetAddress"%>
<%@ page import="java.net.UnknownHostException"%>
<%@ page import="java.util.Date"%>
<%
SolrCore core = SolrCore.getSolrCore();
Integer port = new Integer(request.getServerPort());
IndexSchema schema = core.getSchema();
String rootdir = "/var/opt/resin3/"+port.toString();
File pidFile = new File(rootdir + "/logs/resin.pid");
File enableFile = new File(rootdir + "/logs/server-enabled");
boolean isEnabled = false;
String enabledStatus = "";
String enableActionStatus = "";
String makeEnabled = "";
String action = request.getParameter("action");
String startTime = "";
try {
startTime = (pidFile.lastModified() > 0)
? new Date(pidFile.lastModified()).toString()
: "No Resin Pid found (logs/resin.pid)";
} catch (Exception e) {
out.println("");
out.println("Couldn't open Solr pid file:" + e.toString());
out.println("");
}
try {
if (action != null) {
if ("Enable".compareTo(action) == 0) {
if (enableFile.createNewFile()) {
enableActionStatus += "Enable Succeeded";
} else {
enableActionStatus += "Already Enabled)";
}
}
if ("Disable".compareTo(action) == 0) {
if (enableFile.delete()) {
enableActionStatus = "Disable Succeeded";
} else {
enableActionStatus = "Already Disabled";
}
}
}
} catch (Exception e) {
out.println("");
out.println("Couldn't "+action+" server-enabled file:" + e.toString());
out.println("");
}
try {
isEnabled = (enableFile.lastModified() > 0);
enabledStatus = (isEnabled)
? "Enabled"
: "Disabled";
makeEnabled = (isEnabled)
? "Disable"
: "Enable";
} catch (Exception e) {
out.println("");
out.println("Couldn't check server-enabled file:" + e.toString());
out.println("");
}
String collectionName = schema!=null ? schema.getName():"unknown";
String hostname="localhost";
String defaultSearch= SolrConfig.config.get("admin/defaultQuery","");
try {
InetAddress addr = InetAddress.getLocalHost();
// Get IP Address
byte[] ipAddr = addr.getAddress();
// Get hostname
// hostname = addr.getHostName();
hostname = addr.getCanonicalHostName();
} catch (UnknownHostException e) {}
%>
SOLR Interface
SOLR Interface (<%= collectionName %>) - <%= enabledStatus %>
<%= hostname %> : <%= port.toString() %>
/select mode