public sonesGraphDBStartup(String[] myArgs) { Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.GetCultureInfo(Properties.Settings.Default.DatabaseCulture); if (myArgs.Count() > 0) { foreach (String parameter in myArgs) { if (parameter.ToUpper() == "--Q") quiet = true; } } #region Start REST, WebDAV and WebAdmin services, send GraphDS notification IGraphDB GraphDB; if (Properties.Settings.Default.UsePersistence) { Console.WriteLine("Initializing persistence layer..."); string configuredLocation = Properties.Settings.Default.PersistenceLocation; Uri location = null; if (configuredLocation.Contains("file:")) { location = new Uri(configuredLocation); } else { string rootPath = Path.GetDirectoryName(System.Reflection.Assembly.GetAssembly((typeof(sones.Library.Commons.VertexStore.IVertexStore))).Location); string dataPath = rootPath + Path.DirectorySeparatorChar + configuredLocation; location = new Uri(@dataPath); //commented because if there is any folder inside the path wich contains a whitespace, //it is misinterpreted by the system and leads to failures // if (!Directory.Exists(location.AbsolutePath)) // { //#if __MonoCS__ // Syscall.mkdir(location.AbsolutePath, FilePermissions.ACCESSPERMS); //#else // Directory.CreateDirectory(location.AbsolutePath); // Directory.SetAccessControl(location.AbsolutePath, new DirectorySecurity(location.AbsolutePath, AccessControlSections.All)); //#endif // } } try { //Make a new GraphDB instance GraphDB = new SonesGraphDB(new GraphDBPlugins(new PluginDefinition("sones.pagedfsnonrevisionedplugin", new Dictionary<string, object>() { { "location", location } }))); Console.WriteLine("Persistence layer initialized..."); } catch (Exception a) { Console.WriteLine(a.Message); Console.WriteLine(a.StackTrace); Console.Error.WriteLine("Could not access the data directory " + location.AbsoluteUri + ". Please make sure you that you have the right file access permissions!"); Console.Error.WriteLine("Using in memory storage instead."); GraphDB = new SonesGraphDB(null,true,new CultureInfo(Properties.Settings.Default.DatabaseCulture)); } } else { GraphDB = new SonesGraphDB(null, true, new CultureInfo(Properties.Settings.Default.DatabaseCulture)); } #region Configure PlugIns // Plugins are loaded by the GraphDS with their according PluginDefinition and only if they are listed // below - there is no auto-discovery for plugin types in GraphDS (!) #region Query Languages // the GQL Query Language Plugin needs the GraphDB instance as a parameter List<PluginDefinition> QueryLanguages = new List<PluginDefinition>(); Dictionary<string, object> GQL_Parameters = new Dictionary<string, object>(); GQL_Parameters.Add("GraphDB", GraphDB); QueryLanguages.Add(new PluginDefinition("sones.gql", GQL_Parameters)); #endregion #region REST Service Plugins List<PluginDefinition> SonesRESTServices = new List<PluginDefinition>(); // not yet used #endregion #region Drain Pipes //// QueryLog DrainPipe //Dictionary<string, object> QueryLog_Parameters = new Dictionary<string, object>(); //QueryLog_Parameters.Add("AsynchronousMode", true); // do the work in a separate thread to not slow down queries //QueryLog_Parameters.Add("MaximumAsyncBufferSize", (Int32)1024 * 1024 * 10); // 10 Mbytes of maximum async queue size //QueryLog_Parameters.Add("AppendLogPathAndName", "sones.drainpipelog"); //QueryLog_Parameters.Add("CreateNew", false); // always create a new file on start-up //QueryLog_Parameters.Add("FlushOnWrite", true); // always flush on each write //// the DrainPipe Log expects several parameters //Dictionary<string, object> DrainPipeLog_Parameters = new Dictionary<string, object>(); //DrainPipeLog_Parameters.Add("AsynchronousMode", true); // do the work in a separate thread to not slow down queries //DrainPipeLog_Parameters.Add("MaximumAsyncBufferSize", (Int32)1024 * 1024 * 10); // 10 Mbytes of maximum async queue size //DrainPipeLog_Parameters.Add("AppendLogPathAndName", "sones.drainpipelog"); //DrainPipeLog_Parameters.Add("CreateNew", false); // always create a new file on start-up //DrainPipeLog_Parameters.Add("FlushOnWrite", true); // always flush on each write //Dictionary<string, object> DrainPipeLog2_Parameters = new Dictionary<string, object>(); //DrainPipeLog2_Parameters.Add("AsynchronousMode", true); // do the work in a separate thread to not slow down queries //DrainPipeLog2_Parameters.Add("MaximumAsyncBufferSize", (Int32)1024 * 1024 * 10); // 10 Mbytes of maximum async queue size //DrainPipeLog2_Parameters.Add("AppendLogPathAndName", "sones.drainpipelog2"); //DrainPipeLog2_Parameters.Add("CreateNew", false); // always create a new file on start-up //DrainPipeLog2_Parameters.Add("FlushOnWrite", true); // always flush on each write List<PluginDefinition> DrainPipes = new List<PluginDefinition>(); //DrainPipes.Add(new PluginDefinition("sones.querylog", QueryLog_Parameters)); //DrainPipes.Add(new PluginDefinition("sones.drainpipelog", DrainPipeLog_Parameters)); //DrainPipes.Add(new PluginDefinition("sones.drainpipelog", DrainPipeLog2_Parameters)); #endregion #endregion GraphDSPlugins PluginsAndParameters = new GraphDSPlugins(SonesRESTServices,QueryLanguages,DrainPipes); _dsServer = new GraphDS_Server(GraphDB, Properties.Settings.Default.ListeningPort,Properties.Settings.Default.Username,Properties.Settings.Default.Password, IPAddress.Any, PluginsAndParameters); _dsServer.LogOn(new UserPasswordCredentials(Properties.Settings.Default.Username,Properties.Settings.Default.Password)); _dsServer.StartRESTService("", Properties.Settings.Default.ListeningPort, IPAddress.Any); #endregion #region Some helping lines... if (!quiet) { DiscordianDate ddate = new DiscordianDate(); Console.WriteLine("sones GraphDB version 2.0 - "+ddate.ToString()); Console.WriteLine("(C) sones GmbH 2007-2011 - http://www.sones.com"); Console.WriteLine("-----------------------------------------------"); Console.WriteLine(); Console.WriteLine("This GraphDB Instance offers the following options:"); Console.WriteLine(" * If you want to suppress console output add --Q as a"); Console.WriteLine(" parameter."); Console.WriteLine(); Console.WriteLine(" * REST Service is started at http://localhost:"+Properties.Settings.Default.ListeningPort); Console.WriteLine(" * access it directly like in this example: "); Console.WriteLine(" http://localhost:"+Properties.Settings.Default.ListeningPort+"/gql?DESCRIBE%20VERTEX%20TYPES"); Console.WriteLine(" * if you want JSON Output add ACCEPT: application/json "); Console.WriteLine(" to the client request header (or application/xml or"); Console.WriteLine(" application/text)"); Console.WriteLine(); Console.WriteLine(" * we recommend to use the AJAX WebShell. "); Console.WriteLine(" Browse to http://localhost:"+Properties.Settings.Default.ListeningPort+"/WebShell and use"); Console.WriteLine(" the username \""+Properties.Settings.Default.Username+"\" and password \""+Properties.Settings.Default.Password+"\""); Console.WriteLine(); Console.WriteLine("Enter 'shutdown' to initiate the shutdown of this instance."); } bool shutdown = false; while (!shutdown) { String command = Console.ReadLine(); if (command.ToUpper() == "SHUTDOWN") shutdown = true; } _dsServer.Shutdown(null); //GraphDB.Shutdown(null); #endregion }
public BenchmarkStartup() { Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.GetCultureInfo(_culture); #region Start REST, WebDAV and WebAdmin services, send GraphDS notification var GraphDB = new SonesGraphDB(null, true, new CultureInfo(_culture)); #region Configure PlugIns // Plugins are loaded by the GraphDS with their according PluginDefinition and only if they are listed // below - there is no auto-discovery for plugin types in GraphDS (!) #region Query Languages // the GQL Query Language Plugin needs the GraphDB instance as a parameter List<PluginDefinition> QueryLanguages = new List<PluginDefinition>(); Dictionary<string, object> GQL_Parameters = new Dictionary<string, object>(); GQL_Parameters.Add("GraphDB", GraphDB); QueryLanguages.Add(new PluginDefinition("sones.gql", GQL_Parameters)); #endregion #endregion GraphDSPlugins PluginsAndParameters = new GraphDSPlugins(myIGraphQLPlugins: QueryLanguages); _dsServer = new GraphDS_Server(GraphDB, PluginsAndParameters); #region pre-configure REST Service Dictionary<string, object> RestParameter = new Dictionary<string, object>(); RestParameter.Add("IPAddress", IPAddress.Any); RestParameter.Add("Port", _listeningPort); RestParameter.Add("Username", _userName); RestParameter.Add("Password", _password); _dsServer.StartService("sones.RESTService", RestParameter); #endregion _dsServer.StartService("sones.RESTService", RestParameter); #endregion #region start grammar and console Grammar benchmarkGrammar = new BenchmarkGrammar(_dsServer, _listeningPort, _userName, _password); var commandLine = new CommandLine(benchmarkGrammar); commandLine.Run(); #endregion _dsServer.Shutdown(null); }