Package com.sun.sgs.profile

Examples of com.sun.sgs.profile.ProfileConsumer


    }
   
    @Test
    public void testOperationMediumToMaxLevel() 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("opmedtomax");
        final Identity negativeOwner = new DummyIdentity("opmedtomaxneg");
        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.MAX);
        txnScheduler.runTask(
            new TestAbstractKernelRunnable() {
    public void run() {
                    op.report();
                }
View Full Code Here


    }
   
    @Test
    public void testOperationMaxLevel() throws Exception {
        ProfileCollector collector = getCollector(serverNode);
        ProfileConsumer cons1 = collector.getConsumer("c1");
        final ProfileOperation op =
                cons1.createOperation("something", 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("opmax");
        final Identity negativeOwner = new DummyIdentity("opmaxneg");
        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() {
                    // No report expected:  the level is still too low
                    op.report();
                }
            }, negativeOwner);
           
        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() {
                    op.report();
                }
View Full Code Here

    @Test
    public void testOperationMultiple() 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, testType, ProfileLevel.MIN);
        final ProfileOperation op1 =
                cons1.createOperation(op1Name, 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 testSample() throws Exception {
        final String name = "sample";
        ProfileCollector collector = getCollector(serverNode);
        ProfileConsumer cons1 = collector.getConsumer("c1");
        // Register a counter to be noted at all profiling levels
        final ProfileSample sample =
            cons1.createSample(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 testSampleLevel() throws Exception {
        final String name = "MySamples";
        ProfileCollector collector = getCollector(serverNode);
        ProfileConsumer cons1 = collector.getConsumer("cons1");
        final ProfileSample sample =
            cons1.createSample(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>();

        final List<Long> testValues = new ArrayList<Long>();
        testValues.add(101L);
        testValues.add(-22L);
        // 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("samplelevel");
        final Identity negativeOwner = new DummyIdentity("samplelevelneg");
        SimpleTestListener test = new SimpleTestListener(
            new SampleReportRunnable(sample.getName(),
                                     negativeOwner, positiveOwner,
                                     errorExchanger, testValues));
        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 samples.
                    for (Long v : testValues) {
                        sample.addSample(v);
                    }
                }
            }, 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 samples to appear
View Full Code Here

   
    @Test
    public void testSampleLevelChange() throws Exception {
        final String name = "samples";
        ProfileCollector collector = getCollector(serverNode);
        final ProfileConsumer cons1 = collector.getConsumer("c1");
        final ProfileSample sample =
            cons1.createSample(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>();

        final List<Long> testValues = new ArrayList<Long>();
        testValues.add(101L);
        testValues.add(-22L);
        // 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("samplechange");
        final Identity negativeOwner = new DummyIdentity("samplechangeneg");
        SimpleTestListener test = new SimpleTestListener(
            new SampleReportRunnable(sample.getName(),
                                     negativeOwner, positiveOwner,
                                     errorExchanger, testValues));
        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 samples.
                    for (Long v : testValues) {
                        sample.addSample(v);
                    }
                }
            }, negativeOwner);

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

        txnScheduler.runTask(
            new TestAbstractKernelRunnable() {
    public void run() {
                    // We don't expect to see this sample in the report;
                    // the level was still too low.
                    sample.addSample(999L);
                    cons1.setProfileLevel(ProfileLevel.MAX);
                    for (Long v : testValues) {
                        sample.addSample(v);
                    }
                    cons1.setProfileLevel(ProfileLevel.MIN);
                    // Should not see this one, either
                    sample.addSample(-22L);
                }
            }, positiveOwner);
           
View Full Code Here

    final ProfileOperation isLocalNodeAliveNonTransOp;
   
    WatchdogServiceStats(ProfileCollector collector, WatchdogServiceImpl wdog) {
        watchdog = wdog;
       
        ProfileConsumer consumer =
            collector.getConsumer(ProfileCollectorImpl.CORE_CONSUMER_PREFIX +
                                  "WatchdogService");
        ProfileLevel level = ProfileLevel.MAX;
        ProfileDataType type = ProfileDataType.TASK_AND_AGGREGATE;
       
        addNodeListenerOp =
            consumer.createOperation("addNodeListener", type, level);
        addRecoveryListenerOp =
            consumer.createOperation("addRecoveryListener", type, level);
        getBackupOp =
            consumer.createOperation("getBackup", type, level);
        getNodeOp =
            consumer.createOperation("getNode", type, level);
        getNodesOp =
            consumer.createOperation("getNodes", type, level);
        getLocalNodeHealthOp =
            consumer.createOperation("getLocalNodeHealth", type, level);
        getLocalNodeHealthNonTransOp =
            consumer.createOperation("getLocalNodeHealthNonTransactional",
                                     type, level);
        isLocalNodeAliveOp =
            consumer.createOperation("isLocalNodeAlive", type, level);
        isLocalNodeAliveNonTransOp =
            consumer.createOperation("isLocalNodeAliveNonTransactional",
                                     type, level);
    }
View Full Code Here

    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
        getLocalNodeIdOp =
            consumer.createOperation("getLocalNodeId", type, level);
        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

   
    ClientSessionServiceStats(ProfileCollector collector,
                              ClientSessionServiceImpl service)
    {
        this.service = service;
        ProfileConsumer consumer =
            collector.getConsumer(ProfileCollectorImpl.CORE_CONSUMER_PREFIX +
                                  "ClientSessionService");
        ProfileLevel level = ProfileLevel.MAX;
        ProfileDataType type = ProfileDataType.TASK_AND_AGGREGATE;
       
        addSessionStatusListenerOp =
            consumer.createOperation("addSessionStatusListener",
                                     type, level);
        getSessionProtocolOp =
            consumer.createOperation("getSessionProtocol", type, level);
        isRelocatingToLocalNodeOp =
            consumer.createOperation("isRelocatingToLocalNode", type, level);
    }
View Full Code Here

   
   @Test
    public void testAggregateProfileCounter() 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 AggregateProfileCounter counter =
                (AggregateProfileCounter)
                    cons1.createCounter(name, testType, ProfileLevel.MIN);
       
        counter.incrementCount();
        assertEquals(1, counter.getCount());
       
        counter.incrementCount(4);
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.