[
https://issues.apache.org/jira/browse/ACCUMULO-490?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13236296#comment-13236296
]
David Medinets commented on ACCUMULO-490:
-----------------------------------------
I was thinking something much simpler. Something that could be just a java
process so there are few dependencies. Perhaps something like this:
public class SingleFileHTTPServer extends Thread {
private static Logger logger = Logger.getLogger(CriteriaWatchServer.class);
private int port = 9876;
private String encoding = "ASCII";
private int pagesServed = 1;
private IDB db = null;
UrlRequestProcessor urlRequestProcessor = null;
private boolean endProcess = false;
public SingleFileHTTPServer() throws IOException {
StopWatch.add("httpServer");
}
public void run() {
//logger.debug("SingleFileHTTPServer; running.");
try {
ServerSocket server = new ServerSocket(this.port);
server.setSoTimeout(1000);
logger.info("Accepting connections on port " +
server.getLocalPort());
while (!endProcess) {
Socket connection = null;
int bufferSize = 1000;
StringBuffer request = new StringBuffer(bufferSize);
try {
connection = server.accept();
OutputStream out = new
BufferedOutputStream(connection.getOutputStream());
InputStream in = new
BufferedInputStream(connection.getInputStream());
int bufferIndex = 0;
while (bufferIndex++ < bufferSize) {
int c = in.read();
if (c == '\r' || c == '\n' || c == -1)
break;
request.append((char) c);
// If this is HTTP/1.0 or later send a MIME header
}
DecimalFormat myFormat = (DecimalFormat)
DecimalFormat.getInstance();
myFormat.setDecimalSeparatorAlwaysShown(true);
//logger.fatal("qs: " + request.toString());
try {
out.write(urlRequestProcessor.process(request.toString()).getBytes(encoding));
} catch (StopServerException e) {
logger.debug("Stopping the Server.");
endProcess = true;
}
//logger.debug("SingleFileHTTPServer; running serving page
[" + myFormat.format(pagesServed) + "].");
out.flush();
out.close();
pagesServed++;
} catch (InterruptedIOException e) {
// ignore this error. when the access() times out, then
// a new accept() is started. The timeout lets calling
// processes easily stop the server.
} catch (IOException e) {
logger.error("SingleFileHTTPServer; IOException [" +
e.getMessage() + "]");
} finally {
if (connection != null) {
//logger.debug("SingleFileHTTPServer; closing
connection.");
connection.close();
}
}
} // end while(!endProcess)
} // end try
catch (IOException e) {
// LogConfiguration.fatal("F063: Could not start HTTP server. Port
// Occupied, probably another process is already running.");
}
} // end run
}
This would make a swell separate github project as well.
> Provide REST-ful Web Service
> ----------------------------
>
> Key: ACCUMULO-490
> URL: https://issues.apache.org/jira/browse/ACCUMULO-490
> Project: Accumulo
> Issue Type: New Feature
> Reporter: David Medinets
> Priority: Minor
>
> This web service will:
> - provide cross language compatibility.
> - provide data access without direct access to nodes.
> - provide work-around for port restrictions.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira