Package com.betfair.cougar.core.api.ev

Examples of com.betfair.cougar.core.api.ev.Subscription


            nioLogger.log(NioLogger.LoggingLevel.TRANSPORT, currentSession, "Couldn't find heap definition, heapId = %s", newHeapSubscription.getHeapId());
            logger.log(Level.WARNING, "Can't find the heap for this subscription result. Heap id = " + newHeapSubscription.getHeapId());
            observer.onResult(new ExecutionResult(new CougarServiceException(ServerFaultCode.FrameworkError, "Can't find the heap for this subscription result. Heap id = " + newHeapSubscription.getHeapId())));
        } else {
            if (preExistingHeap && heapState.haveSeenInitialUpdate()) {
                Subscription sub = heapState.addSubscription(this, currentSession, newHeapSubscription.getHeapId(), newHeapSubscription.getSubscriptionId());
                if (sub != null) {
                    observer.onResult(new ExecutionResult(new ConnectedResponseImpl(heapState.getHeap(), sub)));
                } else {
                    // null sub means we already had a subscription with that id, something's not in a good state in the server, so kill this connection as we don't know what's going on
                    nioLogger.log(NioLogger.LoggingLevel.TRANSPORT, currentSession, "Duplicate subscription returned by the server, id = %s - closing session", newHeapSubscription.getSubscriptionId());
View Full Code Here


            nioLogger.log(NioLogger.LoggingLevel.TRANSPORT, currentSession, "Couldn't find heap definition, heapId = %s", newHeapSubscription.getHeapId());
            logger.log(Level.WARNING, "Can't find the heap for this subscription result. Heap id = " + newHeapSubscription.getHeapId());
            observer.onResult(new ExecutionResult(new CougarClientException(ServerFaultCode.FrameworkError, "Can't find the heap for this subscription result. Heap id = " + newHeapSubscription.getHeapId())));
        } else {
            if (preExistingHeap && heapState.haveSeenInitialUpdate()) {
                Subscription sub = heapState.addSubscription(this, currentSession, newHeapSubscription.getHeapId(), newHeapSubscription.getSubscriptionId());
                if (sub != null) {
                    observer.onResult(new ExecutionResult(new ConnectedResponseImpl(heapState.getHeap(), sub)));
                } else {
                    // null sub means we already had a subscription with that id, something's not in a good state in the server, so kill this connection as we don't know what's going on
                    nioLogger.log(NioLogger.LoggingLevel.TRANSPORT, currentSession, "Duplicate subscription returned by the server, id = %s - closing session", newHeapSubscription.getSubscriptionId());
View Full Code Here

    }

    @Override
    public ConnectedResponse simpleConnectedObject(RequestContext ctx, TimeConstraints timeConstraints) {
        ctx.setConnectedObjectLogExtension(new BaselineLogExtension("a","b","c"));
        Subscription sub = createSub(simpleConnectedObjectHeap);
        return new ConnectedResponseImpl(simpleConnectedObjectHeap, sub);
    }
View Full Code Here

    }

    @Override
    public ConnectedResponse simpleConnectedList(RequestContext ctx, TimeConstraints timeConstraints) {
        ctx.setConnectedObjectLogExtension(new BaselineLogExtension("d","e","f"));
        Subscription sub = createSub(simpleConnectedListHeap);
        return new ConnectedResponseImpl(simpleConnectedListHeap, sub);
    }
View Full Code Here

    }

    @Override
    public ConnectedResponse complexConnectedObject(RequestContext ctx, TimeConstraints timeConstraints) {
        ctx.setConnectedObjectLogExtension(new BaselineLogExtension("g","h","i"));
        Subscription sub = createSub(complexConnectedObjectHeap);
        return new ConnectedResponseImpl(complexConnectedObjectHeap, sub);
    }
View Full Code Here

        //first pre timestamp
        Date pre = Calendar.getInstance().getTime();

        ConnectedResponse simpleConnectedObjectResponse = client.simpleConnectedObject(ctx);
        Heap simpleConnectedObjectHeap = protocol == TestConnectedObjectsProtocolEnum.IN_PROCESS ? new ImmutableHeap(simpleConnectedObjectResponse.getHeap().getUri(),simpleConnectedObjectResponse.getHeap(),true) : simpleConnectedObjectResponse.getHeap();
        Subscription simpleConnectedObjectSub = simpleConnectedObjectResponse.getSubscription();

        String subId1 = getSubscriptionId(simpleConnectedObjectSub, socketProtocol);

        //try subscription log check
        {
            //Test Data
            int stepCount = 0;
            TestResult tr = new TestResult();
            tr.setDescription("Testing a new subscription for a simple connected object is logged (redundant if protocol=IN_PROCESS)");

            assertEquals(tr, stepCount++, true, isLogged(file, subId1, simpleObjectUri, startReason, pre, socketProtocol), "Subscription not logged for " + simpleObjectUri);
            results.add(tr);
        }

        ConnectedResponse simpleConnectedListResponse = client.simpleConnectedList(ctx);
        Heap simpleConnectedListHeap = protocol == TestConnectedObjectsProtocolEnum.IN_PROCESS ? new ImmutableHeap(simpleConnectedListResponse.getHeap().getUri(),simpleConnectedListResponse.getHeap(),true) : simpleConnectedListResponse.getHeap();
        Subscription simpleConnectedListSub = simpleConnectedListResponse.getSubscription();

        String subId2 = getSubscriptionId(simpleConnectedListSub, socketProtocol);
        //try subscription log check
        {
            //Test Data
            int stepCount = 0;
            TestResult tr = new TestResult();
            tr.setDescription("Testing a new subscription for a simple connected object is logged (redundant if protocol=IN_PROCESS)");

            assertEquals(tr, stepCount++, true, isLogged(file, subId2, simpleListUri, startReason, pre, socketProtocol), "Subscription not logged for " + simpleListUri);
            results.add(tr);
        }

        ConnectedResponse complexConnectedObjectResponse = client.complexConnectedObject(ctx);
        Heap complexConnectedObjectHeap = protocol == TestConnectedObjectsProtocolEnum.IN_PROCESS ? new ImmutableHeap(complexConnectedObjectResponse.getHeap().getUri(),complexConnectedObjectResponse.getHeap(),true) : complexConnectedObjectResponse.getHeap();

        Subscription complexConnectedObjectSub = complexConnectedObjectResponse.getSubscription();

        String subId3 = getSubscriptionId(complexConnectedObjectSub, socketProtocol);
        //try subscription log check
        {
            //Test Data
View Full Code Here

    }

    @Override
    public ConnectedResponse simpleConnectedObject(RequestContext ctx, TimeConstraints timeConstraints) {
        ctx.setConnectedObjectLogExtension(new BaselineLogExtension("a","b","c"));
        Subscription sub = createSub(simpleConnectedObjectHeap);
        return new ConnectedResponseImpl(simpleConnectedObjectHeap, sub);
    }
View Full Code Here

    }

    @Override
    public ConnectedResponse simpleConnectedList(RequestContext ctx, TimeConstraints timeConstraints) {
        ctx.setConnectedObjectLogExtension(new BaselineLogExtension("d","e","f"));
        Subscription sub = createSub(simpleConnectedListHeap);
        return new ConnectedResponseImpl(simpleConnectedListHeap, sub);
    }
View Full Code Here

    }

    @Override
    public ConnectedResponse complexConnectedObject(RequestContext ctx, TimeConstraints timeConstraints) {
        ctx.setConnectedObjectLogExtension(new BaselineLogExtension("g","h","i"));
        Subscription sub = createSub(complexConnectedObjectHeap);
        return new ConnectedResponseImpl(complexConnectedObjectHeap, sub);
    }
View Full Code Here

            // right, now we've got both locks, in the right order and we've definitely got a heap state which everyone else can also get/has got

            final HeapState finalHeapState = heapState;
            // hmm,
            final Subscription subscription = result.getSubscription();
            result.getHeap().traverse(new UpdateProducingHeapListener() {
                @Override
                protected void doUpdate(Update u) {
                    boolean updateContainsTermination = u.getActions().contains(TerminateHeap.INSTANCE);
                    if (updateContainsTermination) {
                        // note this won't notify this sub, which never got started. the publisher code won't expect a call back for this since
                        // it's just terminated the heap, which implies it wants to disconnect all clients anyway
                        terminateSubscriptions(command.getSession(), heapUri, REQUESTED_BY_PUBLISHER);
                        commandProcessor.writeErrorResponse(command, context, new CougarFrameworkException("Subscription requested for terminated heap: " + heapUri));
                        return;
                    }

                    Multiset<String> heapsForThisClient = heapsByClient.get(command.getSession());
                    if (heapsForThisClient == null) {
                        heapsForThisClient = new Multiset<String>();
                        heapsByClient.put(command.getSession(), heapsForThisClient);
                    }

                    long heapId = finalHeapState.getHeapId();

                    final String subscriptionId = finalHeapState.addSubscription(connectedObjectLogExtension, subscription, command.getSession());
                    subscription.addListener(new Subscription.SubscriptionListener() {
                        @Override
                        public void subscriptionClosed(Subscription subscription, Subscription.CloseReason reason) {
                            if (reason == REQUESTED_BY_PUBLISHER) {
                                PooledServerConnectedObjectManager.this.terminateSubscription(command.getSession(), heapUri, subscriptionId, reason);
                            }
View Full Code Here

TOP

Related Classes of com.betfair.cougar.core.api.ev.Subscription

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.