Package com.sun.sgs.profile

Examples of com.sun.sgs.profile.ProfileConsumer


    final ProfileOperation nextServiceBoundNameOp;
    final ProfileOperation removeServiceBindingOp;
    final ProfileOperation setServiceBindingOp;
   
    DataServiceStats(ProfileCollector collector) {
        ProfileConsumer consumer =
            collector.getConsumer(ProfileCollectorImpl.CORE_CONSUMER_PREFIX +
                                  "DataService");
        ProfileLevel level = ProfileLevel.MAX;
        ProfileDataType type = ProfileDataType.TASK_AND_AGGREGATE;
       
        // Manager operations
        createRefOp =
            consumer.createOperation("createReference", type, level);
        getBindingOp =
            consumer.createOperation("getBinding", type, level);
        getBindingForUpdateOp =
            consumer.createOperation("getBindingForUpdate", type, level);
        getObjectIdOp =
      consumer.createOperation("getObjectId", type, level);
        markForUpdateOp =
            consumer.createOperation("markForUpdate", type, level);
        nextBoundNameOp =
            consumer.createOperation("nextBoundName", type, level);
        removeBindingOp =
            consumer.createOperation("removeBinding", type, level);
        removeObjOp =
            consumer.createOperation("removeObject", type, level);
        setBindingOp =
            consumer.createOperation("setBinding", type, level);
        // Service operations
        createRefForIdOp =
            consumer.createOperation("createReferenceForId", type, level);
        getServiceBindingOp =
            consumer.createOperation("getServiceBinding", type, level);
        getServiceBindingForUpdateOp = consumer.createOperation(
      "getServiceBindingForUpdate", type, level);
        nextObjIdOp =
            consumer.createOperation("nextObjectId", type, level);
        nextServiceBoundNameOp =
            consumer.createOperation("nextServiceBoundName", type, level);
        removeServiceBindingOp =
            consumer.createOperation("removeServiceBinding", type, level);
        setServiceBindingOp =
            consumer.createOperation("setServiceBinding", type, level);
    }
View Full Code Here


    /* -- counter tests -- */
    @Test
    public void testCounter() throws Exception {
        final String name = "counter";
        ProfileCollector collector = getCollector(serverNode);
        ProfileConsumer cons1 = collector.getConsumer("c1");
        // Register a counter to be noted at all profiling levels
        final ProfileCounter counter =
                cons1.createCounter(name, testType, ProfileLevel.MIN);  
       
        // 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.
View Full Code Here

   
    @Test
    public void testCounterLevel() throws Exception {
        final String name = "MyCounter";
        ProfileCollector collector = getCollector(serverNode);
        ProfileConsumer cons1 = collector.getConsumer("c1");
        // Register a counter to be updated only at the max level
        final ProfileCounter counter =
                cons1.createCounter(name, testType, ProfileLevel.MAX);
       
        // 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>();

        // The owner for our positive test.  The listener uses this owner
        // to find the ProfileReport for the task in this test.
        final Identity positiveOwner = new DummyIdentity("counterlevel");
        final Identity negativeOwner = new DummyIdentity("counterlevelneg");
        SimpleTestListener test = new SimpleTestListener(
            new CounterReportRunnable(counter.getName(), negativeOwner,
                                      positiveOwner, errorExchanger, 1));
        profileCollector.addListener(test, true);

        txnScheduler.runTask(
            new TestAbstractKernelRunnable() {
    public void run() {
                    // The default profile level is MIN so we don't expect
                    // to see the counter incremented.
                    counter.incrementCount();
                }
            }, negativeOwner);

        AssertionError error =
            errorExchanger.exchange(null, TIMEOUT, TimeUnit.MILLISECONDS);
        if (error != null) {
            throw new AssertionError(error);
        }

        cons1.setProfileLevel(ProfileLevel.MAX);
        txnScheduler.runTask(
            new TestAbstractKernelRunnable() {
    public void run() {
                    // Because we bumped the consumer's profile level,
                    // we expect the counter
View Full Code Here

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

    @Test
    public void testCounterIncrementValue() throws Exception {
        final String name = "counter";
        final int incValue = 5;
        ProfileCollector collector = getCollector(serverNode);
        ProfileConsumer cons1 = collector.getConsumer("c1");
        // Register a counter to be noted at all profiling levels
        final ProfileCounter counter =
                cons1.createCounter(name, testType, ProfileLevel.MIN);

        // 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.
View Full Code Here

    @Test
    public void testCounterIncrementMultiple() throws Exception {
        final String name = "counterforstuff";
        final int incValue = 3;
        ProfileCollector collector = getCollector(serverNode);
        ProfileConsumer cons1 = collector.getConsumer("c1");
        // Register a counter to be noted at all profiling levels
        final ProfileCounter counter =
                cons1.createCounter(name, testType, ProfileLevel.MIN);
       
        // 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.
View Full Code Here

    @Test
    public void testCounterIncrementValueMultiple() throws Exception {
        final String name = "counterforstuff";
        final int incValue = 5;
        ProfileCollector collector = getCollector(serverNode);
        ProfileConsumer cons1 = collector.getConsumer("c1");
        // Register a counter to be noted at all profiling levels
        final ProfileCounter counter =
                cons1.createCounter(name, testType, ProfileLevel.MIN);
       
        // 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.
View Full Code Here

   
    @Test
    public void testTaskCounterMultConsumer() throws Exception {
        final String name = "sharedName";
        ProfileCollector collector = getCollector(serverNode);
        ProfileConsumer cons1 = collector.getConsumer("c1");
        ProfileConsumer cons2 = collector.getConsumer("c2");
        final ProfileCounter counter1 =
                cons1.createCounter(name, testType, ProfileLevel.MIN);
        final ProfileCounter counter2 =
                cons2.createCounter(name, testType, ProfileLevel.MIN);
       
        // 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.
View Full Code Here

    }
   
    @Test
    public void testOperation() throws Exception {
        ProfileCollector collector = getCollector(serverNode);
        ProfileConsumer cons1 = collector.getConsumer("c1");
        final ProfileOperation op =
                cons1.createOperation("something", testType, ProfileLevel.MIN);
       
        // 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.
View Full Code Here

    }
       
    @Test
    public void testOperationMediumLevel() throws Exception {
        ProfileCollector collector = getCollector(serverNode);
        ProfileConsumer cons1 = collector.getConsumer("c1");
        final ProfileOperation op =
                cons1.createOperation("something", testType,
                                      ProfileLevel.MEDIUM);
       
        // 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>();

        // The owner for our positive test.  The listener uses this owner
        // to find the ProfileReport for the task in this test.
        final Identity positiveOwner = new DummyIdentity("opmed");
        final Identity negativeOwner = new DummyIdentity("opmedneg");
        SimpleTestListener test = new SimpleTestListener(
            new OperationReportRunnable(op.getName(),
                                        negativeOwner, positiveOwner,
                                        errorExchanger));
        profileCollector.addListener(test, true);

        txnScheduler.runTask(
            new TestAbstractKernelRunnable() {
    public void run() {
                    // We do not expect to see this reported.
                    op.report();
                }
            }, negativeOwner);

        AssertionError error =
            errorExchanger.exchange(null, TIMEOUT, TimeUnit.MILLISECONDS);
        if (error != null) {
            throw new AssertionError(error);
        }

        cons1.setProfileLevel(ProfileLevel.MEDIUM);
        txnScheduler.runTask(
            new TestAbstractKernelRunnable() {
    public void run() {
                    op.report();
                }
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.