Package com.sun.sgs.profile

Examples of com.sun.sgs.profile.AggregateProfileOperation


   @Test
   public void testAggregateProfileOperation() throws Exception {
        final String name = "operation";
        ProfileCollector collector = getCollector(serverNode);
        ProfileConsumer cons1 = collector.getConsumer("c1");
        final AggregateProfileOperation op =
                (AggregateProfileOperation)
                    cons1.createOperation(name, testType, ProfileLevel.MIN);
       
        op.report();
        assertEquals(1, op.getCount());
       
        op.report();
        assertEquals(2, op.getCount());
       
        op.clearCount();
        assertEquals(0, op.getCount());
       
        op.report();
        assertEquals(1, op.getCount());
   }
View Full Code Here


                                      ProfileLevel.MIN);
        final ProfileOperation op1 =
                cons1.createOperation(op1Name,
                                      ProfileDataType.TASK_AND_AGGREGATE,
                                      ProfileLevel.MIN);
        final AggregateProfileOperation opAgg = (AggregateProfileOperation) op;
        final AggregateProfileOperation op1Agg =
                (AggregateProfileOperation) op1;
       
        // Because the listener is running in a different thread, JUnit
        // is not able to report the assertions and failures.
        // Use an exchanger to synchronize between the threads and communicate
        // any problems.
        final Exchanger<AssertionError> errorExchanger =
                new Exchanger<AssertionError>();

        final Identity myOwner = new DummyIdentity("me");
        SimpleTestListener test = new SimpleTestListener(
            new Runnable() {
                public void run() {
                    AssertionError error = null;
                    ProfileReport report = SimpleTestListener.report;
                    if (report.getTaskOwner().equals(myOwner)) {
                        try {
                            List<String> ops =
                                report.getReportedOperations();
                            System.err.println("+++");
                            for (String name : ops) {
                                assertTrue(name.contains(opName)
                                        || name.contains(op1Name));
                               
                                System.err.println("+ " + name);
                            }
                            System.err.println("+++");
                           
                            // Our aggregate counter knows that it was updated
                            assertEquals(4, opAgg.getCount());
                            assertEquals(2, op1Agg.getCount());
                           
                           
                           
                        } catch (AssertionError e) {
                            error = e;
                        }
                    }

                    // Signal that we're done, and return the exception
                    try {
                        errorExchanger.exchange(error);
                    } catch (InterruptedException ignored) {
                        // do nothing
                    }
                }
        });
        profileCollector.addListener(test, true);

        op.report();
        op1.report();
        assertEquals(1, opAgg.getCount());
        assertEquals(1, op1Agg.getCount());
        op.report();
        assertEquals(2, opAgg.getCount());
       
        txnScheduler.runTask(
            new TestAbstractKernelRunnable() {
    public void run() {
                    // We expect to see the operations in the profile report
                    op.report();
                    op1.report();
                    op.report();
                }
            }, myOwner);
           
        AssertionError error =
                errorExchanger.exchange(null, 100, TimeUnit.MILLISECONDS);
        if (error != null) {
            throw new AssertionError(error);
        }
        assertEquals(4, opAgg.getCount());
        assertEquals(2, op1Agg.getCount());
    }
View Full Code Here

TOP

Related Classes of com.sun.sgs.profile.AggregateProfileOperation

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.