Just show my how ..
On Monday, March 17, 2014 1:15:36 PM UTC-4, Andrey Lomakin wrote: > > Thank you very much I will look on it tomorrow. > Meanwhile do not you mind to create issue so I will start to work on it ? > > > > On Mon, Mar 17, 2014 at 7:08 PM, Dodong Juan <[email protected]<javascript:> > > wrote: > >> TestNode is define this way >> >> create class TestNode extends V >> >> create property TestNode.uuid String >> >> create index TestNode.index on TestNode(uuid) UNIQUE >> >> >> >> On Monday, March 17, 2014 1:05:21 PM UTC-4, Dodong Juan wrote: >>> >>> A quick code .. >>> >>> >>> >>> >>> import java.util.HashMap; >>> >>> import java.util.concurrent.BlockingQueue; >>> >>> import java.util.concurrent.LinkedBlockingQueue; >>> >>> import java.util.concurrent.ThreadPoolExecutor; >>> >>> import java.util.concurrent.TimeUnit; >>> >>> >>> import com.tinkerpop.blueprints.Vertex; >>> >>> import com.tinkerpop.blueprints.impls.orient.OrientBaseGraph; >>> >>> import com.tinkerpop.blueprints.impls.orient.OrientGraphFactory; >>> >>> import com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx; >>> >>> import com.tinkerpop.blueprints.impls.orient.OrientVertex; >>> >>> >>> public class TestConnection >>> >>> { >>> >>> >>> private static final String url = "remote:localhost/testdb"; >>> >>> private static final String user = "admin"; >>> >>> private static final String pass = "admin"; >>> >>> >>> OrientGraphFactory graphFactory; >>> >>> >>> private static final ThreadLocal<OrientGraphNoTx> graphNoTx = >>> newThreadLocal<OrientGraphNoTx>() >>> ; >>> >>> private int counter = 0; >>> >>> >>> public TestConnection() >>> >>> { >>> >>> graphFactory = new OrientGraphFactory(url, user, pass); >>> >>> } >>> >>> >>> public OrientGraphNoTx getDB() >>> >>> { >>> >>> if (graphNoTx.get() == null) >>> >>> { >>> >>> graphNoTx.set(graphFactory.getNoTx()); >>> >>> } >>> >>> >>> return graphNoTx.get(); >>> >>> } >>> >>> >>> public synchronized String getId() >>> >>> { >>> >>> counter++; >>> >>> return "ID: " + counter; >>> >>> } >>> >>> >>> public Vertex query(OrientBaseGraph graph, String uuid) >>> >>> { >>> >>> Vertex ret = null; >>> >>> >>> Object rec = graph.getRawGraph().getMetadata().getIndexManager( >>> ).getIndex("TestNode.index").get(uuid); >>> >>> >>> if (rec != null) >>> >>> { >>> >>> ret = graph.getVertex(rec); >>> >>> } >>> >>> >>> return ret; >>> >>> } >>> >>> >>> public Vertex saveNode(OrientBaseGraph graph) >>> >>> { >>> >>> String id = this.getId(); >>> >>> >>> Vertex v = query(graph, id); >>> >>> if (v == null) >>> >>> { >>> >>> HashMap<String, Object> prop = new HashMap<String, Object>(); >>> >>> >>> prop.put("uuid", id); >>> >>> prop.put("createTime", System.currentTimeMillis()); >>> >>> prop.put("updateTime", System.currentTimeMillis()); >>> >>> v = graph.addVertex("class:TestNode", prop); >>> >>> >>> } >>> >>> >>> return v; >>> >>> } >>> >>> >>> public static void main(String[] args) >>> >>> { >>> >>> final TestConnection tc = new TestConnection(); >>> >>> BlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<Runnable>(); >>> >>> >>> ThreadPoolExecutor tp = new ThreadPoolExecutor(10, 40, 30, TimeUnit. >>> SECONDS, workQueue); >>> >>> >>> for (int count = 0; count < 1000; count++) >>> >>> { >>> >>> System.out.println("Running : " + count); >>> >>> >>> if (tp.getActiveCount() > 40) >>> >>> { >>> >>> try >>> >>> { >>> >>> Thread.sleep(100); >>> >>> } catch (InterruptedException e) >>> >>> { >>> >>> // TODO Auto-generated catch block >>> >>> e.printStackTrace(); >>> >>> } >>> >>> >>> } >>> >>> >>> Thread t = new Thread() >>> >>> { >>> >>> public void run() >>> >>> { >>> >>> OrientGraphNoTx graph = tc.getDB(); >>> >>> >>> OrientVertex v1 = (OrientVertex) tc.saveNode(graph); >>> >>> OrientVertex v2 = (OrientVertex) tc.saveNode(graph); >>> >>> v1.addEdge(null, v2, "CONNECT"); >>> >>> graph.shutdown(); >>> >>> >>> } >>> >>> >>> }; >>> >>> >>> tp.execute(t); >>> >>> >>> } >>> >>> >>> } >>> >>> >>> } >>> >>> >>> On Monday, March 17, 2014 11:52:10 AM UTC-4, Dodong Juan wrote: >>>> >>>> yes .. 1.7-rc2 .. >>>> I will create a test case .. >>>> >>>> On Monday, March 17, 2014 11:40:39 AM UTC-4, Andrey Lomakin wrote: >>>>> >>>>> I would appreciate if you provide test case. >>>>> You use 1.7-rc2, right ? >>>>> >>>>> >>>>> On Mon, Mar 17, 2014 at 5:34 PM, Dodong Juan <[email protected]>wrote: >>>>> >>>>>> In my case, If I do shutdown on the graph, I get an exception of >>>>>> IllegalStateException: Database is closed. >>>>>> >>>>>> This is >>>>>> >>>>>> >>>>>> On Monday, March 17, 2014 7:24:22 AM UTC-4, Andrey Lomakin wrote: >>>>>> >>>>>>> You should use shutdown as usual to put connection back to the pool. >>>>>>> And call close only during application shutdown. >>>>>>> >>>>>>> >>>>>>> On Mon, Mar 17, 2014 at 1:14 PM, <[email protected]> wrote: >>>>>>> >>>>>>>> Hi, >>>>>>>> >>>>>>>> A have implemented a connection pool based on this: >>>>>>>> http://www.orientechnologies.com/new-orientdb-graph-factory/ >>>>>>>> >>>>>>>> OrientGraphFactory factory = new >>>>>>>> OrientGraphFactory("plocal:/var/www/data/" >>>>>>>> + tenant).setupPool(1, 10); >>>>>>>> ... >>>>>>>> OrientGraph graph = factory.getTx(); >>>>>>>> >>>>>>>> The documentation implies that calling factory.close() to free >>>>>>>> resources, can that that right? >>>>>>>> >>>>>>>> Should I not be able to close/return one graph (graph.close() / >>>>>>>> graph.release()) at a time? >>>>>>>> >>>>>>>> Thank you, >>>>>>>> -Stefán >>>>>>>> >>>>>>>> -- >>>>>>>> >>>>>>>> --- >>>>>>>> You received this message because you are subscribed to the Google >>>>>>>> Groups "OrientDB" group. >>>>>>>> To unsubscribe from this group and stop receiving emails from it, >>>>>>>> send an email to [email protected]. >>>>>>>> >>>>>>>> For more options, visit https://groups.google.com/d/optout. >>>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> -- >>>>>>> Best regards, >>>>>>> Andrey Lomakin. >>>>>>> >>>>>>> Orient Technologies >>>>>>> the Company behind OrientDB >>>>>>> >>>>>>> -- >>>>>> >>>>>> --- >>>>>> You received this message because you are subscribed to the Google >>>>>> Groups "OrientDB" group. >>>>>> To unsubscribe from this group and stop receiving emails from it, >>>>>> send an email to [email protected]. >>>>>> For more options, visit https://groups.google.com/d/optout. >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> Best regards, >>>>> Andrey Lomakin. >>>>> >>>>> Orient Technologies >>>>> the Company behind OrientDB >>>>> >>>>> -- >> >> --- >> You received this message because you are subscribed to the Google Groups >> "OrientDB" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > Best regards, > Andrey Lomakin. > > Orient Technologies > the Company behind OrientDB > > -- --- You received this message because you are subscribed to the Google Groups "OrientDB" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
