Package com.sun.sgs.profile

Examples of com.sun.sgs.profile.ProfileOperation


    {
        if (name == null) {
            throw new NullPointerException("Operation name must not be null");
        }
        String fullName = getCanonicalName(name);
  ProfileOperation op = ops.get(fullName);
       
  if (op == null) {
            switch (type) {
                case TASK:
                    op = new TaskProfileOperationImpl(fullName, type, minLevel);
View Full Code Here


    /** {@inheritDoc} */
    public void propertyChange(PropertyChangeEvent event) {
  if (event.getPropertyName().
                equals("com.sun.sgs.profile.newop"))
        {       
      ProfileOperation op = (ProfileOperation) (event.getNewValue());
      opCounts.put(op.getName(), 0L);
  } else {
      if (event.getPropertyName().
                    equals("com.sun.sgs.profile.threadcount"))
            {
    threadCount = ((Integer) (event.getNewValue())).intValue();
View Full Code Here

    /** {@inheritDoc} */
    public void propertyChange(PropertyChangeEvent event) {
  if (event.getPropertyName().
                equals("com.sun.sgs.profile.newop"))
        {         
      ProfileOperation op = (ProfileOperation) (event.getNewValue());
      sOpCounts.put(op.getName(), 0L);
      fOpCounts.put(op.getName(), 0L);
  }
    }
View Full Code Here

    }

    /** {@inheritDoc} */
    public byte[] getObject(Transaction txn, long oid, boolean forUpdate) {
  byte[] result = dataStore.getObject(txn, oid, forUpdate);
  ProfileOperation op =
                forUpdate ? stats.getObjectForUpdateOp : stats.getObjectOp;
  op.report();
  stats.readBytesCounter.incrementCount(result.length);
  stats.readObjectsCounter.incrementCount();
  stats.readBytesSample.addSample(result.length);
  return result;
    }
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.
        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("opowner");
        final Identity negativeOwner = new DummyIdentity("opownerneg");
        SimpleTestListener test = new SimpleTestListener(
            new OperationReportRunnable(op.getName(),
                                        negativeOwner, positiveOwner,
                                        errorExchanger));
        profileCollector.addListener(test, true);

        txnScheduler.runTask(
            new TestAbstractKernelRunnable() {
    public void run() {
                    op.report();
                }
            }, positiveOwner);

        AssertionError error =
            errorExchanger.exchange(null, TIMEOUT, TimeUnit.MILLISECONDS);
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();
                }
            }, positiveOwner);
           
        error =
            errorExchanger.exchange(null, TIMEOUT, TimeUnit.MILLISECONDS);
View Full Code Here

   
    @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();
                }
            }, positiveOwner);
           
        error = errorExchanger.exchange(null, TIMEOUT, TimeUnit.MILLISECONDS);
        if (error != null) {
View Full Code Here

    }

    /** {@inheritDoc} */
    public byte[] getObject(Transaction txn, long oid, boolean forUpdate) {
  byte[] result = dataStore.getObject(txn, oid, forUpdate);
  ProfileOperation op =
                forUpdate ? stats.getObjectForUpdateOp : stats.getObjectOp;
  op.report();
  stats.readBytesCounter.incrementCount(result.length);
  stats.readObjectsCounter.incrementCount();
  stats.readBytesSample.addSample(result.length);
  return result;
    }
View Full Code Here

    /* -- Operation tests -- */
    @Test(expected=NullPointerException.class)
    public void testOperationTaskBadName() throws Exception {
        ProfileCollector collector = getCollector(serverNode);
        ProfileConsumer cons1 = collector.getConsumer("c1");
        ProfileOperation o1 =
            cons1.createOperation(null, ProfileDataType.TASK, ProfileLevel.MIN);
    }
View Full Code Here

    }
    @Test(expected=NullPointerException.class)
    public void testOperationAggregateBadName() throws Exception {
        ProfileCollector collector = getCollector(serverNode);
        ProfileConsumer cons1 = collector.getConsumer("c1");
        ProfileOperation o1 =
            cons1.createOperation(null,
                                  ProfileDataType.AGGREGATE, ProfileLevel.MIN);
    }
View Full Code Here

TOP

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

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.