Beispiel #1
0
        public void SparqlRemoteEndpointMemoryLeak2()
        {
            //Do a GC before attempting the test
            GC.GetTotalMemory(true);

            //First off make sure to load some data into the some
            SparqlRemoteUpdateEndpoint updateEndpoint = RemoteEndpoints.GetUpdateEndpoint();

            updateEndpoint.Update("DROP ALL");

            int totalRuns  = 10000;
            int subjects   = 1000;
            int predicates = 10;

            //Loop over making queries to try and reproduce the memory leak
            for (int i = 1; i <= totalRuns; i++)
            {
                //Add new data each time around
                updateEndpoint.Update("INSERT DATA { <http://subject/" + (i % subjects) + "> <http://predicate/" + (i % predicates) + "> <http://object/" + i + "> . }");

                SparqlRemoteEndpoint      endpoint    = RemoteEndpoints.GetQueryEndpoint();
                SparqlParameterizedString queryString = new SparqlParameterizedString();
                queryString.CommandText = "SELECT * WHERE { <http://subject/" + (i % 1000) + "> ?p ?o }";

                ResultCountHandler handler = new ResultCountHandler();
                endpoint.QueryWithResultSet(handler, queryString.ToString());
                Assert.True(handler.Count >= 1 && handler.Count <= subjects, "Result Count " + handler.Count + " is not in expected range 1 <= x < " + (i % 1000));

                if (i % 500 == 0)
                {
                    Debug.WriteLine("Memory Usage after " + i + " Iterations: " + Process.GetCurrentProcess().PrivateMemorySize64);
                }
            }
            Debug.WriteLine("Memory Usage after " + totalRuns + " Iterations: " + Process.GetCurrentProcess().PrivateMemorySize64);
        }
        public void SparqlRemoteEndpointAsyncApiUpdate()
        {
            if (!TestConfigManager.GetSettingAsBoolean(TestConfigManager.UseRemoteParsing))
            {
                throw new SkipTestException("Test Config marks Remote Parsing as unavailable, test cannot be run");
            }

            SparqlRemoteUpdateEndpoint endpoint = RemoteEndpoints.GetUpdateEndpoint();
            ManualResetEvent           signal   = new ManualResetEvent(false);

            endpoint.Update("LOAD <http://dbpedia.org/resource/Ilkeston> INTO GRAPH <http://example.org/async/graph>", s =>
            {
                signal.Set();
                signal.Close();
            }, null);

            Thread.Sleep(AsyncTimeout);
            Assert.True(signal.SafeWaitHandle.IsClosed, "Wait Handle should be closed");

            //Check that the Graph was really loaded
            SparqlRemoteEndpoint queryEndpoint = RemoteEndpoints.GetQueryEndpoint();
            IGraph g = queryEndpoint.QueryWithResultGraph("CONSTRUCT FROM <http://example.org/async/graph> WHERE { ?s ?p ?o }");

            Assert.False(g.IsEmpty, "Graph should not be empty");
        }
Beispiel #3
0
        public void UpdateTripleStore(SparqlParameterizedString updateString)
        {
            if (updateString == null)
            {
                return;
            }

            if (_transaction != null)
            {
                _transaction.AddUpdateString(updateString);
            }
            else
            {
                updateString.AddAllColidNamespaces();
                _updateEndpoint.Update(updateString.ToString());
            }
        }
Beispiel #4
0
        /// <summary>
        /// Makes a SPARQL Update against the store.
        /// </summary>
        /// <param name="sparqlUpdate">SPARQL Update.</param>
        public void Update(string sparqlUpdate)
        {
            if (!_skipLocalParsing)
            {
                // Parse the update locally to validate it
                // This also saves us wasting a HttpWebRequest on a malformed update
                SparqlUpdateParser uparser = new SparqlUpdateParser();
                uparser.ParseFromString(sparqlUpdate);

                _updateEndpoint.Update(sparqlUpdate);
            }
            else
            {
                // If we're skipping local parsing then we'll need to just make a raw update
                _updateEndpoint.Update(sparqlUpdate);
            }
        }
        public void SparqlRemoteEndpointAsyncApiUpdate()
        {
            SparqlRemoteUpdateEndpoint endpoint = GetUpdateEndpoint();
            ManualResetEvent           signal   = new ManualResetEvent(false);

            endpoint.Update("LOAD <http://dbpedia.org/resource/Ilkeston> INTO GRAPH <http://example.org/async/graph>", s =>
            {
                signal.Set();
                signal.Close();
            }, null);

            signal.WaitOne(TimeSpan.FromSeconds(10.0)).Should().BeTrue();
        }
        public void SparqlRemoteEndpointAsyncApiUpdate()
        {
            SparqlRemoteUpdateEndpoint endpoint = GetUpdateEndpoint();
            ManualResetEvent           signal   = new ManualResetEvent(false);

            endpoint.Update("LOAD <http://dbpedia.org/resource/Ilkeston> INTO GRAPH <http://example.org/async/graph>", s =>
            {
                signal.Set();
                signal.Close();
            }, null);

            Thread.Sleep(1000);
            Assert.True(signal.SafeWaitHandle.IsClosed, "Wait Handle should be closed");
        }
Beispiel #7
0
        public void SparqlRemoteEndpointMemoryLeak1()
        {
            /*
             * Dim endpoint = New SparqlRemoteEndpoint(New Uri("http://localhost:8080/sesame/repositories/my_repo"))
             * Dim queryString As SparqlParameterizedString = New SparqlParameterizedString()
             * queryString.Namespaces.AddNamespace("annot", New Uri(oAppSettingsReader.GetValue("BaseUriSite", GetType(System.String)) & "/annotations.owl#"))
             * queryString.CommandText = "SELECT DISTINCT ?text WHERE {?annotation annot:onContent <" & _uriDocument & "> ; annot:onContentPart """ & ContentPart & """ ; annot:text ?text ; annot:isValid ""false""^^xsd:boolean . }"
             * Dim results As SparqlResultSet = endpoint.QueryWithResultSet(queryString.ToString)
             * For Each result As SparqlResult In results
             * Console.WriteLine(DirectCast(result.Value("text"), LiteralNode).Value)
             * Next
             * results.Dispose()
             */

            //Do a GC before attempting the test
            GC.GetTotalMemory(true);

            //First off make sure to load some data into the some
            SparqlRemoteUpdateEndpoint updateEndpoint = RemoteEndpoints.GetUpdateEndpoint();

            updateEndpoint.Update("DROP ALL; INSERT DATA { <http://subject> <http://predicate> <http://object> . }");

            int totalRuns = 10000;

            //Loop over making queries to try and reproduce the memory leak
            for (int i = 1; i <= totalRuns; i++)
            {
                SparqlRemoteEndpoint      endpoint    = RemoteEndpoints.GetQueryEndpoint();
                SparqlParameterizedString queryString = new SparqlParameterizedString();
                queryString.CommandText = "SELECT * WHERE { ?s ?p ?o }";

                SparqlResultSet results = endpoint.QueryWithResultSet(queryString.ToString());
                Assert.Equal(1, results.Count);
                foreach (SparqlResult result in results)
                {
                    //We're just iterating to make sure we touch the whole of the results
                }
                results.Dispose();

                if (i % 500 == 0)
                {
                    Debug.WriteLine("Memory Usage after " + i + " Iterations: " + Process.GetCurrentProcess().PrivateMemorySize64);
                }
            }
            Debug.WriteLine("Memory Usage after " + totalRuns + " Iterations: " + Process.GetCurrentProcess().PrivateMemorySize64);
        }
        public void SparqlRemoteEndpointLongUpdate()
        {
            try
            {
                Options.HttpDebugging = true;

                StringBuilder input = new StringBuilder();
                input.AppendLine("LOAD <http://dbpedia.org/resource/Ilkeston>");
                input.AppendLine(new String('#', 2048));

                SparqlRemoteUpdateEndpoint endpoint = RemoteEndpoints.GetUpdateEndpoint();
                endpoint.Update(input.ToString());
            }
            finally
            {
                Options.HttpDebugging = false;
            }
        }
        public void SparqlRemoteEndpointAsyncApiUpdate()
        {
            SparqlRemoteUpdateEndpoint endpoint = RemoteEndpoints.GetUpdateEndpoint();
            ManualResetEvent           signal   = new ManualResetEvent(false);

            endpoint.Update("LOAD <http://dbpedia.org/resource/Ilkeston> INTO GRAPH <http://example.org/async/graph>", s =>
            {
                signal.Set();
                signal.Close();
            }, null);

            Thread.Sleep(AsyncTimeout);
            Assert.IsTrue(signal.SafeWaitHandle.IsClosed, "Wait Handle should be closed");

            //Check that the Graph was really loaded
            SparqlRemoteEndpoint queryEndpoint = RemoteEndpoints.GetQueryEndpoint();
            IGraph g = queryEndpoint.QueryWithResultGraph("CONSTRUCT FROM <http://example.org/async/graph> WHERE { ?s ?p ?o }");

            Assert.IsFalse(g.IsEmpty, "Graph should not be empty");
        }
Beispiel #10
0
        public void SparqlRemoteEndpointLongUpdate()
        {
            Skip.IfNot(TestConfigManager.GetSettingAsBoolean(TestConfigManager.UseRemoteParsing),
                       "Test Config marks Remote Parsing as unavailable, test cannot be run");

            try
            {
                Options.HttpDebugging = true;

                StringBuilder input = new StringBuilder();
                input.AppendLine("LOAD <http://dbpedia.org/resource/Ilkeston>");
                input.AppendLine(new String('#', 2048));

                SparqlRemoteUpdateEndpoint endpoint = RemoteEndpoints.GetUpdateEndpoint();
                endpoint.Update(input.ToString());
            }
            finally
            {
                Options.HttpDebugging = false;
            }
        }
Beispiel #11
0
        static void Main(string[] args)
        {
            queue = new Queue <string>();
            count = 0;
            //Then create our Endpoint instance
            endpoint = new SparqlRemoteUpdateEndpoint(ONT_SENSE_URL);

            TcpListener ServerSocket = new TcpListener(PORT);

            ServerSocket.Start();
            Console.WriteLine("OntSense API started on Port " + PORT + ", with " + ONT_SENSE_URL + " Server...");
            TcpClient    clientSocket = ServerSocket.AcceptTcpClient();
            handleClient client       = new handleClient();

            client.startClient(clientSocket);
            while (true)
            {
                string auxString = "";

                lock (queue)
                {
                    if (queue.Count > 0)
                    {
                        auxString = queue.Dequeue();
                    }
                    else
                    {
                        Thread.Yield();
                    }
                }
                if (!auxString.Equals(""))
                {
                    endpoint.Update(auxString);
                }
            }
        }
 /// <summary>
 /// Applies a SPARQL Update against 4store
 /// </summary>
 /// <param name="sparqlUpdate">SPARQL Update</param>
 /// <remarks>
 /// <strong>Note:</strong> Please be aware that some valid SPARQL Updates may not be accepted by 4store since the SPARQL parser used by 4store does not support some of the latest editors draft syntax changes.
 /// </remarks>
 public void Update(String sparqlUpdate)
 {
     _updateEndpoint.Update(sparqlUpdate);
 }
Beispiel #13
0
        /// executes a Sparql command receive as parameter.

        public void executeSparqlUpdate(string updateCmd)
        {
            //And finally send the update request
            endpoint.Update(updateCmd);
        }