<%@ page import="org.apache.solr.core.SolrCore, org.apache.solr.schema.IndexSchema, java.io.File, java.net.InetAddress, java.net.UnknownHostException"%> <%@ page import="java.util.Date"%> <%@ page import="java.util.logging.Level"%> <%@ page import="java.util.logging.Logger"%> <% SolrCore core = SolrCore.getSolrCore(); IndexSchema schema = core.getSchema(); String collectionName = schema!=null ? schema.getName():"unknown"; String action = request.getParameter("action"); String logging = request.getParameter("log"); String enableActionStatus = ""; boolean isValid = false; boolean wasOk = true; String rootdir = "/var/opt/resin3/"+request.getServerPort(); File pidFile = new File(rootdir + "/logs/resin.pid"); 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(""); } File enableFile = new File(rootdir + "/logs/server-enabled"); if (action != null) { // Validate fname if ("Enable".compareTo(action) == 0) isValid = true; if ("Disable".compareTo(action) == 0) isValid = true; } if (logging != null) { action = "Set Log Level"; isValid = true; } if (isValid) { if ("Enable".compareTo(action) == 0) { try { if (enableFile.createNewFile()) { enableActionStatus += "Enable Succeeded"; } else { enableActionStatus += "Already Enabled"; } } catch(Exception e) { enableActionStatus += "Enable Failed: " + e.toString(); wasOk = false; } } if ("Disable".compareTo(action) == 0) { try { if (enableFile.delete()) { enableActionStatus = "Disable Succeeded"; } else { enableActionStatus = "Already Disabled"; } } catch(Exception e) { enableActionStatus += "Disable Failed: " + e.toString(); wasOk = false; } } if (logging != null) { try { Logger log = SolrCore.log; Logger parent = log.getParent(); while (parent != null) { log = parent; parent = log.getParent(); } log.setLevel(Level.parse(logging)); enableActionStatus = "Set Log Level (" + logging + ") Succeeded"; } catch(Exception e) { enableActionStatus += "Set Log Level (" + logging + ") Failed: " + e.toString(); wasOk = false; } } } else { enableActionStatus = "Illegal Action"; } String hostname="localhost"; try { InetAddress addr = InetAddress.getLocalHost(); // Get IP Address byte[] ipAddr = addr.getAddress(); // Get hostname // hostname = addr.getHostName(); hostname = addr.getCanonicalHostName(); } catch (UnknownHostException e) {} %> <% if (wasOk) { %> <% } %> SOLR

SOLR Action (<%= collectionName %>) - <%= action %>

<%= hostname %> : <%= request.getServerPort() %>

Action:

<%= action %>

Result:

<%= enableActionStatus %>

Current Time: <%= new Date().toString() %>
Server Start At: <%= startTime %>


Return to Admin Page