Package com.collective2.signalEntry.implementation

Examples of com.collective2.signalEntry.implementation.Request


        //starts out empty
        assertTrue(!journal.pending().hasNext());

        /////////////////////////
        //successful addition of one request
        Request request = new Request(Command.Signal);
        journal.append(request);

        //stop journal and force reload from disk
        journal.close();
        journal = new C2EntryServiceLogFileJournal(tempFile,4096);

        assertEquals(request, journal.pending().next());

        ///////////////////////////////
        //successful removal of one request
        journal.markSent(request);

        //stop journal and force reload from disk
        journal.close();
        journal = new C2EntryServiceLogFileJournal(tempFile,4096);

        assertTrue("check file:"+tempFile,!journal.pending().hasNext());

        //////////////////////////////////
        //successful addition of two requests in order
        Request request2 = new Request(Command.Cancel);
        assert(!request.equals(request2));
        journal.append(request);

        //stop journal and force reload from disk
        journal.close();
View Full Code Here


            e.printStackTrace();
            fail();
        }
        C2EntryServiceLogFileJournal journal = new C2EntryServiceLogFileJournal(tempFile,50);

        Request request = new Request(Command.Signal);
        Request request2 = new Request(Command.Cancel);

        journal.append(request);
        journal.markSent(request);

        assertFalse(journal.pending().hasNext());
View Full Code Here

    private void journalTest(C2EntryServiceJournal journal) {
        //starts out empty
        assertTrue(!journal.pending().hasNext());

        //successful addition of one request
        Request request = new Request(Command.Signal);
        journal.append(request);
        assertEquals(request,journal.pending().next());

        //successful removal of one request
        journal.markSent(request);
        assertTrue(!journal.pending().hasNext());

        //successful addition of two requests in order
        Request request2 = new Request(Command.Cancel);
        assert(!request.equals(request2));
        journal.append(request);
        journal.append(request2);
        Iterator<Request> iterator = journal.pending();
        assertTrue(iterator.hasNext());
View Full Code Here

    @Test
    public void timeoutTest() {

        Collective2Adapter adapter = new Collective2Adapter();
        //mock request that does not return actual URL to collective2
        Request mockRequest = new Request(Command.AllSignals) {
            @Override
            public URL buildURL() {
                try {
                    return new URL("file://nofile.nowhere");
View Full Code Here

    @Test
    public void transmitTest() {

        Collective2Adapter adapter = new Collective2Adapter();
        //mock request that does not return actual URL to collective2
        Request mockRequest = new Request(Command.Cancel) {
            @Override
            public URL buildURL() {
                return getClass().getClassLoader().getResource("staticResponse.xml");
            };
        };
View Full Code Here

            }

            @Override
            public void markSent(Request request) {

                Request oldest = super.pending().next();
                assertEquals("\n"+request+"\n"+oldest ,
                                  request,     oldest);

                super.markSent(request);
            }
View Full Code Here

        list.add(request);
    }

    @Override
    public void markRejected(Request request) {
        Request oldPending = list.remove(0);
        if (!request.equals(oldPending)) {
            throw new C2ServiceException("Expected to finish "+oldPending+" but instead was rejected "+request,false);
        }
    }
View Full Code Here

        }
    }

    @Override
    public void markSent(Request request) {
        Request oldPending = list.remove(0);
        if (!request.equals(oldPending)) {
            throw new C2ServiceException("Expected to finish "+oldPending+" but instead was sent "+request,false);
        }
    }
View Full Code Here

                                }
                            }
                            col = ('\n' == value ? 0 : col+1);
                            if (0 == col && loadPending) {
                                //save last row we are on to the next one
                                Request request = Request.parseURL(builder.toString());
                                builder.setLength(0);

                                //when loading pending requests if any are time dependent must throw failure
                                //can not be done upon write because this is used as a journal and if its never used
                                //as a source of recovery then there is no failure.
                                if (null != request.get(Parameter.CancelsAtRelative)) {
                                    //cant try again or delay because the request is time dependent relative to submission time
                                    throw new C2ServiceException("Can not retry request which makes use of CancelsAtRelative feature", false);
                                }

                                requests.add(request);
View Full Code Here

     * @param mark
     */
    private void mark(Request request, ByteBuffer mark) {

        //remove from in memory list
        Request oldPending = requests.remove(0);
        if (!request.equals(oldPending)) {
            throw new C2ServiceException("Expected to finish "+oldPending+" but instead was sent "+request,false);
        }
        long pendingPosition = positions.remove(0);
        try {
View Full Code Here

TOP

Related Classes of com.collective2.signalEntry.implementation.Request

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.