Examples of StoreHandle


Examples of org.mom4j.mstore.StoreHandle

        //
        final String sessionId = Long.toString(System.currentTimeMillis());
       
        String s = "test : " + (new java.util.Date());
        ByteArrayInputStream in = new ByteArrayInputStream(s.getBytes());
        StoreHandle name = this.store.write(sessionId, DESTINATION, 4, in);
       
        File f = new File(this.storePath + DELIM + name);
        Assert.assertTrue(f + " does not exist", f.exists());
        Assert.assertTrue(f + " seems to have the wrong file-size",
                    f.length() >= s.getBytes().length);
       
        StringTokenizer st = new StringTokenizer(name.toString(), DELIM);
        Assert.assertEquals("no of tokens in fs-name", 8, st.countTokens());
       
        String dest = st.nextToken();
        Assert.assertEquals("first token of fs-name", DESTINATION, dest);
        long prio = Long.parseLong(st.nextToken());
        Assert.assertTrue("prio fs-element is out of range", 0 <= prio && prio <= 9);
       
        Thread.sleep(1000 * 60);
       
        String s1 = "test : " + (new java.util.Date());
        in = new ByteArrayInputStream(s1.getBytes());
        StoreHandle name1 = this.store.write(sessionId, DESTINATION, 5, in);
       
        String path  = name.toString().substring(name.toString().lastIndexOf(DELIM));
        String path1 = name1.toString().substring(name1.toString().lastIndexOf(DELIM));
       
        Assert.assertTrue("name:" + name + " name1:" + name1 + " must not have the same path", !path.equals(path1));
       
        //
        // Test read
View Full Code Here

Examples of org.mom4j.mstore.StoreHandle

       
        this.store.txBegin(sessionId);
       
        String s1 = "test : " + (new java.util.Date());
        ByteArrayInputStream in1 = new ByteArrayInputStream(s1.getBytes());
        StoreHandle name1 = this.store.write(sessionId, DESTINATION, 4, in1);
       
        String s2 = "test : " + (new java.util.Date());
        ByteArrayInputStream in2 = new ByteArrayInputStream(s2.getBytes());
        StoreHandle name2 = this.store.write(sessionId, DESTINATION1, 4, in2);
       
        Thread.sleep(1000 * 30);
       
        String s3 = "test : " + (new java.util.Date());
        ByteArrayInputStream in3 = new ByteArrayInputStream(s3.getBytes());
        StoreHandle name3 = this.store.write(sessionId, DESTINATION1, 4, in3);
       
        Assert.assertTrue(name1 + " (name1) must not end with .tx", !name1.toString().endsWith(".tx"));
        Assert.assertTrue(name2 + " (name2) must not end with .tx", !name2.toString().endsWith(".tx"));
        Assert.assertTrue(name3 + " (name3) must not end with .tx", !name3.toString().endsWith(".tx"));
       
        File tx1 = new File(this.storePath + DELIM + name1 + ".tx");
        File tx2 = new File(this.storePath + DELIM + name2 + ".tx");
        File tx3 = new File(this.storePath + DELIM + name3 + ".tx");
       
View Full Code Here

Examples of org.mom4j.mstore.StoreHandle

       
        this.store.txBegin(sessionId);
       
        String s1 = "test : " + (new java.util.Date());
        ByteArrayInputStream in1 = new ByteArrayInputStream(s1.getBytes());
        StoreHandle name1 = this.store.write(sessionId, DESTINATION, 4, in1);
       
        String s2 = "test : " + (new java.util.Date());
        ByteArrayInputStream in2 = new ByteArrayInputStream(s2.getBytes());
        StoreHandle name2 = this.store.write(sessionId, DESTINATION1, 4, in2);
       
        Thread.sleep(1000 * 30);
       
        String s3 = "test : " + (new java.util.Date());
        ByteArrayInputStream in3 = new ByteArrayInputStream(s3.getBytes());
        StoreHandle name3 = this.store.write(sessionId, DESTINATION1, 4, in3);
       
        Assert.assertTrue(name1 + " (name1) must not end with .tx", !name1.toString().endsWith(".tx"));
        Assert.assertTrue(name2 + " (name2) must not end with .tx", !name2.toString().endsWith(".tx"));
        Assert.assertTrue(name3 + " (name3) must not end with .tx", !name3.toString().endsWith(".tx"));
       
        File tx1 = new File(this.storePath + DELIM + name1 + ".tx");
        File tx2 = new File(this.storePath + DELIM + name2 + ".tx");
        File tx3 = new File(this.storePath + DELIM + name3 + ".tx");
       
View Full Code Here

Examples of org.mom4j.mstore.StoreHandle

    {
        final String sessionId = Long.toString(System.currentTimeMillis());
       
        String s1 = "test : " + (new java.util.Date());
        ByteArrayInputStream in1 = new ByteArrayInputStream(s1.getBytes());
        StoreHandle name1 = this.store.write(sessionId, DESTINATION, 4, in1);
       
        String s2 = "test : " + (new java.util.Date());
        ByteArrayInputStream in2 = new ByteArrayInputStream(s2.getBytes());
        StoreHandle name2 = this.store.write(sessionId, DESTINATION1, 4, in2);
       
        Thread.sleep(1000 * 30);
       
        String s3 = "test : " + (new java.util.Date());
        ByteArrayInputStream in3 = new ByteArrayInputStream(s3.getBytes());
        StoreHandle name3 = this.store.write(sessionId, DESTINATION1, 4, in3);
       
        Assert.assertTrue(name1 + " (name1) must not end with .tx", !name1.toString().endsWith(".tx"));
        Assert.assertTrue(name2 + " (name2) must not end with .tx", !name2.toString().endsWith(".tx"));
        Assert.assertTrue(name3 + " (name3) must not end with .tx", !name3.toString().endsWith(".tx"));
       
        File f1 = new File(this.storePath + DELIM + name1);
        File f2 = new File(this.storePath + DELIM + name2);
        File f3 = new File(this.storePath + DELIM + name3);
       
View Full Code Here

Examples of org.mom4j.mstore.StoreHandle

    {
        final String sessionId = Long.toString(System.currentTimeMillis());
       
        String s1 = "test : " + (new java.util.Date());
        ByteArrayInputStream in1 = new ByteArrayInputStream(s1.getBytes());
        StoreHandle name1 = this.store.write(sessionId, DESTINATION, 4, in1);
       
        String s2 = "test : " + (new java.util.Date());
        ByteArrayInputStream in2 = new ByteArrayInputStream(s2.getBytes());
        StoreHandle name2 = this.store.write(sessionId, DESTINATION1, 4, in2);
       
        Thread.sleep(1000 * 30);
       
        String s3 = "test : " + (new java.util.Date());
        ByteArrayInputStream in3 = new ByteArrayInputStream(s3.getBytes());
        StoreHandle name3 = this.store.write(sessionId, DESTINATION1, 4, in3);
       
        Assert.assertTrue(name1 + " (name1) must not end with .tx", !name1.toString().endsWith(".tx"));
        Assert.assertTrue(name2 + " (name2) must not end with .tx", !name2.toString().endsWith(".tx"));
        Assert.assertTrue(name3 + " (name3) must not end with .tx", !name3.toString().endsWith(".tx"));
       
        File f1 = new File(this.storePath + DELIM + name1);
        File f2 = new File(this.storePath + DELIM + name2);
        File f3 = new File(this.storePath + DELIM + name3);
       
View Full Code Here

Examples of org.mom4j.mstore.StoreHandle

        final String sessionId_B = Long.toString(System.currentTimeMillis());
        final String DEST = "test-destination-lock-" + System.currentTimeMillis();
       
        String s0 = "test : " + (new java.util.Date());
        ByteArrayInputStream in0 = new ByteArrayInputStream(s0.getBytes());
        StoreHandle name0 = this.store.write(sessionId_A, DEST, 4, in0);
       
        String s1 = "test : " + (new java.util.Date());
        ByteArrayInputStream in1 = new ByteArrayInputStream(s1.getBytes());
        StoreHandle name1 = this.store.write(sessionId_A, DEST, 4, in1);
       
        String s2 = "test : " + (new java.util.Date());
        ByteArrayInputStream in2 = new ByteArrayInputStream(s2.getBytes());
        StoreHandle name2 = this.store.write(sessionId_A, DEST, 4, in2);

        String s3 = "test : " + (new java.util.Date());
        ByteArrayInputStream in3 = new ByteArrayInputStream(s3.getBytes());
        StoreHandle name3 = this.store.write(sessionId_A, DEST, 4, in3);

        File f0 = new File(this.storePath + DELIM + name0);
        File f1 = new File(this.storePath + DELIM + name1);
        File f2 = new File(this.storePath + DELIM + name2);
        File f3 = new File(this.storePath + DELIM + name3);

        Assert.assertTrue(f0 + " (name0) does not exist", f0.exists());
        Assert.assertTrue(f1 + " (name1) does not exist", f1.exists());
        Assert.assertTrue(f2 + " (name2) does not exist", f2.exists());
        Assert.assertTrue(f3 + " (name3) does not exist", f3.exists());

        try {
            this.store.lock(sessionId_A, name1);
            Assert.fail("lock outside a tx must not work");
        } catch(LockException ex) {
            //as expected
        }

        this.store.txBegin(sessionId_A);
        this.store.txBegin(sessionId_B);

        /*--- Lock the files ---*/
        this.store.lock(sessionId_A, name0);
        //After name0 is locked, name1 is the eldest, readable file
        StoreHandle eldest = this.store.getEldest(DEST);
        Assert.assertEquals("Eldest entry in " + DEST, name1, eldest);
        //lock the rest
        this.store.lock(sessionId_B, name3);
        //After name3 is locked, name2 is the latest, readable file
        StoreHandle latest = this.store.getLatest(DEST);
        Assert.assertEquals("Latest entry in " + DEST, name2, latest);
        //lock the rest
        this.store.lock(sessionId_A, name1);
        this.store.lock(sessionId_B, name2);

View Full Code Here

Examples of org.mom4j.mstore.StoreHandle

    {
        final String sessionId = Long.toString(System.currentTimeMillis());
       
        String s0 = "test : " + (new java.util.Date());
        ByteArrayInputStream in0 = new ByteArrayInputStream(s0.getBytes());
        StoreHandle name0 = this.store.write(sessionId, DESTINATION, 4, in0);
       
        String s1 = "test : " + (new java.util.Date());
        ByteArrayInputStream in1 = new ByteArrayInputStream(s1.getBytes());
        StoreHandle name1 = this.store.write(sessionId, DESTINATION, 4, in1);
       
        String s2 = "test : " + (new java.util.Date());
        ByteArrayInputStream in2 = new ByteArrayInputStream(s2.getBytes());
        StoreHandle name2 = this.store.write(sessionId, DESTINATION1, 4, in2);
       
        Thread.sleep(1000 * 30);
       
        String s3 = "test : " + (new java.util.Date());
        ByteArrayInputStream in3 = new ByteArrayInputStream(s3.getBytes());
        StoreHandle name3 = this.store.write(sessionId, DESTINATION1, 4, in3);
       
        Assert.assertTrue(name0 + " (name0) must not end with .tx", !name0.toString().endsWith(".tx"));
        Assert.assertTrue(name1 + " (name1) must not end with .tx", !name1.toString().endsWith(".tx"));
        Assert.assertTrue(name2 + " (name2) must not end with .tx", !name2.toString().endsWith(".tx"));
        Assert.assertTrue(name3 + " (name3) must not end with .tx", !name3.toString().endsWith(".tx"));
       
        File f0 = new File(this.storePath + DELIM + name0);
        File f1 = new File(this.storePath + DELIM + name1);
        File f2 = new File(this.storePath + DELIM + name2);
        File f3 = new File(this.storePath + DELIM + name3);
       
        Assert.assertTrue(f0 + " (name0) does not exist", f0.exists());
        Assert.assertTrue(f1 + " (name1) does not exist", f1.exists());
        Assert.assertTrue(f2 + " (name2) does not exist", f2.exists());
        Assert.assertTrue(f3 + " (name3) does not exist", f3.exists());
       
        this.store.txBegin(sessionId);
       
        String s4 = "test : " + (new java.util.Date());
        ByteArrayInputStream in4 = new ByteArrayInputStream(s4.getBytes());
        StoreHandle name4 = this.store.write(sessionId, DESTINATION, 4, in4);
       
        String s5 = "test : " + (new java.util.Date());
        ByteArrayInputStream in5 = new ByteArrayInputStream(s5.getBytes());
        StoreHandle name5 = this.store.write(sessionId, DESTINATION1, 4, in5);
       
        Assert.assertTrue(name4 + " (name4) must not end with .tx", !name4.toString().endsWith(".tx"));
        Assert.assertTrue(name5 + " (name5) must not end with .tx", !name5.toString().endsWith(".tx"));
       
        File f4 = new File(this.storePath + DELIM + name4 + ".tx");
        File f5 = new File(this.storePath + DELIM + name5 + ".tx");
       
        Assert.assertTrue(f4 + " (name4) does not exist", f4.exists());
View Full Code Here

Examples of org.mom4j.mstore.StoreHandle

        final String sessionId = Long.toString(System.currentTimeMillis());
       
        final String dest = "test-destination" + (this.count++)
                          + "-" + System.currentTimeMillis();
       
        StoreHandle eldest = null;
        StoreHandle latest = null;
       
        String s1 = "test : " + (new java.util.Date());
        ByteArrayInputStream in = new ByteArrayInputStream(s1.getBytes());
        for(int i = 0; i < 100; i++) {
            if(i == 0) {
                eldest = this.store.write(sessionId, dest, 4, in);
            } else {
                latest = this.store.write(sessionId, dest, 4, in);
            }
            in.reset();
            if((i % 10) == 0) {
                Thread.sleep(1000 * 10);
            }
        }
       
        StoreHandle e = this.store.getEldest(dest);
        StoreHandle l = this.store.getLatest(dest);
       
        Assert.assertEquals("eldest file is wrong!", eldest, e);
        Assert.assertEquals("latest file is wrong!", latest, l);
    }
View Full Code Here

Examples of org.mom4j.mstore.StoreHandle

        final String sessionId = Long.toString(System.currentTimeMillis());
       
        final String dest = "test-destination" + (this.count++)
                          + "-" + System.currentTimeMillis();
       
        StoreHandle eldest = null;
        StoreHandle eldest_2nd = null;
        StoreHandle latest = null;
       
        String s1 = "test : " + (new java.util.Date());
        ByteArrayInputStream in = new ByteArrayInputStream(s1.getBytes());
       
        eldest = this.store.write(sessionId, dest, 0, in);
        in.reset();
        this.store.write(sessionId, dest, 5, in);
        in.reset();
        this.store.write(sessionId, dest, 1, in);
        in.reset();
        this.store.write(sessionId, dest, 4, in);
        in.reset();
        this.store.write(sessionId, dest, 4, in);
        in.reset();
        this.store.write(sessionId, dest, 5, in);
        in.reset();
        eldest_2nd = this.store.write(sessionId, dest, 0, in);
        in.reset();
        this.store.write(sessionId, dest, 9, in);
        in.reset();
        this.store.write(sessionId, dest, 7, in);
        in.reset();
        this.store.write(sessionId, dest, 1, in);
        in.reset();
        this.store.write(sessionId, dest, 8, in);
        in.reset();
        this.store.write(sessionId, dest, 4, in);
        in.reset();
        latest = this.store.write(sessionId, dest, 9, in);
        in.reset();
        this.store.write(sessionId, dest, 3, in);
        in.reset();
        this.store.write(sessionId, dest, 1, in);
        in.reset();
        this.store.write(sessionId, dest, 3, in);
        in.reset();
        this.store.write(sessionId, dest, 0, in);
        in.reset();
        this.store.write(sessionId, dest, 1, in);
        in.reset();

       
        StoreHandle e = this.store.getEldest(dest);
        StoreHandle l = this.store.getLatest(dest);
       
        Assert.assertEquals("eldest file is wrong!", eldest, e);
        Assert.assertEquals("latest file is wrong!", latest, l);
       
        this.store.delete(sessionId, eldest);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.