/// <summary> /// Initializes a new instance of the GraphService class. /// </summary> /// <param name='fallen8'> Fallen-8. </param> public GraphService(Fallen8 fallen8) { _fallen8 = fallen8; _compilerParameters = new CompilerParameters { GenerateExecutable = false, GenerateInMemory = true, TreatWarningsAsErrors = false, IncludeDebugInformation = false, CompilerOptions = "/optimize /target:library", }; var curAss = Assembly.GetAssembly(fallen8.GetType()); _compilerParameters.ReferencedAssemblies.Add("System.dll"); _compilerParameters.ReferencedAssemblies.Add("mscorlib.dll"); _compilerParameters.ReferencedAssemblies.Add("System.dll"); _compilerParameters.ReferencedAssemblies.Add("System.Data.dll"); _compilerParameters.ReferencedAssemblies.Add(curAss.Location); _codeProvider = new CSharpCodeProvider(new Dictionary <string, string> { { "CompilerVersion", "v4.0" } }); }
public void Load(SerializationReader reader, Fallen8 fallen8) { if (WriteResource()) { reader.ReadInt32();//parameter var keyCount = reader.ReadInt32(); _idx = new Dictionary <IComparable, AGraphElement>(keyCount); for (var i = 0; i < keyCount; i++) { var key = reader.ReadObject(); var graphElementId = reader.ReadInt32(); AGraphElement graphElement; if (fallen8.TryGetGraphElement(out graphElement, graphElementId)) { _idx.Add((IComparable)key, graphElement); } else { Logger.LogError(String.Format("[SingleValueIndex] Error while deserializing the index. Could not find the graph element \"{0}\"", graphElementId)); } } FinishWriteResource(); return; } throw new CollisionException(this); }
public void GraphServiceConstructorUnitTest() { Assert.Inconclusive("TODO"); Fallen8 fallen8 = null; // TODO: Initialize to an appropriate value var target = new GraphService(fallen8); }
public void ServiceFactoryConstructorIntegrationTest() { Assert.Inconclusive("TODO."); Fallen8 fallen8 = null; // TODO: Initialize to an appropriate value var target = new ServiceFactory(fallen8); }
private static void LoadIndices(Fallen8 fallen8, IndexFactory indexFactory, List <String> indexStreams) { //load the indices for (var i = 0; i < indexStreams.Count; i++) { LoadAnIndex(indexStreams[i], fallen8, indexFactory); } }
public void Load(SerializationReader reader, Fallen8 fallen8) { _uriPattern = reader.ReadString(); _address = IPAddress.Parse(reader.ReadString()); _port = reader.ReadUInt16(); StartService(fallen8); }
private static void LoadServices(Fallen8 fallen8, ServiceFactory newServiceFactory, List <string> serviceStreams, Boolean startServices) { //load the indices for (var i = 0; i < serviceStreams.Count; i++) { LoadAService(serviceStreams[i], fallen8, newServiceFactory, startServices); } }
public static void Main(string[] args) { var shutdown = false; #region Fallen-8 startup var fallen8 = new Fallen8(); #endregion #region services #region Fallen-8 REST API fallen8.ServiceFactory.StartGraphService(); fallen8.ServiceFactory.StartAdminService(); #endregion #region benchmark api IService introService; if (fallen8.ServiceFactory.TryAddService(out introService, "Fallen-8_Benchmark_Service", "Benchmark API", null)) { introService.TryStart(); } #endregion #endregion #region shutdown Console.WriteLine("Enter 'shutdown' to initiate the shutdown of this instance."); while (!shutdown) { var command = Console.ReadLine(); if (command == null) { continue; } if (command.ToUpper() == "SHUTDOWN") { shutdown = true; } } Console.WriteLine("Shutting down Fallen-8 startup"); fallen8.Shutdown(); Console.WriteLine("Shutdown complete"); #endregion }
public void TrimUnitTest() { Assert.Inconclusive("TODO"); Fallen8 fallen8 = null; // TODO: Initialize to an appropriate value var target = new AdminService(fallen8); // TODO: Initialize to an appropriate value target.Trim(); }
public void StartAllServicesUnitTest() { Assert.Inconclusive("TODO"); Fallen8 fallen8 = null; // TODO: Initialize to an appropriate value var target = new ServiceFactory(fallen8); // TODO: Initialize to an appropriate value target.StartAllServices(); }
/// <summary> /// Recycles a Fallen-8 instance. /// </summary> /// <param name='instance'> Fallen-8 instance. </param> public void RecycleFallen8(Fallen8 instance) { instance.TabulaRasa(); if (_instances.Count < _maxValue) { _instances.Enqueue(instance); } }
public void ShutdownAllServicesIntegrationTest() { Assert.Inconclusive("TODO."); Fallen8 fallen8 = null; // TODO: Initialize to an appropriate value var target = new ServiceFactory(fallen8); // TODO: Initialize to an appropriate value target.ShutdownAllServices(); }
public void InitializeUnitTest() { Assert.Inconclusive("TODO"); var target = new RegExIndex(); // TODO: Initialize to an appropriate value Fallen8 fallen8 = null; // TODO: Initialize to an appropriate value IDictionary <string, object> parameter = null; // TODO: Initialize to an appropriate value target.Initialize(fallen8, parameter); }
public void LoadUnitTest() { Assert.Inconclusive("TODO"); Fallen8 fallen8 = null; // TODO: Initialize to an appropriate value var target = new AdminService(fallen8); // TODO: Initialize to an appropriate value string startServices = string.Empty; // TODO: Initialize to an appropriate value target.Load(startServices); }
public void UploadPluginUnitTest() { Assert.Inconclusive("TODO"); Fallen8 fallen8 = null; // TODO: Initialize to an appropriate value var target = new AdminService(fallen8); // TODO: Initialize to an appropriate value Stream dllStream = null; // TODO: Initialize to an appropriate value target.UploadPlugin(dllStream); }
/// <summary> /// Starts the actual service /// </summary> /// <param name="fallen8"> Fallen-8. </param> private void StartService(Fallen8 fallen8) { _uri = new Uri("http://" + _address + ":" + _port + "/" + _uriPattern); if (!_uri.IsWellFormedOriginalString()) { throw new Exception("The URI Pattern is not well formed!"); } Service = new GraphService(fallen8); _host = new ServiceHost(Service, _uri) { CloseTimeout = new TimeSpan(0, 0, 0, 0, 50) }; _restServiceAddress = "REST"; try { var binding = new WebHttpBinding { MaxBufferSize = 268435456, MaxReceivedMessageSize = 268435456, SendTimeout = new TimeSpan(1, 0, 0), ReceiveTimeout = new TimeSpan(1, 0, 0) }; var readerQuotas = new XmlDictionaryReaderQuotas { MaxDepth = 2147483647, MaxStringContentLength = 2147483647, MaxBytesPerRead = 2147483647, MaxNameTableCharCount = 2147483647, MaxArrayLength = 2147483647 }; binding.ReaderQuotas = readerQuotas; var se = _host.AddServiceEndpoint(typeof(IGraphService), binding, _restServiceAddress); var webBehav = new WebHttpBehavior { HelpEnabled = true }; se.Behaviors.Add(webBehav); ((ServiceBehaviorAttribute)_host.Description.Behaviors[typeof(ServiceBehaviorAttribute)]). InstanceContextMode = InstanceContextMode.Single; } catch (Exception) { _host.Abort(); throw; } }
public void StartGraphServiceIntegrationTest() { Assert.Inconclusive("TODO."); Fallen8 fallen8 = null; // TODO: Initialize to an appropriate value var target = new ServiceFactory(fallen8); // TODO: Initialize to an appropriate value IPAddress iPAddress = null; // TODO: Initialize to an appropriate value ushort port = 0; // TODO: Initialize to an appropriate value target.StartGraphService(iPAddress, port); }
public void RecycleFallen8UnitTest() { Assert.Inconclusive("TODO"); uint minValue = 0; // TODO: Initialize to an appropriate value uint maxValue = 0; // TODO: Initialize to an appropriate value var target = new Fallen8Pool(minValue, maxValue); // TODO: Initialize to an appropriate value Fallen8 instance = null; // TODO: Initialize to an appropriate value target.RecycleFallen8(instance); }
/// <summary> /// Initializes a new instance of the AdminService class. /// </summary> /// <param name='fallen8'> Fallen-8. </param> public AdminService(Fallen8 fallen8) { _fallen8 = fallen8; _saveFile = "Temp.f8s"; string currentAssemblyDirectoryName = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); _savePath = currentAssemblyDirectoryName + System.IO.Path.DirectorySeparatorChar + _saveFile; _optimalNumberOfPartitions = Convert.ToUInt32(Environment.ProcessorCount * 3 / 2); }
public void StatusUnitTest() { Assert.Inconclusive("TODO"); Fallen8 fallen8 = null; // TODO: Initialize to an appropriate value var target = new AdminService(fallen8); // TODO: Initialize to an appropriate value StatusREST expected = null; // TODO: Initialize to an appropriate value StatusREST actual; actual = target.Status(); Assert.AreEqual(expected, actual); }
public void GetAvailableServicePluginsIntegrationTest() { Assert.Inconclusive("TODO."); Fallen8 fallen8 = null; // TODO: Initialize to an appropriate value var target = new ServiceFactory(fallen8); // TODO: Initialize to an appropriate value IEnumerable <string> expected = null; // TODO: Initialize to an appropriate value IEnumerable <string> actual; actual = target.GetAvailableServicePlugins(); Assert.AreEqual(expected, actual); }
public void VertexCountUnitTest() { Assert.Inconclusive("TODO"); Fallen8 fallen8 = null; // TODO: Initialize to an appropriate value var target = new AdminService(fallen8); // TODO: Initialize to an appropriate value uint expected = 0; // TODO: Initialize to an appropriate value uint actual; actual = target.VertexCount(); Assert.AreEqual(expected, actual); }
public void FreeMemUnitTest() { Assert.Inconclusive("TODO"); Fallen8 fallen8 = null; // TODO: Initialize to an appropriate value var target = new AdminService(fallen8); // TODO: Initialize to an appropriate value ulong expected = 0; // TODO: Initialize to an appropriate value ulong actual; actual = target.FreeMem(); Assert.AreEqual(expected, actual); }
public void AddEdgeUnitTest() { Assert.Inconclusive("TODO"); Fallen8 fallen8 = null; // TODO: Initialize to an appropriate value var target = new GraphService(fallen8); // TODO: Initialize to an appropriate value EdgeSpecification definition = null; // TODO: Initialize to an appropriate value int expected = 0; // TODO: Initialize to an appropriate value int actual; actual = target.AddEdge(definition); Assert.AreEqual(expected, actual); }
public void TryRemoveGraphElementUnitTest() { Assert.Inconclusive("TODO"); Fallen8 fallen8 = null; // TODO: Initialize to an appropriate value var target = new GraphService(fallen8); // TODO: Initialize to an appropriate value string graphElementIdString = string.Empty; // TODO: Initialize to an appropriate value bool expected = false; // TODO: Initialize to an appropriate value bool actual; actual = target.TryRemoveGraphElement(graphElementIdString); Assert.AreEqual(expected, actual); }
public void SpatialIndexScanSearchDistanceUnitTest() { Assert.Inconclusive("TODO"); Fallen8 fallen8 = null; // TODO: Initialize to an appropriate value var target = new GraphService(fallen8); // TODO: Initialize to an appropriate value SearchDistanceSpecification definition = null; // TODO: Initialize to an appropriate value IEnumerable <int> expected = null; // TODO: Initialize to an appropriate value IEnumerable <int> actual; actual = target.SpatialIndexScanSearchDistance(definition); Assert.AreEqual(expected, actual); }
public void RemoveKeyFromIndexUnitTest() { Assert.Inconclusive("TODO"); Fallen8 fallen8 = null; // TODO: Initialize to an appropriate value var target = new GraphService(fallen8); // TODO: Initialize to an appropriate value IndexRemoveKeyFromIndexSpecification definition = null; // TODO: Initialize to an appropriate value bool expected = false; // TODO: Initialize to an appropriate value bool actual; actual = target.RemoveKeyFromIndex(definition); Assert.AreEqual(expected, actual); }
public void DeleteServiceUnitTest() { Assert.Inconclusive("TODO"); Fallen8 fallen8 = null; // TODO: Initialize to an appropriate value var target = new AdminService(fallen8); // TODO: Initialize to an appropriate value ServiceDeleteSpecificaton definition = null; // TODO: Initialize to an appropriate value bool expected = false; // TODO: Initialize to an appropriate value bool actual; actual = target.DeleteService(definition); Assert.AreEqual(expected, actual); }
public void GetAllGraphelementPropertiesUnitTest() { Assert.Inconclusive("TODO"); Fallen8 fallen8 = null; // TODO: Initialize to an appropriate value var target = new GraphService(fallen8); // TODO: Initialize to an appropriate value string graphElementIdentifier = string.Empty; // TODO: Initialize to an appropriate value PropertiesREST expected = null; // TODO: Initialize to an appropriate value PropertiesREST actual; actual = target.GetAllGraphelementProperties(graphElementIdentifier); Assert.AreEqual(expected, actual); }
public void GetTargetVertexForEdgeUnitTest() { Assert.Inconclusive("TODO"); Fallen8 fallen8 = null; // TODO: Initialize to an appropriate value var target = new GraphService(fallen8); // TODO: Initialize to an appropriate value string edgeIdentifier = string.Empty; // TODO: Initialize to an appropriate value int expected = 0; // TODO: Initialize to an appropriate value int actual; actual = target.GetTargetVertexForEdge(edgeIdentifier); Assert.AreEqual(expected, actual); }
public void Persistence_RandomGraph_UnitTest() { var saveGamePath = System.IO.Path.Combine(Environment.CurrentDirectory, "randomGraph.fs8"); TestHelper.ExecuteTestWithPersistence( () => TestHelper.CreateRandomGraph(100000, 20), element => { Assert.IsTrue(element != null); Assert.IsTrue(element.EdgeCount > 0); Assert.IsTrue(element.VertexCount > 0); }, element => element.Save(saveGamePath), () => { var reloadedF8 = new Fallen8(); reloadedF8.Load(saveGamePath); return reloadedF8; }, (reference, reloaded) => Assert.IsTrue(TestHelper.CheckIfFallen8IsEqual(reference, reloaded)), saveGamePath); }
/// <summary> /// Starts the actual service /// </summary> /// <param name="fallen8"> Fallen-8. </param> private void StartService(Fallen8 fallen8) { #region configuration var configs = new Dictionary<String, String>(); foreach (String key in ConfigurationManager.AppSettings) { var value = ConfigurationManager.AppSettings[key]; configs.Add(key, value); } String adminIpAddress; configs.TryGetValue("AdminIPAddress", out adminIpAddress); UInt16 adminPort = 2323; String adminPortString; if(configs.TryGetValue("AdminPort", out adminPortString)) { adminPort = Convert.ToUInt16(adminPortString); } String adminUriPattern; configs.TryGetValue("AdminUriPattern", out adminUriPattern); String restServiceAddress; configs.TryGetValue("RESTServicePattern", out restServiceAddress); #endregion var address = String.IsNullOrWhiteSpace(adminIpAddress) ? IPAddress.Any.ToString() : adminIpAddress; var port = adminPort; var uriPattern = String.IsNullOrWhiteSpace(adminUriPattern) ? "Admin" : adminUriPattern; _uri = new Uri("http://" + address + ":" + port + "/" + uriPattern); if (!_uri.IsWellFormedOriginalString()) throw new Exception("The URI pattern is not well formed!"); Service = new AdminService(fallen8); _host = new ServiceHost(Service, _uri) { CloseTimeout = new TimeSpan(0, 0, 0, 0, 50) }; _restServiceAddress = String.IsNullOrWhiteSpace(restServiceAddress) ? "REST" : restServiceAddress; try { var binding = new WebHttpBinding { MaxBufferSize = 268435456, MaxReceivedMessageSize = 268435456, SendTimeout = new TimeSpan(1, 0, 0), ReceiveTimeout = new TimeSpan(1, 0, 0) }; var readerQuotas = new XmlDictionaryReaderQuotas { MaxDepth = 2147483647, MaxStringContentLength = 2147483647, MaxBytesPerRead = 2147483647, MaxNameTableCharCount = 2147483647, MaxArrayLength = 2147483647 }; binding.ReaderQuotas = readerQuotas; var se = _host.AddServiceEndpoint(typeof (IAdminService), binding, _restServiceAddress); var webBehav = new WebHttpBehavior { HelpEnabled = true }; se.Behaviors.Add(webBehav); ((ServiceBehaviorAttribute) _host.Description.Behaviors[typeof (ServiceBehaviorAttribute)]). InstanceContextMode = InstanceContextMode.Single; } catch (Exception) { _host.Abort(); throw; } }
public void Initialize(Fallen8 fallen8, IDictionary<string, object> parameter) { _fallen8 = fallen8; }
public void Initialize(Fallen8 fallen8, IDictionary<string, object> parameter) { _uriPattern = "Graph"; if (parameter != null && parameter.ContainsKey("URIPattern")) _uriPattern = (String)Convert.ChangeType(parameter["URIPattern"], typeof(String)); _address = IPAddress.Any; if (parameter != null && parameter.ContainsKey("IPAddress")) _address = (IPAddress)Convert.ChangeType(parameter["IPAddress"], typeof(IPAddress)); _port = 2357; if (parameter != null && parameter.ContainsKey("Port")) _port = (ushort)Convert.ChangeType(parameter["Port"], typeof(ushort)); StartService(fallen8); }
/// <summary> /// Starts the actual service /// </summary> /// <param name="fallen8"> Fallen-8. </param> private void StartService(Fallen8 fallen8) { _uri = new Uri("http://" + _address + ":" + _port + "/" + _uriPattern); if (!_uri.IsWellFormedOriginalString()) throw new Exception("The URI Pattern is not well formed!"); Service = new GraphService(fallen8); _host = new ServiceHost(Service, _uri) { CloseTimeout = new TimeSpan(0, 0, 0, 0, 50) }; _restServiceAddress = "REST"; try { var binding = new WebHttpBinding { MaxBufferSize = 268435456, MaxReceivedMessageSize = 268435456, SendTimeout = new TimeSpan(1, 0, 0), ReceiveTimeout = new TimeSpan(1, 0, 0) }; var readerQuotas = new XmlDictionaryReaderQuotas { MaxDepth = 2147483647, MaxStringContentLength = 2147483647, MaxBytesPerRead = 2147483647, MaxNameTableCharCount = 2147483647, MaxArrayLength = 2147483647 }; binding.ReaderQuotas = readerQuotas; var se = _host.AddServiceEndpoint(typeof (IGraphService), binding, _restServiceAddress); var webBehav = new WebHttpBehavior { HelpEnabled = true }; se.Behaviors.Add(webBehav); ((ServiceBehaviorAttribute) _host.Description.Behaviors[typeof (ServiceBehaviorAttribute)]). InstanceContextMode = InstanceContextMode.Single; } catch (Exception) { _host.Abort(); throw; } }
public override IRESTService LoadServiceFromSerialization(SerializationReader reader, Fallen8 fallen8) { return new AdminService(fallen8); }
private static void LoadIndices(Fallen8 fallen8, IndexFactory indexFactory, List<String> indexStreams) { //load the indices for (var i = 0; i < indexStreams.Count; i++) { LoadAnIndex(indexStreams[i], fallen8, indexFactory); } }
public void Initialize(Fallen8 fallen8, IDictionary<string, object> parameter) { _idx = new Dictionary<IComparable, List<AGraphElement>>(); }
public void Initialize(Fallen8 fallen8, IDictionary<string, object> parameter) { InitializeParams (fallen8, parameter); _service = CreateService (fallen8, parameter); StartService (); }
/// <summary> /// Tries to get a pooled Fallen-8 instance. /// </summary> /// <returns> True for success. </returns> /// <param name='result'> The resulting Fallen-8. </param> public bool TryGetFallen8(out Fallen8 result) { if (_instances.TryDequeue(out result)) { if (_instances.Count < _minValue) { FillQueue(); } return true; } result = null; return false; }
public void Load(SerializationReader reader, Fallen8 fallen8) { }
/// <summary> /// Opens and deserializes an index /// </summary> /// <param name="indexName"> The index name </param> /// <param name="indexPluginName"> The index plugin name </param> /// <param name="reader"> Serialization reader </param> /// <param name="fallen8"> Fallen-8 </param> internal void OpenIndex(string indexName, string indexPluginName, SerializationReader reader, Fallen8 fallen8) { IIndex index; if (PluginFactory.TryFindPlugin(out index, indexPluginName)) { index.Load(reader, fallen8); if (WriteResource()) { try { Indices.Add(indexName, index); return; } finally { FinishWriteResource(); } } throw new CollisionException(); } Logger.LogError(String.Format("Could not find index plugin with name \"{0}\".", indexPluginName)); }
/// <summary> /// Creates a new service factory /// </summary> /// <param name="fallen8">Fallen-8</param> public ServiceFactory(Fallen8 fallen8) { _fallen8 = fallen8; Services = new Dictionary<string, IService>(); }
private static void LoadServices(Fallen8 fallen8, ServiceFactory newServiceFactory, List<string> serviceStreams, Boolean startServices) { //load the indices for (var i = 0; i < serviceStreams.Count; i++) { LoadAService(serviceStreams[i], fallen8, newServiceFactory, startServices); } }
public abstract IRESTService CreateService(Fallen8 fallen8, IDictionary<string, object> parameter);
/// <summary> /// Load Fallen-8 from a save point /// </summary> /// <param name="fallen8">Fallen-8</param> /// <param name="graphElements">The graph elements </param> /// <param name="pathToSavePoint">The path to the save point.</param> /// <param name="currentId">The maximum graph element id</param> /// <param name="startServices">Start the services</param> internal static Boolean Load(Fallen8 fallen8, ref BigList<AGraphElement> graphElements, string pathToSavePoint, ref Int32 currentId, Boolean startServices) { //if there is no savepoint file... do nothing if (!File.Exists(pathToSavePoint)) { Logger.LogError(String.Format("Fallen-8 could not be loaded because the path \"{0}\" does not exist.", pathToSavePoint)); return false; } var pathName = Path.GetDirectoryName(pathToSavePoint); var fileName = Path.GetFileName(pathToSavePoint); Logger.LogInfo(String.Format("Now loading file \"{0}\" from path \"{1}\"", fileName, pathName)); using (var file = File.Open(pathToSavePoint, FileMode.Open, FileAccess.Read)) { var reader = new SerializationReader(file); currentId = reader.ReadInt32(); graphElements.InitializeUntil(currentId); #region graph elements //initialize the list of graph elements var graphElementStreams = new List<String>(); var numberOfGraphElemementStreams = reader.ReadInt32(); for (var i = 0; i < numberOfGraphElemementStreams; i++) { var graphElementBunchFilename = Path.Combine(pathName, reader.ReadString()); Logger.LogInfo(String.Format("Found graph element bunch {0} here: \"{1}\"", i, graphElementBunchFilename)); graphElementStreams.Add(graphElementBunchFilename); } LoadGraphElements(graphElements, graphElementStreams); #endregion #region indexe var indexStreams = new List<String>(); var numberOfIndexStreams = reader.ReadInt32(); for (var i = 0; i < numberOfIndexStreams; i++) { var indexFilename = Path.Combine(pathName, reader.ReadString()); Logger.LogInfo(String.Format("Found index number {0} here: \"{1}\"", i, indexFilename)); indexStreams.Add(indexFilename); } var newIndexFactory = new IndexFactory(); LoadIndices(fallen8, newIndexFactory, indexStreams); fallen8.IndexFactory = newIndexFactory; #endregion #region services var serviceStreams = new List<String>(); var numberOfServiceStreams = reader.ReadInt32(); for (var i = 0; i < numberOfServiceStreams; i++) { var serviceFilename = Path.Combine(pathName, reader.ReadString()); Logger.LogInfo(String.Format("Found service number {0} here: \"{1}\"", i, serviceFilename)); serviceStreams.Add(serviceFilename); } var newServiceFactory = new ServiceFactory(fallen8); fallen8.ServiceFactory = newServiceFactory; LoadServices(fallen8, newServiceFactory, serviceStreams, startServices); #endregion return true; } }
/// <summary> /// Initializes a new instance of the GraphService class. /// </summary> /// <param name='fallen8'> Fallen-8. </param> public GraphService(Fallen8 fallen8) { _fallen8 = fallen8; _compilerParameters = new CompilerParameters { GenerateExecutable = false, GenerateInMemory = true, TreatWarningsAsErrors = false, IncludeDebugInformation = false, CompilerOptions = "/optimize /target:library", }; var curAss = Assembly.GetAssembly (fallen8.GetType ()); _compilerParameters.ReferencedAssemblies.Add ("System.dll"); _compilerParameters.ReferencedAssemblies.Add ("mscorlib.dll"); _compilerParameters.ReferencedAssemblies.Add ("System.dll"); _compilerParameters.ReferencedAssemblies.Add ("System.Data.dll"); _compilerParameters.ReferencedAssemblies.Add (curAss.Location); _codeProvider = new CSharpCodeProvider (new Dictionary<string, string> { { "CompilerVersion", "v4.5" } }); }
/// <summary> /// Opens a serialized service /// </summary> /// <param name="serviceName">Service name</param> /// <param name="servicePluginName">Service plugin name</param> /// <param name="reader">Serialization reader</param> /// <param name="fallen8">Fallen-8</param> /// <param name="startService">Start the service?</param> internal void OpenService(string serviceName, string servicePluginName, SerializationReader reader, Fallen8 fallen8, Boolean startService) { IService service; if (PluginFactory.TryFindPlugin(out service, servicePluginName)) { if (WriteResource()) { try { if (Services.ContainsKey(serviceName)) { Logger.LogError(String.Format("A service with the same name \"{0}\" already exists.", serviceName)); } service.Load(reader, fallen8); if (service.TryStart()) { Services.Add(serviceName, service); } } finally { FinishWriteResource(); } return; } throw new CollisionException(this); } Logger.LogError(String.Format("Could not find service plugin with name \"{0}\".", servicePluginName)); }
public void Load(SerializationReader reader, Fallen8 fallen8) { StartService(fallen8); }
/// <summary> /// Save the specified graphElements, indices and pathToSavePoint. /// </summary> /// <param name='fallen8'> Fallen-8. </param> /// <param name='graphElements'> Graph elements. </param> /// <param name='path'> Path. </param> /// <param name='savePartitions'> The number of save partitions for the graph elements. </param> /// <param name="currentId">The current graph elemement identifier.</param> internal static void Save(Fallen8 fallen8, BigList<AGraphElement> graphElements, String path, UInt32 savePartitions, Int32 currentId) { // Create the new, empty data file. if (File.Exists(path)) { //the newer save gets an timestamp path = path + Constants.VersionSeparator + DateTime.Now.ToBinary().ToString(CultureInfo.InvariantCulture); } using (var file = File.Create(path, Constants.BufferSize, FileOptions.SequentialScan)) { var writer = new SerializationWriter(file, true); writer.Write(currentId); //create some futures to save as much as possible in parallel const TaskCreationOptions options = TaskCreationOptions.LongRunning; var f = new TaskFactory(CancellationToken.None, options, TaskContinuationOptions.None, TaskScheduler.Default); #region graph elements var graphElementCount = Convert.ToUInt32(currentId); Task<string>[] graphElementSaver; if (graphElementCount > 0) { graphElementCount++; //Hack var graphElementPartitions = CreatePartitions(graphElementCount, savePartitions); graphElementSaver = new Task<string>[graphElementPartitions.Count]; for (var i = 0; i < graphElementPartitions.Count; i++) { var partition = graphElementPartitions[i]; graphElementSaver[i] = f.StartNew(() => SaveBunch(partition, graphElements, path)); } } else { graphElementSaver = new Task<string>[0]; } #endregion #region indices var indexSaver = new Task<string>[fallen8.IndexFactory.Indices.Count]; var counter = 0; foreach (var aIndex in fallen8.IndexFactory.Indices) { var indexName = aIndex.Key; var index = aIndex.Value; indexSaver[counter] = f.StartNew(() => SaveIndex(indexName, index, path)); counter++; } #endregion #region services var serviceSaver = new Task<string>[fallen8.ServiceFactory.Services.Count]; counter = 0; foreach (var aService in fallen8.ServiceFactory.Services) { var serviceName = aService.Key; var service = aService.Value; serviceSaver[counter] = f.StartNew(() => SaveService(serviceName, service, path)); counter++; } #endregion writer.Write(graphElementSaver.Length); foreach (var aFileStreamName in graphElementSaver) { writer.Write(aFileStreamName.Result); } writer.Write(indexSaver.Length); foreach (var aIndexFileName in indexSaver) { writer.Write(aIndexFileName.Result); } writer.Write(serviceSaver.Length); foreach (var aServiceFileName in serviceSaver) { writer.Write(aServiceFileName.Result); } writer.UpdateHeader(); writer.Flush(); file.Flush(); } }
public void Initialize(Fallen8 fallen8, IDictionary<string, object> parameter) { StartService(fallen8); }
private static void LoadAnIndex(string indexLocaion, Fallen8 fallen8, IndexFactory indexFactory) { //if there is no savepoint file... do nothing if (!File.Exists(indexLocaion)) { return; } using (var file = File.Open(indexLocaion, FileMode.Open, FileAccess.Read)) { var reader = new SerializationReader(file); var indexName = reader.ReadString(); var indexPluginName = reader.ReadString(); indexFactory.OpenIndex(indexName, indexPluginName, reader, fallen8); } }
public void Load(SerializationReader reader, Fallen8 fallen8) { _uriPattern = reader.ReadString (); _address = IPAddress.Parse (reader.ReadString ()); _port = reader.ReadUInt16 (); _service = LoadServiceFromSerialization (reader, fallen8); _service.Load (reader, fallen8); StartService (); }
private static void LoadAService(string serviceLocaion, Fallen8 fallen8, ServiceFactory serviceFactory, Boolean startService) { //if there is no savepoint file... do nothing if (!File.Exists(serviceLocaion)) { return; } using (var file = File.Open(serviceLocaion, FileMode.Open, FileAccess.Read)) { var reader = new SerializationReader(file); var indexName = reader.ReadString(); var indexPluginName = reader.ReadString(); serviceFactory.OpenService(indexName, indexPluginName, reader, fallen8, startService); } }
public void Load(SerializationReader reader, Fallen8 fallen8) { if (WriteResource()) { try { reader.ReadInt32();//parameter var keyCount = reader.ReadInt32(); _idx = new Dictionary<IComparable, List<AGraphElement>>(keyCount); for (var i = 0; i < keyCount; i++) { var key = reader.ReadObject(); var value = new List<AGraphElement>(); var valueCount = reader.ReadInt32(); for (var j = 0; j < valueCount; j++) { var graphElementId = reader.ReadInt32(); AGraphElement graphElement; if (fallen8.TryGetGraphElement(out graphElement, graphElementId)) { value.Add(graphElement); } else { Logger.LogError(String.Format("[DictionaryIndex] Error while deserializing the index. Could not find the graph element \"{0}\"", graphElementId)); } } _idx.Add((IComparable)key, value); } } finally { FinishWriteResource(); } return; } throw new CollisionException(this); }
public abstract IRESTService LoadServiceFromSerialization(SerializationReader reader, Fallen8 fallen8);
public override IRESTService CreateService(Fallen8 fallen8, IDictionary<string, object> parameter) { return new AdminService(fallen8); }
public void Load(SerializationReader reader, Fallen8 fallen8) { throw new NotImplementedException(); }