private readonly Dictionary <String, IUsageDataCollector> _usagedatacollectors; // Usage Data Collector #endregion #region Constructor /// <summary> /// The GraphDS server constructor. /// </summary> /// <param name="myGraphDB">The graph db instance.</param> /// <param name="myIPAddress">the IP adress this GraphDS Server should bind itself to</param> /// <param name="myPort">the port this GraphDS Server should listen on</param> /// <param name="PluginDefinitions">the plugins that shall be loaded and their according parameters</param> public GraphDS_Server(IGraphDB myGraphDB, GraphDSPlugins Plugins = null) { _iGraphDB = myGraphDB; _pluginManager = new GraphDSPluginManager(); _ID = new Guid(); _QueryLanguages = new Dictionary <string, IGraphQL>(); _DrainPipes = new Dictionary <string, IDrainPipe>(); _graphDSServices = new Dictionary <String, IService>(); _usagedatacollectors = new Dictionary <string, IUsageDataCollector>(); _plugins = Plugins; #region Load Configured Plugins if (_plugins == null) { #region set the defaults // which are: // GQL with GraphDB Parameter #region GQL List <PluginDefinition> QueryLanguages = new List <PluginDefinition>(); Dictionary <string, object> GQL_Parameters = new Dictionary <string, object>(); GQL_Parameters.Add("GraphDB", myGraphDB); QueryLanguages.Add(new PluginDefinition("sones.gql", GQL_Parameters)); #endregion _plugins = new GraphDSPlugins(QueryLanguages, null); #endregion } // now at least the default plugins or a user setup is stored in the _plugins structure // iterate through and instantiate if found #region IGraphQL Plugins if (_plugins.IGraphQLPlugins != null) { // we got QL foreach (PluginDefinition _pd in _plugins.IGraphQLPlugins) { // load! IGraphQL loaded = LoadIGraphQLPlugins(_pd); // add! if (loaded != null) { _QueryLanguages.Add(_pd.NameOfPlugin, loaded); } // else // System.Diagnostics.Debug.WriteLine("Could not load plugin " + _pd.NameOfPlugin); } } #endregion #region IDrainPipe Plugins if (_plugins.IDrainPipePlugins != null) { // we got IDrainPipePlugins foreach (PluginDefinition _pd in _plugins.IDrainPipePlugins) { // load! IDrainPipe loaded = LoadIDrainPipes(_pd); // add! if (loaded != null) { _DrainPipes.Add(_pd.NameOfPlugin, loaded); } // else // System.Diagnostics.Debug.WriteLine("Could not load plugin " + _pd.NameOfPlugin); } } #endregion #region IUsageDataCollector Plugins if (_plugins.IUsageDataCollectorPlugIns != null) { // we got IUsageDataCollector foreach (PluginDefinition _pd in _plugins.IUsageDataCollectorPlugIns) { // load! IUsageDataCollector loaded = LoadIUsageDataCollector(_pd); // add! if (loaded != null) { _usagedatacollectors.Add(_pd.NameOfPlugin, loaded); } } } #endregion #endregion }
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 }
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 }