Package com.sun.sgs.profile

Examples of com.sun.sgs.profile.ProfileCounter


    }
    @Test(expected=NullPointerException.class)
    public void testCounterTaskAggregateBadName() throws Exception {
        ProfileCollector collector = getCollector(serverNode);
        ProfileConsumer cons1 = collector.getConsumer("c1");
        ProfileCounter c1 =
            cons1.createCounter(null,
                                ProfileDataType.TASK_AND_AGGREGATE,
                                ProfileLevel.MIN);
    }
View Full Code Here


        ProfileCollector collector = getCollector(serverNode);
        ProfileConsumer cons1 = collector.getConsumer("c1");
        ProfileConsumer cons2 = collector.getConsumer("c2");
        String name = "taskcounter";
        {
            ProfileCounter counter1 =
                    cons1.createCounter(name,
                                        ProfileDataType.TASK, ProfileLevel.MAX);
            ProfileCounter counter2 =
                    cons2.createCounter(name,
                                        ProfileDataType.TASK, ProfileLevel.MAX);
            assertFalse(counter1.getName().equals(counter2.getName()));
            assertTrue(counter1.getName().contains(name));
            assertTrue(counter2.getName().contains(name));
        }
       
        name = "aggregateCounter";
        {
            ProfileCounter counter1 =
                    cons1.createCounter(name, ProfileDataType.AGGREGATE,
                                        ProfileLevel.MAX);
            ProfileCounter counter2 =
                    cons2.createCounter(name, ProfileDataType.AGGREGATE,
                                        ProfileLevel.MAX);
            assertFalse(counter1.getName().equals(counter2.getName()));
            assertTrue(counter1.getName().contains(name));
            assertTrue(counter2.getName().contains(name));
        }
       
        name = "bothCounter";
        {
            ProfileCounter counter1 =
                cons1.createCounter(name, ProfileDataType.TASK_AND_AGGREGATE,
                                    ProfileLevel.MAX);
            ProfileCounter counter2 =
                cons2.createCounter(name, ProfileDataType.TASK_AND_AGGREGATE,
                                    ProfileLevel.MAX);
            assertFalse(counter1.getName().equals(counter2.getName()));
            assertTrue(counter1.getName().contains(name));
            assertTrue(counter2.getName().contains(name));
        }
    }
View Full Code Here

    @Test
    public void testCounterTwice() throws Exception {
        final String name = "counter";
        ProfileCollector collector = getCollector(serverNode);
        ProfileConsumer cons1 = collector.getConsumer("c1");
        ProfileCounter counter1 =
                cons1.createCounter(name,
                                    ProfileDataType.TASK, ProfileLevel.MAX);

        // Try creating with same name and parameters
        ProfileCounter counter2 =
                cons1.createCounter(name,
                                    ProfileDataType.TASK, ProfileLevel.MAX);
        assertSame(counter1, counter2);
       
        // Try creating with same name and different parameters
        try {
            ProfileCounter op3 =
                cons1.createCounter(name,
                                    ProfileDataType.AGGREGATE,
                                    ProfileLevel.MAX);
            fail("Expected IllegalArgumentException");
        } catch (IllegalArgumentException expected) {
            System.err.println(expected);
        }
        try {
            ProfileCounter op3 =
                cons1.createCounter(name,
                                    ProfileDataType.TASK_AND_AGGREGATE,
                                    ProfileLevel.MAX);
            fail("Expected IllegalArgumentException");
        } catch (IllegalArgumentException expected) {
            System.err.println(expected);
        }
        try {
            ProfileCounter op3 =
                cons1.createCounter(name,
                                    ProfileDataType.TASK,
                                    ProfileLevel.MIN);
            fail("Expected IllegalArgumentException");
        } catch (IllegalArgumentException expected) {
            System.err.println(expected);
        }
        try {
            ProfileCounter op3 =
                cons1.createCounter(name,
                                    ProfileDataType.TASK,
                                    ProfileLevel.MEDIUM);
            fail("Expected IllegalArgumentException");
        } catch (IllegalArgumentException expected) {
            System.err.println(expected);
        }
       
        // Try creating with a different name
        ProfileCounter counter4 =
                cons1.createCounter("somethingelse",
                                    ProfileDataType.TASK, ProfileLevel.MAX);
        assertNotSame(counter1, counter4);
    }
View Full Code Here

   
    @Test
    public void testCounterType() throws Exception {
        ProfileCollector collector = getCollector(serverNode);
        ProfileConsumer cons1 = collector.getConsumer("c1");
        ProfileCounter counter =
                cons1.createCounter("counter",
                                    ProfileDataType.TASK, ProfileLevel.MIN);
        assertTrue(counter instanceof TaskProfileCounter);
        assertFalse(counter instanceof AggregateProfileCounter);
       
        ProfileCounter counter1 =
                cons1.createCounter("counter1",
                                    ProfileDataType.AGGREGATE,
                                    ProfileLevel.MIN);
        assertFalse(counter1 instanceof TaskProfileCounter);
        assertTrue(counter1 instanceof AggregateProfileCounter);
       
        ProfileCounter counter2 =
                cons1.createCounter("counter2",
                                    ProfileDataType.TASK_AND_AGGREGATE,
                                    ProfileLevel.MIN);
        assertTrue(counter2 instanceof TaskProfileCounter);
        assertTrue(counter2 instanceof AggregateProfileCounter);
View Full Code Here

    @Test(expected=IllegalStateException.class)
    public void testTaskCounterIncrementNoTransaction() throws Exception {
        ProfileCollector collector = getCollector(serverNode);
        ProfileConsumer cons1 = collector.getConsumer("c1");
        final ProfileCounter counter =
                cons1.createCounter("my counter",
                                    ProfileDataType.TASK, ProfileLevel.MIN);
       
        counter.incrementCount();
    }
View Full Code Here

   
    @Test(expected=IllegalStateException.class)
    public void testTaskCounterIncrementValueNoTransaction() throws Exception {
        ProfileCollector collector = getCollector(serverNode);
        ProfileConsumer cons1 = collector.getConsumer("c1");
        final ProfileCounter counter =
                cons1.createCounter("my counter",
                                    ProfileDataType.TASK, ProfileLevel.MIN);
       
        counter.incrementCount(55);
    }
View Full Code Here

        if (name == null) {
            throw new NullPointerException("Counter name must not be null");
        }
        String fullName = getCanonicalName(name);
        if (counters.containsKey(fullName)) {
            ProfileCounter oldCounter = counters.get(fullName);
            // Check minLevel and type
            if (oldCounter instanceof AbstractProfileData) {
                AbstractProfileData oldData = (AbstractProfileData) oldCounter;
                ProfileLevel oldLevel = oldData.getMinLevel();
                if (oldLevel != minLevel) {
                    throw new IllegalArgumentException(
                            "Counter with name " + name +
                            " already created, but with level " +  oldLevel);
                }
               
                ProfileDataType oldType = oldData.getType();
                if (oldType != type) {
                    throw new  IllegalArgumentException(
                            "Counter with name " + name +
                            " already created, but with type " +  oldType);
                }
            } else {
                // Can't happen in this implementation
                throw new IllegalArgumentException(
                        "Counter with name " + name +
                        " already created with an unknown type");
            }  
            return oldCounter;
        } else {
            ProfileCounter counter;
            switch (type) {
                case TASK:
                    counter = new TaskProfileCounterImpl(fullName, type,
                                                         minLevel);
                    break;
View Full Code Here

TOP

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

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.