Пример #1
0
        /// <summary> Конструктор класса GraphDBTest
        /// Создается база данных graphDB и сервер GraphDSServer
        /// </summary>
        public GraphDBTest()
        {
            var graphDB = new SonesGraphDB();

            List<PluginDefinition> QueryLanguagePATH = new List<PluginDefinition>();
            Dictionary<string, object> GQL_Parameters = new Dictionary<string, object>();
            GQL_Parameters.Add("GraphDB", graphDB);

            QueryLanguagePATH.Add(new PluginDefinition("sones.gql", GQL_Parameters));
 
            //adding the QueryLanguage as a GraphDSPlugin
            GraphDSPlugins PluginsAndParameters = new GraphDSPlugins(QueryLanguagePATH);

            GraphDSServer = new GraphDS_Server(graphDB, PluginsAndParameters);
            
            SecToken = GraphDSServer.LogOn(new UserPasswordCredentials("User", "test"));
            TransactionID = GraphDSServer.BeginTransaction(SecToken);

            edge_list = new List<List< KeyValuePair<long, Int32> >>();

            Dictionary<string, object> RestParameter = new Dictionary<string, object>();
            RestParameter.Add("IPAddress", IPAddress.Any);
            RestParameter.Add("Port", 9975);
            RestParameter.Add("Username", "test");
            RestParameter.Add("Password", "test");
            GraphDSServer.StartService("sones.RESTService", RestParameter);
        }
Пример #2
0
        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);
        }
Пример #3
0
        public TagExample()
        {
            //Make a new GraphDB instance
            var graphDB = new SonesGraphDB();

            var credentials = new UserPasswordCredentials("User", "test");

            //GraphDSServer = new GraphDS_Server(GraphDB, (ushort)9975, "User", "test", IPAddress.Any, PluginsAndParameters);
            GraphDSServer = new GraphDS_Server(graphDB, null);
            GraphDSServer.LogOn(credentials);
            //GraphDSServer.StartRESTService("", Properties.Settings.Default.ListeningPort, IPAddress.Any);

            //get a SecurityToken and an TransactionID
            SecToken = GraphDSServer.LogOn(credentials);
            TransationID = GraphDSServer.BeginTransaction(SecToken);
        }
Пример #4
0
        public TagExample()
        {
            //Make a new GraphDB instance
            var graphDB = new SonesGraphDB();

            var credentials = new UserPasswordCredentials("User", "test");

            //GraphDSServer = new GraphDS_Server(GraphDB, (ushort)9975, "User", "test", IPAddress.Any, PluginsAndParameters);
            GraphDSServer = new GraphDS_Server(graphDB, null);
            GraphDSServer.LogOn(credentials);
            //GraphDSServer.StartRESTService("", Properties.Settings.Default.ListeningPort, IPAddress.Any);

            //get a SecurityToken and an TransactionID
            SecToken     = GraphDSServer.LogOn(credentials);
            TransationID = GraphDSServer.BeginTransaction(SecToken);
        }
Пример #5
0
        public TagExampleWithGraphMappingFramework(String[] myArgs)
        {
            Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.GetCultureInfo("en-us");

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

            #region Start RemoteAPI, WebDAV and WebAdmin services, send GraphDS notification

            IGraphDB GraphDB;

            GraphDB = new SonesGraphDB(null, true, new CultureInfo("en-us"));

            #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 GraphDS Service Plugins
            List<PluginDefinition> GraphDSServices = new List<PluginDefinition>();
            #endregion

            List<PluginDefinition> UsageDataCollector = new List<PluginDefinition>();

            #endregion

            GraphDSPlugins PluginsAndParameters = new GraphDSPlugins(QueryLanguages);
            _dsServer = new GraphDS_Server(GraphDB, PluginsAndParameters);

            #region Start GraphDS Services

            #region Remote API Service
            Dictionary<string, object> RemoteAPIParameter = new Dictionary<string, object>();
            RemoteAPIParameter.Add("IPAddress", IPAddress.Parse("127.0.0.1"));
            RemoteAPIParameter.Add("Port", (ushort)9970);
            _dsServer.StartService("sones.RemoteAPIService", RemoteAPIParameter);
            #endregion

            #endregion

            #endregion

        #endregion

            #region Some helping lines...
            if (!quiet)
            {
                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("   * the following GraphDS Service Plugins are initialized and started: ");

                foreach (var Service in _dsServer.AvailableServices)
                {
                    Console.WriteLine("      * " + Service.PluginName);
                }
                Console.WriteLine();

                foreach (var Service in _dsServer.AvailableServices)
                {
                    Console.WriteLine(Service.ServiceDescription);
                    Console.WriteLine();
                }

                Console.WriteLine("Enter 'shutdown' to initiate the shutdown of this instance.");
            }



            Run();

            Console.CancelKeyPress += OnCancelKeyPress;

            while (!shutdown)
            {
                String command = Console.ReadLine();

                if (!_ctrlCPressed)
                {
                    if (command != null)
                    {
                        if (command.ToUpper() == "SHUTDOWN")
                            shutdown = true;
                    }
                }
            }

            Console.WriteLine("Shutting down GraphDS Server");
            _dsServer.Shutdown(null);
            Console.WriteLine("Shutdown complete");
            #endregion
        }
        public void InitializePlugin_CheckPropertyIDs()
        {
            #region data

            // create db
            var graphDB = new SonesGraphDB();
            var transactionToken = 0L;
            var securityToken = new SecurityToken();

            // create vertex type with attribute
            var vertexType = graphDB.CreateVertexType<IVertexType>(securityToken,
                transactionToken,
                new RequestCreateVertexType(
                    new VertexTypePredefinition("dummy")
                    .AddProperty(new PropertyPredefinition("age", "Int32"))),
                    (stats, type) => type);

            // create persistent index on attribute
            var indexDef = graphDB.CreateIndex<IIndexDefinition>(securityToken,
                transactionToken,
                new RequestCreateIndex(new IndexPredefinition("myindex", "dummy").AddProperty("age").SetIndexType("binarytree")),
                (stats, index) => index);

            #endregion

            #region test

            var metaManager = GetMetaManager(graphDB);
            var sonesIdx = metaManager.IndexManager.GetIndex("myindex", securityToken, transactionToken);

            // propertyID stored at the index
            var indexPropertyIDs = (List<Int64>)new BinaryTreeIndex().GetType().GetField("_PropertyIDs", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(sonesIdx);

            // propertyID stored at the vertextype
            var propID = vertexType.GetPropertyDefinition("age").ID;

            Assert.IsTrue(indexPropertyIDs.Contains(propID), "indexed propertyID is not the same as propertyID at vertex type");

            #endregion

            #region Cleanup

            graphDB.Shutdown(securityToken);

            #endregion
        }
Пример #7
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)
            {
                if (!quiet)
                {
                    Console.WriteLine("Initializing persistence layer...");
                }

                Uri    configuredLocation            = new Uri(Properties.Settings.Default.PersistenceLocation, UriKind.RelativeOrAbsolute);
                string configuredPageSize            = Properties.Settings.Default.PageSize;
                string configuredBufferSize          = Properties.Settings.Default.BufferSizeInPages;
                string configuredUseVertexExtensions = Properties.Settings.Default.UseVertexExtensions;
                string configuredWriteStrategy       = Properties.Settings.Default.WriteStrategy;
                /* Configure the location */

                Uri location = null;

                if (configuredLocation.IsAbsoluteUri)
                {
                    location = configuredLocation;
                }
                else
                {
                    Uri rootPath = new Uri(System.Reflection.Assembly.GetAssembly((typeof(sones.Library.Commons.VertexStore.IVertexStore))).Location);
                    location = new Uri(rootPath, configuredLocation);
                }

                /* Configuration for the page size */
                int pageSize = Int32.Parse(configuredPageSize);

                /* Configuration for the buffer size */
                int bufferSize = Int32.Parse(configuredBufferSize);

                /* Configuration for using vertex extensions */
                bool useVertexExtensions = Boolean.Parse(configuredUseVertexExtensions);

                /* Make a new instance by applying the configuration */
                try
                {
                    //Make a new GraphDB instance
                    GraphDB = new SonesGraphDB(new GraphDBPlugins(
                                                   new PluginDefinition("sones.pagedfsnonrevisionedplugin", new Dictionary <string, object>()
                    {
                        { "location", location },
                        { "pageSize", pageSize },
                        { "bufferSizePages", bufferSize },
                        { "writeStrategy", configuredWriteStrategy },
                        { "useVertexExtensions", useVertexExtensions }
                    })), true, null, location.AbsolutePath);


                    if (!quiet)
                    {
                        Console.WriteLine("Persistence layer initialized.");
                    }
                }
                catch (Exception a)
                {
                    if (!quiet)
                    {
                        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 GraphDS Service Plugins
            List <PluginDefinition> GraphDSServices = new List <PluginDefinition>();
            #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
            List <PluginDefinition> UsageDataCollector = new List <PluginDefinition>();

            #region UsageDataCollector
            if (Properties.Settings.Default.UDCEnabled)
            {
                Dictionary <string, object> UDC_parameters = new Dictionary <string, object>();
                UDC_parameters.Add("UDCWaitUpfrontTime", (Int32)Properties.Settings.Default.UDCWaitUpfront);                          // do the work in a separate thread to not slow down queries
                UDC_parameters.Add("UDCUpdateInterval", (Int32)Properties.Settings.Default.UDCUpdateInterval);                        // 10
                UsageDataCollector.Add(new PluginDefinition("sones.GraphDS.UsageDataCollectorClient", UDC_parameters));
            }
            #endregion

            #endregion

            GraphDSPlugins PluginsAndParameters = new GraphDSPlugins(QueryLanguages, DrainPipes, UsageDataCollector);
            _dsServer = new GraphDS_Server(GraphDB, PluginsAndParameters);

            #region Start GraphDS Services

            #region pre-configure REST Service
            Dictionary <string, object> RestParameter = new Dictionary <string, object>();
            RestParameter.Add("IPAddress", IPAddress.Any);
            RestParameter.Add("Port", Properties.Settings.Default.ListeningPort);
            RestParameter.Add("Username", Properties.Settings.Default.Username);
            RestParameter.Add("Password", Properties.Settings.Default.Password);
            _dsServer.StartService("sones.RESTService", RestParameter);
            #endregion

            #region Remote API Service

            Dictionary <string, object> RemoteAPIParameter = new Dictionary <string, object>();
            RemoteAPIParameter.Add("IPAddress", IPAddress.Any);
            RemoteAPIParameter.Add("Port", (ushort)9970);
            //RemoteAPIParameter.Add("IsSecure", true);

            _dsServer.StartService("sones.RemoteAPIService", RemoteAPIParameter);
            #endregion


            #endregion

            _dsServer.LogOn(new UserPasswordCredentials(Properties.Settings.Default.Username, Properties.Settings.Default.Password));

            #endregion

            #region Some helping lines...
            if (!quiet)
            {
                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("   * the following GraphDS Service Plugins are initialized and started: ");

                foreach (var Service in _dsServer.AvailableServices)
                {
                    Console.WriteLine("      * " + Service.PluginName);
                }
                Console.WriteLine();

                foreach (var Service in _dsServer.AvailableServices)
                {
                    Console.WriteLine(Service.ServiceDescription);
                    Console.WriteLine();
                }

                Console.WriteLine("Enter 'shutdown' to initiate the shutdown of this instance.");
            }

            Console.CancelKeyPress += OnCancelKeyPress;

            while (!shutdown)
            {
                String command = Console.ReadLine();

                if (!_ctrlCPressed)
                {
                    if (command != null)
                    {
                        if (command.ToUpper() == "SHUTDOWN")
                        {
                            shutdown = true;
                        }
                    }
                }
            }

            Console.WriteLine("Shutting down GraphDS Server");
            _dsServer.Shutdown(null);
            Console.WriteLine("Shutdown complete");
            #endregion
        }
Пример #8
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)
            {
                if (!quiet)
                   Console.WriteLine("Initializing persistence layer...");

                Uri configuredLocation = new Uri(Properties.Settings.Default.PersistenceLocation, UriKind.RelativeOrAbsolute);
                string configuredPageSize = Properties.Settings.Default.PageSize;
                string configuredBufferSize = Properties.Settings.Default.BufferSizeInPages;
                string configuredUseVertexExtensions = Properties.Settings.Default.UseVertexExtensions;
                string configuredWriteStrategy = Properties.Settings.Default.WriteStrategy;
                /* Configure the location */

                Uri location = null;

                if (configuredLocation.IsAbsoluteUri)
                {
                    location = configuredLocation;
                }
                else
                {
                    Uri rootPath = new Uri(System.Reflection.Assembly.GetAssembly((typeof(sones.Library.Commons.VertexStore.IVertexStore))).Location);
                    location = new Uri(rootPath, configuredLocation);
                }

                 /* Configuration for the page size */
                int pageSize = Int32.Parse(configuredPageSize);

                /* Configuration for the buffer size */
                int bufferSize = Int32.Parse(configuredBufferSize);

                /* Configuration for using vertex extensions */
                bool useVertexExtensions = Boolean.Parse(configuredUseVertexExtensions);

                /* Make a new instance by applying the configuration */
                try
                {
                    //Make a new GraphDB instance
                     GraphDB = new SonesGraphDB(new GraphDBPlugins(
                        new PluginDefinition("sones.pagedfsnonrevisionedplugin", new Dictionary<string, object>() { { "location", location },
                                                                                                                    { "pageSize", pageSize },
                                                                                                                    { "bufferSizePages", bufferSize },
                                                                                                                    { "writeStrategy", configuredWriteStrategy },
                                                                                                                    { "useVertexExtensions", useVertexExtensions } })), true, null, location.AbsolutePath);

                    if (!quiet)
                        Console.WriteLine("Persistence layer initialized.");
                }
                catch (Exception a)
                {
                    if (!quiet)
                    {
                        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 GraphDS Service Plugins
                List<PluginDefinition> GraphDSServices = new List<PluginDefinition>();
                #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
                List<PluginDefinition> UsageDataCollector = new List<PluginDefinition>();

                #region UsageDataCollector
                if (Properties.Settings.Default.UDCEnabled)
                {
                    Dictionary<string, object> UDC_parameters = new Dictionary<string, object>();
                    UDC_parameters.Add("UDCWaitUpfrontTime", (Int32)Properties.Settings.Default.UDCWaitUpfront);  // do the work in a separate thread to not slow down queries
                    UDC_parameters.Add("UDCUpdateInterval", (Int32)Properties.Settings.Default.UDCUpdateInterval); // 10
                    UsageDataCollector.Add(new PluginDefinition("sones.GraphDS.UsageDataCollectorClient",UDC_parameters));
                }
                #endregion

            #endregion

            GraphDSPlugins PluginsAndParameters = new GraphDSPlugins(QueryLanguages, DrainPipes,UsageDataCollector);
            _dsServer = new GraphDS_Server(GraphDB, PluginsAndParameters);

            #region Start GraphDS Services

            #region pre-configure REST Service
            Dictionary<string, object> RestParameter = new Dictionary<string, object>();
            RestParameter.Add("IPAddress", System.Net.IPAddress.Any);
            RestParameter.Add("Port", Properties.Settings.Default.ListeningPort);
            RestParameter.Add("Username", Properties.Settings.Default.Username);
            RestParameter.Add("Password", Properties.Settings.Default.Password);
            _dsServer.StartService("sones.RESTService", RestParameter);
            #endregion

            #region Remote API Service

            Dictionary<string, object> RemoteAPIParameter = new Dictionary<string, object>();
            RemoteAPIParameter.Add("IPAddress", System.Net.IPAddress.Any);
            RemoteAPIParameter.Add("Port", (ushort)9970);
            //RemoteAPIParameter.Add("IsSecure", true);

            _dsServer.StartService("sones.RemoteAPIService", RemoteAPIParameter);
            #endregion

            #endregion

            _dsServer.LogOn(new UserPasswordCredentials(Properties.Settings.Default.Username,Properties.Settings.Default.Password));

            #endregion

            #region Some helping lines...
            if (!quiet)
            {
                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("   * the following GraphDS Service Plugins are initialized and started: ");

                foreach (var Service in _dsServer.AvailableServices)
                {
                    Console.WriteLine("      * "+Service.PluginName);
                }
                Console.WriteLine();

                foreach (var Service in _dsServer.AvailableServices)
                {
                    Console.WriteLine(Service.ServiceDescription);
                    Console.WriteLine();
                }

                Console.WriteLine("Enter 'shutdown' to initiate the shutdown of this instance.");
            }

            Console.CancelKeyPress += OnCancelKeyPress;

            while (!shutdown)
            {
                String command = Console.ReadLine();

                if (!_ctrlCPressed)
                {
                    if (command != null)
                    {
                        if (command.ToUpper() == "SHUTDOWN")
                            shutdown = true;
                    }
                }
            }

            Console.WriteLine("Shutting down GraphDS Server");
            _dsServer.Shutdown(null);
            Console.WriteLine("Shutdown complete");
            #endregion
        }
Пример #9
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
        }
Пример #10
0
        public TagExampleWithGraphMappingFramework(String[] myArgs)
        {
            Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.GetCultureInfo("en-us");

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

            #region Start RemoteAPI, WebDAV and WebAdmin services, send GraphDS notification

            IGraphDB GraphDB;

            GraphDB = new SonesGraphDB(null, true, new CultureInfo("en-us"));

            #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 GraphDS Service Plugins
            List <PluginDefinition> GraphDSServices = new List <PluginDefinition>();
            #endregion

            List <PluginDefinition> UsageDataCollector = new List <PluginDefinition>();

            #endregion

            GraphDSPlugins PluginsAndParameters = new GraphDSPlugins(QueryLanguages);
            _dsServer = new GraphDS_Server(GraphDB, PluginsAndParameters);

            #region Start GraphDS Services

            #region Remote API Service
            Dictionary <string, object> RemoteAPIParameter = new Dictionary <string, object>();
            RemoteAPIParameter.Add("IPAddress", IPAddress.Parse("127.0.0.1"));
            RemoteAPIParameter.Add("Port", (ushort)9970);
            RemoteAPIParameter.Add("IsSecure", false);
            _dsServer.StartService("sones.RemoteAPIService", RemoteAPIParameter);
            #endregion

            #endregion

            #endregion

            #endregion

            #region Some helping lines...
            if (!quiet)
            {
                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("   * the following GraphDS Service Plugins are initialized and started: ");

                foreach (var Service in _dsServer.AvailableServices)
                {
                    Console.WriteLine("      * " + Service.PluginName);
                }
                Console.WriteLine();

                foreach (var Service in _dsServer.AvailableServices)
                {
                    Console.WriteLine(Service.ServiceDescription);
                    Console.WriteLine();
                }

                Console.WriteLine("Enter 'shutdown' to initiate the shutdown of this instance.");
            }



            Run();

            Console.CancelKeyPress += OnCancelKeyPress;

            while (!shutdown)
            {
                String command = Console.ReadLine();

                if (!_ctrlCPressed)
                {
                    if (command != null)
                    {
                        if (command.ToUpper() == "SHUTDOWN")
                        {
                            shutdown = true;
                        }
                    }
                }
            }

            Console.WriteLine("Shutting down GraphDS Server");
            _dsServer.Shutdown(null);
            Console.WriteLine("Shutdown complete");
            #endregion
        }