Package com.hp.hpl.jena.shared

Examples of com.hp.hpl.jena.shared.Lock


   
        @Override
        public Object call()
        {
            DatasetGraph dsg = null ;
            Lock lock = null ;
            try
            {
                dsg = tts.getDatasetGraph() ;
                lock = dsg.getLock() ;
                int id = gen.incrementAndGet() ;
                for (int i = 0; i < repeats; i++)
                {
                    try {
                        lock.enterCriticalSection(Lock.READ) ;
                        log.debug("reader start " + id + "/" + i) ;

                        int x1 = count("SELECT * { ?s ?p ?o }", dsg) ;
                        pause(maxpause) ;
                        int x2 = count("SELECT * { ?s ?p ?o }", dsg) ;
                        if (x1 != x2) log.warn(format("READER: %s Change seen: %d/%d : id=%d: i=%d",
                                                      "read-" + i, x1, x2, id, i)) ;
                        log.debug("reader finish " + id + "/" + i) ;
                    } catch (RuntimeException ex)
                    {
                        log.debug("reader error " + id + "/" + i) ;
                        ex.printStackTrace() ;
                    } finally {
                        lock.leaveCriticalSection() ;                       
                    }
                }
                return null ;
            } catch (RuntimeException ex)
            {
View Full Code Here


       
        @Override
        public Object call()
        {
            DatasetGraph dsg = null ;
            Lock lock = null ;
            try {
                dsg = tts.getDatasetGraph() ;
                lock = dsg.getLock() ;
                int id = gen.incrementAndGet() ;
                for ( int i = 0 ; i < repeats ; i++ )
                {
                    try {
                        lock.enterCriticalSection(Lock.WRITE) ;
                        log.debug("writer start "+id+"/"+i) ;               

                        int x1 = count("SELECT * { ?s ?p ?o }", dsg) ;
                        int z = change(dsg, id, i) ;
                        pause(maxpause) ;
                        int x2 = count("SELECT * { ?s ?p ?o }", dsg) ;
                        if ( x1+z != x2 )
                        {
                            log.warn(format("WRITER: %s Change seen: %d + %d != %d : id=%d: i=%d", "write-" + i, x1, z, x2, id, i)) ;
                            return null ;
                        }
                        log.debug("writer finish "+id+"/"+i) ;               
                    } catch (RuntimeException ex)
                    {
                        log.debug("writer error "+id+"/"+i) ;        
                        System.err.println(ex.getMessage()) ;
                        ex.printStackTrace() ;
                    } finally {
                        lock.leaveCriticalSection() ;                       
                    }
                }
                return null ;
            }
            catch (RuntimeException ex)
View Full Code Here

   
        @Override
        public Object call()
        {
            DatasetGraph dsg = null ;
            Lock lock = null ;
            try
            {
                dsg = tts.getDatasetGraph() ;
                lock = dsg.getLock() ;
                int id = gen.incrementAndGet() ;
                for (int i = 0; i < repeats; i++)
                {
                    try {
                        lock.enterCriticalSection(Lock.READ) ;
                        log.debug("reader start " + id + "/" + i) ;

                        int x1 = count("SELECT * { ?s ?p ?o }", dsg) ;
                        pause(maxpause) ;
                        int x2 = count("SELECT * { ?s ?p ?o }", dsg) ;
                        if (x1 != x2) log.warn(format("READER: %s Change seen: %d/%d : id=%d: i=%d",
                                                      "read-" + i, x1, x2, id, i)) ;
                        log.debug("reader finish " + id + "/" + i) ;
                    } catch (RuntimeException ex)
                    {
                        log.debug("reader error " + id + "/" + i) ;
                        ex.printStackTrace() ;
                    } finally {
                        lock.leaveCriticalSection() ;                       
                    }
                }
                return null ;
            } catch (RuntimeException ex)
            {
View Full Code Here

       
        @Override
        public Object call()
        {
            DatasetGraph dsg = null ;
            Lock lock = null ;
            try {
                dsg = tts.getDatasetGraph() ;
                lock = dsg.getLock() ;
                int id = gen.incrementAndGet() ;
                for ( int i = 0 ; i < repeats ; i++ )
                {
                    try {
                        lock.enterCriticalSection(Lock.WRITE) ;
                        log.debug("writer start "+id+"/"+i) ;               

                        int x1 = count("SELECT * { ?s ?p ?o }", dsg) ;
                        int z = change(dsg, id, i) ;
                        pause(maxpause) ;
                        int x2 = count("SELECT * { ?s ?p ?o }", dsg) ;
                        if ( x1+z != x2 )
                        {
                            log.warn(format("WRITER: %s Change seen: %d + %d != %d : id=%d: i=%d", "write-" + i, x1, z, x2, id, i)) ;
                            return null ;
                        }
                        log.debug("writer finish "+id+"/"+i) ;               
                    } catch (RuntimeException ex)
                    {
                        log.debug("writer error "+id+"/"+i) ;        
                        System.err.println(ex.getMessage()) ;
                        ex.printStackTrace() ;
                    } finally {
                        lock.leaveCriticalSection() ;                       
                    }
                }
                return null ;
            }
            catch (RuntimeException ex)
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.shared.Lock

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.