Package com.sun.sgs.profile

Examples of com.sun.sgs.profile.ProfileConsumer


    @Test
    public void testTaskAggregateOperationUnique() throws Exception {
        final String opName = "something";
        final String op1Name = "else";
        ProfileCollector collector = getCollector(serverNode);
        ProfileConsumer cons1 = collector.getConsumer("c1");
        final ProfileOperation op =
                cons1.createOperation(opName,
                                      ProfileDataType.TASK_AND_AGGREGATE,
                                      ProfileLevel.MIN);
        final ProfileOperation op1 =
                cons1.createOperation(op1Name,
                                      ProfileDataType.TASK_AND_AGGREGATE,
                                      ProfileLevel.MIN);
        final AggregateProfileOperation opAgg = (AggregateProfileOperation) op;
        final AggregateProfileOperation op1Agg =
                (AggregateProfileOperation) op1;
View Full Code Here


   
    /* -- Sample tests -- */
    @Test(expected=NullPointerException.class)
    public void testSampleTaskBadName() throws Exception {
        ProfileCollector collector = getCollector(serverNode);
        ProfileConsumer cons1 = collector.getConsumer("c1");
        ProfileSample s1 =
            cons1.createSample(null, ProfileDataType.TASK, ProfileLevel.MIN);
    }
View Full Code Here

            cons1.createSample(null, ProfileDataType.TASK, ProfileLevel.MIN);
    }
    @Test(expected=NullPointerException.class)
    public void testSampleAggregateBadName() throws Exception {
        ProfileCollector collector = getCollector(serverNode);
        ProfileConsumer cons1 = collector.getConsumer("c1");
        ProfileSample s1 =
            cons1.createSample(null,
                               ProfileDataType.AGGREGATE, ProfileLevel.MIN);
    }
View Full Code Here

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

                               ProfileLevel.MIN);
    }
    @Test(expected=IllegalArgumentException.class)
    public void testSampleTaskAggregateNegCapacity() throws Exception {
        ProfileCollector collector = getCollector(serverNode);
        ProfileConsumer cons1 = collector.getConsumer("c1");
        AggregateProfileSample s1 = (AggregateProfileSample)
            cons1.createSample("foo",
                               ProfileDataType.TASK_AND_AGGREGATE,
                               ProfileLevel.MIN);
        s1.setCapacity(-1);
    }
View Full Code Here

    }
   
    @Test
    public void testSampleName() throws Exception {
        ProfileCollector collector = getCollector(serverNode);
        ProfileConsumer cons1 = collector.getConsumer("c1");
        ProfileConsumer cons2 = collector.getConsumer("c2");
        String name = "mySample";
        {
            ProfileSample samp1 =
                cons1.createSample(name, ProfileDataType.TASK,
                                   ProfileLevel.MAX);
            ProfileSample samp2 =
                cons2.createSample(name, ProfileDataType.TASK,
                                   ProfileLevel.MAX);
            assertFalse(samp1.getName().equals(samp2.getName()));
            assertTrue(samp1.getName().contains(name));
            assertTrue(samp2.getName().contains(name));
        }
       
        name = "aggSample";
        {
            ProfileSample samp1 =
                cons1.createSample(name, ProfileDataType.AGGREGATE,
                                   ProfileLevel.MAX);
            ProfileSample samp2 =
                cons2.createSample(name, ProfileDataType.AGGREGATE,
                                   ProfileLevel.MAX);
            assertFalse(samp1.getName().equals(samp2.getName()));
            assertTrue(samp1.getName().contains(name));
            assertTrue(samp2.getName().contains(name));
        }
       
        name = "bothSample";
        {
            ProfileSample samp1 =
                cons1.createSample(name, ProfileDataType.TASK_AND_AGGREGATE,
                                   ProfileLevel.MAX);
            ProfileSample samp2 =
                cons2.createSample(name, ProfileDataType.TASK_AND_AGGREGATE,
                                   ProfileLevel.MAX);
            assertFalse(samp1.getName().equals(samp2.getName()));
            assertTrue(samp1.getName().contains(name));
            assertTrue(samp2.getName().contains(name));
        }
View Full Code Here

   
    @Test
    public void testSampleTwice() throws Exception {
        final String name = "mySamples";
        ProfileCollector collector = getCollector(serverNode);
        ProfileConsumer cons1 = collector.getConsumer("c1");
        ProfileSample s1 =
                cons1.createSample(name, ProfileDataType.TASK,
                                   ProfileLevel.MAX);

        // Try creating with same name and parameters
        ProfileSample s2 =
                cons1.createSample(name, ProfileDataType.TASK,
                                   ProfileLevel.MAX);
        assertSame(s1, s2);
       
        // Try creating with same name and different parameters
        try {
            ProfileSample s3 =
                cons1.createSample(name, ProfileDataType.AGGREGATE,
                                   ProfileLevel.MAX);
            fail("Expected IllegalArgumentException");
        } catch (IllegalArgumentException expected) {
            System.err.println(expected);
        }
        try {
            ProfileSample s3 =
                cons1.createSample(name, ProfileDataType.TASK_AND_AGGREGATE,
                                   ProfileLevel.MAX);
            fail("Expected IllegalArgumentException");
        } catch (IllegalArgumentException expected) {
            System.err.println(expected);
        }
        try {
            ProfileSample s3 =
                cons1.createSample(name, ProfileDataType.TASK,
                                   ProfileLevel.MIN);
            fail("Expected IllegalArgumentException");
        } catch (IllegalArgumentException expected) {
            System.err.println(expected);
        }
        try {
            ProfileSample s3 =
                cons1.createSample(name, ProfileDataType.TASK,
                                   ProfileLevel.MEDIUM);
            fail("Expected IllegalArgumentException");
        } catch (IllegalArgumentException expected) {
            System.err.println(expected);
        }
        {
            ProfileSample s3 =
                cons1.createSample(name, ProfileDataType.TASK,
                                   ProfileLevel.MAX);
            assertSame(s1, s3);  
        }
       
        final String aggName = "aggregateSample";
        {
            ProfileSample s3 =
                 cons1.createSample(aggName, ProfileDataType.AGGREGATE,
                                    ProfileLevel.MAX);
           
            AggregateProfileSample s4 = (AggregateProfileSample)
                 cons1.createSample(aggName, ProfileDataType.AGGREGATE,
                                    ProfileLevel.MAX);
            assertSame(s3, s4);
        }
       
        final String taskAggName = "task aggregate sample";
        {
            ProfileSample s3 =
                cons1.createSample(taskAggName,
                                   ProfileDataType.TASK_AND_AGGREGATE,
                                   ProfileLevel.MAX);
            ProfileSample s4 =
                 cons1.createSample(taskAggName,
                                    ProfileDataType.TASK_AND_AGGREGATE,
                                    ProfileLevel.MAX);
            assertSame(s3, s4);
        }
       
        // Try creating with a different name
        ProfileSample s5 =
            cons1.createSample("somethingelse", ProfileDataType.TASK,
                               ProfileLevel.MAX);
        assertNotSame(s1, s5);
    }
View Full Code Here

        // makes them easy to find programmatically, we make a best guess
        // search here.
        Map<String, ProfileConsumer> consumers = collector.getConsumers();
        for (Map.Entry<String, ProfileConsumer> entry : consumers.entrySet()) {
            if (entry.getKey().contains("TaskAggregate")) {
                ProfileConsumer taskConsumer = entry.getValue();
                taskConsumer.setProfileLevel(ProfileLevel.MAX);
                break;
            }
        }
       
        // Schedule a periodic task to print reports
View Full Code Here

   

    @Test
    public void testSampleType() throws Exception {
        ProfileCollector collector = getCollector(serverNode);
        ProfileConsumer cons1 = collector.getConsumer("c1");
        ProfileSample s1 =
            cons1.createSample("samples1", ProfileDataType.TASK,
                               ProfileLevel.MAX);
        assertTrue(s1 instanceof TaskProfileSample);
        assertFalse(s1 instanceof AggregateProfileSample);
        ProfileSample s2 =
            cons1.createSample("samples2", ProfileDataType.AGGREGATE,
                               ProfileLevel.MAX);
        assertFalse(s2 instanceof TaskProfileSample);
        assertTrue(s2 instanceof AggregateProfileSample);
       
        ProfileSample s3 =
            cons1.createSample("samples3", ProfileDataType.TASK_AND_AGGREGATE,
                               ProfileLevel.MAX);
        assertTrue(s3 instanceof TaskProfileSample);
        assertTrue(s3 instanceof AggregateProfileSample);
    }
View Full Code Here

        final List<Long> expected = new LinkedList<Long>();
        expected.add(Long.valueOf(5));
        expected.add(Long.valueOf(-1));
        expected.add(Long.valueOf(2));
        ProfileCollector collector = getCollector(serverNode);
        ProfileConsumer cons1 = collector.getConsumer("c1");
        final AggregateProfileSample samp = (AggregateProfileSample)
                cons1.createSample("sample1",
                                   ProfileDataType.TASK_AND_AGGREGATE,
                                   ProfileLevel.MIN);
        final String sampleName = samp.getName();
        // Ensure that a zero capacity aggregate sample sends the sample
        // values to the task listener, but does not accumulate any
View Full Code Here

TOP

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

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.