profile upload (a first implementation), similar to CgiUpload,
adds a new customprofiledir argument, a new file is created on each upload
This commit is contained in:
parent
ba867b4779
commit
6f9cef9b3f
5 changed files with 126 additions and 14 deletions
|
|
@ -20,6 +20,7 @@ import btools.router.OsmNodeNamed;
|
|||
import btools.router.OsmTrack;
|
||||
import btools.router.RoutingContext;
|
||||
import btools.router.RoutingEngine;
|
||||
import btools.server.request.ProfileUploadHandler;
|
||||
import btools.server.request.RequestHandler;
|
||||
import btools.server.request.ServerHandler;
|
||||
|
||||
|
|
@ -65,6 +66,16 @@ public class RouteServer extends Thread
|
|||
{
|
||||
handler = new ServerHandler( serviceContext, params );
|
||||
}
|
||||
else if ("/brouter/profile".equals(url))
|
||||
{
|
||||
writeHttpHeader(bw);
|
||||
|
||||
ProfileUploadHandler uploadHandler = new ProfileUploadHandler( serviceContext );
|
||||
uploadHandler.handlePostRequest(br, bw);
|
||||
|
||||
bw.flush();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException( "unknown request syntax: " + getline );
|
||||
|
|
@ -76,12 +87,7 @@ public class RouteServer extends Thread
|
|||
cr.quite = true;
|
||||
cr.doRun( maxRunningTime );
|
||||
|
||||
// http-header
|
||||
bw.write( "HTTP/1.1 200 OK\n" );
|
||||
bw.write( "Connection: close\n" );
|
||||
bw.write( "Content-Type: text/xml; charset=utf-8\n" );
|
||||
bw.write( "Access-Control-Allow-Origin: *\n" );
|
||||
bw.write( "\n" );
|
||||
writeHttpHeader(bw);
|
||||
|
||||
if ( cr.getErrorMessage() != null )
|
||||
{
|
||||
|
|
@ -115,22 +121,23 @@ public class RouteServer extends Thread
|
|||
public static void main(String[] args) throws Exception
|
||||
{
|
||||
System.out.println("BRouter 0.9.9 / 18042014 / abrensch");
|
||||
if ( args.length != 4 )
|
||||
if ( args.length != 5 )
|
||||
{
|
||||
System.out.println("serve BRouter protocol");
|
||||
System.out.println("usage: java RouteServer <segmentdir> <profiledir> <port> <maxthreads>");
|
||||
System.out.println("usage: java RouteServer <segmentdir> <profiledir> <customprofiledir> <port> <maxthreads>");
|
||||
return;
|
||||
}
|
||||
|
||||
ServiceContext serviceContext = new ServiceContext();
|
||||
serviceContext.segmentDir = args[0];
|
||||
System.setProperty( "profileBaseDir", args[1] );
|
||||
serviceContext.customProfileDir = args[2];
|
||||
|
||||
int maxthreads = Integer.parseInt( args[3] );
|
||||
int maxthreads = Integer.parseInt( args[4] );
|
||||
|
||||
TreeMap<Long,RouteServer> threadMap = new TreeMap<Long,RouteServer>();
|
||||
|
||||
ServerSocket serverSocket = new ServerSocket(Integer.parseInt(args[2]));
|
||||
ServerSocket serverSocket = new ServerSocket(Integer.parseInt(args[3]));
|
||||
long last_ts = 0;
|
||||
for (;;)
|
||||
{
|
||||
|
|
@ -187,4 +194,13 @@ public class RouteServer extends Thread
|
|||
}
|
||||
return maxRunningTime;
|
||||
}
|
||||
|
||||
private static void writeHttpHeader(BufferedWriter bw) throws IOException {
|
||||
// http-header
|
||||
bw.write( "HTTP/1.1 200 OK\n" );
|
||||
bw.write( "Connection: close\n" );
|
||||
bw.write( "Content-Type: text/xml; charset=utf-8\n" );
|
||||
bw.write( "Access-Control-Allow-Origin: *\n" );
|
||||
bw.write( "\n" );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue