예제 #1
0
        static void Main(string[] args)
        {
            bool quiet = false;

            if (args.Count() > 0)
            {
                foreach (String parameter in args)
                {
                    if (parameter.ToUpper() == "--Q")
                        quiet = true;
                }
            }

            if (!quiet)
            {
                DiscordianDate ddate = new DiscordianDate();

                Console.WriteLine("sones GraphDB version 2.1-beta-2 - " + ddate.ToString());
                Console.WriteLine("(C) sones GmbH 2007-2011 - http://www.sones.com");
                Console.WriteLine("-----------------------------------------------");
                Console.WriteLine();
                Console.WriteLine("Starting up GraphDB...");
            }

            try
            {
                var sonesGraphDBStartup = new sonesGraphDBStartup(args);
            }
            catch (ServiceException e)
            {
                if (!quiet)
                {
                    Console.WriteLine(e.Message);
                    Console.WriteLine("InnerException: " + e.InnerException.ToString());
                    Console.WriteLine();
                    Console.WriteLine("Press <return> to exit.");
                    Console.ReadLine();
                }
            }
        }
예제 #2
0
        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
        }
예제 #3
0
        public BenchmarkGrammar(IGraphDS myGraphDS, ushort myListeningPort, string myUsername, string myPassword)
            : base(false)
        {
            #region data

            _graphDS = myGraphDS;

            #endregion

            #region grammar

            #region Terminals
            var numberLiteral = new NumberLiteral("number", NumberOptions.AllowSign | NumberOptions.DisableQuickParse);
              		var stringLiteral = new StringLiteral("string", "'", StringOptions.AllowsDoubledQuote | StringOptions.AllowsLineBreak);
            var identifier = new IdentifierTerminal("identifier", "ÄÖÜäöüß0123456789_", "ÄÖÜäöü0123456789$_");
            var S_IMPORT = ToTerm("IMPORT");
            var S_BENCHMARK = ToTerm("BENCHMARK");
            var S_ITERATIONS = ToTerm("ITERATIONS");
            var S_EQUALS = ToTerm("=");
            var S_TRUE = ToTerm("TRUE");
            var S_FALSE = ToTerm("FALSE");
            var S_OPTIONS = ToTerm("OPTIONS");
            var S_BRACKETLEFT = ToTerm("(");
            var S_BRACKETRIGHT = ToTerm(")");
            var S_COMMA = ToTerm(",");
            var S_CLEAR = ToTerm("CLEAR");
            var S_LIST = ToTerm("LIST");

            #endregion

              		#region Non-terminals

            var NT_options = new NonTerminal("Options", CreateOptionsNode);
               	var NT_KeyValueList = new NonTerminal("ValueList", CreateKeyValueListNode);
            var NT_KeyValuePair = new NonTerminal("KeyValuePair", CreateKeyValuePairNode);
            var NT_BooleanVal = new NonTerminal("BooleanVal");
            var NT_iterations = new NonTerminal("Iterations");
            var NT_import = new NonTerminal("Import", CreateImportNode);
            var NT_clear = new NonTerminal("Clear", CreateClearNode);
            var NT_benchmark = new NonTerminal("Benchmark", CreateBenchmarkNode);
            var NT_list = new NonTerminal("List", CreateListNode);
              		var NT_Stmt = new NonTerminal("Stmt", CreateStatementNode);

            #endregion

            #region BNF rules

            NT_BooleanVal.Rule = S_TRUE | S_FALSE;

            NT_KeyValuePair.Rule = 	identifier + S_EQUALS + stringLiteral
                                | 	identifier + S_EQUALS + numberLiteral
                                | 	identifier + S_EQUALS + NT_BooleanVal;

            NT_KeyValueList.Rule = MakePlusRule(NT_KeyValueList, S_COMMA, NT_KeyValuePair);

            NT_options.Rule =	Empty
                          	|   S_OPTIONS + S_BRACKETLEFT + NT_KeyValueList + S_BRACKETRIGHT;

            NT_Stmt.Rule = NT_import | NT_benchmark | NT_clear | NT_list;

            NT_iterations.Rule = 	Empty
                         		|	S_ITERATIONS + S_EQUALS + numberLiteral;

            NT_import.Rule = S_IMPORT + stringLiteral + NT_options;

            NT_clear.Rule = S_CLEAR;

            NT_list.Rule = S_LIST;

            NT_benchmark.Rule = S_BENCHMARK + stringLiteral + NT_iterations + NT_options;

              		this.Root = NT_Stmt;       // Set grammar root

            #endregion

              		#region Token filter
              		//we need to add continuation symbol to NonGrammarTerminals because it is not used anywhere in grammar
              		NonGrammarTerminals.Add(ToTerm(@"\"));

            #endregion

              		#region Initialize console attributes

            DiscordianDate ddate = new DiscordianDate();

            ConsoleTitle = "sones GraphDB Benchmark Console";
              		ConsoleGreeting =
            @"
            sones GraphDB version 2.0 - " +ddate.ToString() + @"
            (C) sones GmbH 2007-2011 - http://www.sones.com
            -----------------------------------------------

            This GraphDB Instance offers the following options:

               * REST Service is started at http://localhost:" + myListeningPort + @"
              * access it directly by passing the GraphQL query using the
            REST interface or a client library. (see documentation)
              * if you want JSON Output add ACCEPT: application/json
            to the client request header (or application/xml or
            application/text)

               * we recommend to use the AJAX WebShell.
            Browse to http://localhost:" + myListeningPort + @"/WebShell and use
            the username """ + myUsername+ @""" and password """+ myPassword + @"""

               * Benchmark commands are:
              * IMPORT 'importPluginName' [key = value [, key = value]]
              * BENCHMARK 'benchmarkPluginName' ITERATIONS = countOfIterations [key = value [, key = value]]
              * CLEAR
              * LIST

            Press Ctrl-C to exit the program at any time.
            ";
              		ConsolePrompt = "Benchmark> ";
              		ConsolePromptMoreInput = "...";

            #endregion

              		this.LanguageFlags = LanguageFlags.CreateAst | LanguageFlags.CanRunSample;
            MarkPunctuation(S_BRACKETLEFT.ToString(), S_BRACKETRIGHT.ToString());

            #endregion
        }