Search in sources :

Example 1 with SPARQLServer

use of org.apache.jena.fuseki.server.SPARQLServer in project jena by apache.

the class MgtCmdServlet method doGet.

@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp) {
    try {
        // serverLog.info("Fuseki Server Config servlet") ;
        PrintWriter out = resp.getWriter();
        resp.setContentType("text/plain");
        SPARQLServer server = Fuseki.getServer();
        out.println("Software:");
        String fusekiVersion = Fuseki.VERSION;
        if (fusekiVersion.equals("${project.version}"))
            fusekiVersion = "(development)";
        out.printf("  %s %s\n", Fuseki.NAME, fusekiVersion);
        out.printf("  %s %s\n", TDB.NAME, TDB.VERSION);
        out.printf("  %s %s\n", ARQ.NAME, ARQ.VERSION);
        out.printf("  %s %s\n", Jena.NAME, Jena.VERSION);
        // out.printf("Port: %s\n",
        // server.getServer().getConnectors()[0].getPort()) ;
        out.println();
        for (DatasetRef dsRef : server.getDatasets()) {
            datasetRefDetails(out, dsRef);
            out.println();
        }
    } catch (IOException ex) {
    }
}
Also used : IOException(java.io.IOException) DatasetRef(org.apache.jena.fuseki.server.DatasetRef) SPARQLServer(org.apache.jena.fuseki.server.SPARQLServer) PrintWriter(java.io.PrintWriter)

Example 2 with SPARQLServer

use of org.apache.jena.fuseki.server.SPARQLServer in project jena by apache.

the class FusekiCmd method exec.

@Override
protected void exec() {
    if (homeDir == null) {
        if (System.getenv(Fuseki.FusekiHomeEnv) != null)
            homeDir = System.getenv(Fuseki.FusekiHomeEnv);
        else
            homeDir = ".";
    }
    homeDir = sort_out_dir(homeDir);
    Fuseki.configLog.info("Home Directory: " + FileOps.fullDirectoryPath(homeDir));
    if (!FileOps.exists(homeDir))
        Fuseki.configLog.warn("No such directory for Fuseki home: " + homeDir);
    String staticContentDir = pagesDir;
    if (staticContentDir == null)
        staticContentDir = homeDir + Fuseki.PagesStatic;
    Fuseki.configLog.debug("Static Content Directory: " + FileOps.fullDirectoryPath(staticContentDir));
    if (!FileOps.exists(staticContentDir)) {
        Fuseki.configLog.warn("No such directory for static content: " + FileOps.fullDirectoryPath(staticContentDir));
        Fuseki.configLog.warn("You may need to set the --pages or --home option to configure static content correctly");
    }
    if (jettyConfigFile != null)
        Fuseki.configLog.info("Jetty configuration: " + jettyConfigFile);
    ServerConfig serverConfig;
    if (fusekiConfigFile != null) {
        Fuseki.configLog.info("Configuration file: " + fusekiConfigFile);
        serverConfig = FusekiConfig.configure(fusekiConfigFile);
    } else {
        serverConfig = FusekiConfig.defaultConfiguration(datasetPath, dsg, allowUpdate, listenLocal);
        if (!allowUpdate)
            Fuseki.serverLog.info("Running in read-only mode.");
    }
    // TODO Get from parsing config file.
    serverConfig.port = port;
    serverConfig.pages = staticContentDir;
    serverConfig.mgtPort = mgtPort;
    serverConfig.pagesPort = port;
    serverConfig.loopback = listenLocal;
    serverConfig.enableCompression = enableCompression;
    serverConfig.jettyConfigFile = jettyConfigFile;
    serverConfig.authConfigFile = authConfigFile;
    serverConfig.verboseLogging = (super.isVerbose() || super.isDebug());
    SPARQLServer server = new SPARQLServer(serverConfig);
    // Temporary
    Fuseki.setServer(server);
    Server mgtServer = null;
    if (mgtPort > 0) {
        Fuseki.configLog.info("Management services on port " + mgtPort);
        mgtServer = ManagementServer.createManagementServer(mgtPort);
        try {
            mgtServer.start();
        } catch (java.net.BindException ex) {
            serverLog.error("SPARQLServer: Failed to start management server: " + ex.getMessage());
            System.exit(1);
        } catch (Exception ex) {
            serverLog.error("SPARQLServer: Failed to start management server: " + ex.getMessage(), ex);
            System.exit(1);
        }
    }
    try {
        server.start();
    } catch (FusekiException ex) {
        serverLog.warn("Failed to start the server.", ex);
    }
    try {
        server.getServer().join();
    } catch (Exception ex) {
    }
    if (mgtServer != null) {
        try {
            mgtServer.stop();
        } catch (Exception e) {
            serverLog.warn("Failed to cleanly stop the management server", e);
        }
    }
    System.exit(0);
}
Also used : ServerConfig(org.apache.jena.fuseki.server.ServerConfig) SPARQLServer(org.apache.jena.fuseki.server.SPARQLServer) Server(org.eclipse.jetty.server.Server) ManagementServer(org.apache.jena.fuseki.mgt.ManagementServer) SPARQLServer(org.apache.jena.fuseki.server.SPARQLServer) CmdException(jena.cmd.CmdException)

Aggregations

SPARQLServer (org.apache.jena.fuseki.server.SPARQLServer)2 IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1 CmdException (jena.cmd.CmdException)1 ManagementServer (org.apache.jena.fuseki.mgt.ManagementServer)1 DatasetRef (org.apache.jena.fuseki.server.DatasetRef)1 ServerConfig (org.apache.jena.fuseki.server.ServerConfig)1 Server (org.eclipse.jetty.server.Server)1