Examples of OProfilerMBean


Examples of com.orientechnologies.common.profiler.OProfilerMBean

    keepValuesInMemory = OGlobalConfiguration.MVRBTREE_ENTRY_VALUES_IN_MEMORY.getValueAsBoolean();
    return changed;
  }

  public byte[] toStream() throws OSerializationException {
    final OProfilerMBean profiler = Orient.instance().getProfiler();
    final long timer = profiler.startChrono();

    try {
      stream.jump(0);
      stream.set(CURRENT_PROTOCOL_VERSION);
      stream.setAsFixed(root != null ? root.toStream() : ORecordId.EMPTY_RECORD_ID_STREAM);

      stream.set(size);
      stream.set(pageSize);
      stream.set(keySize);

      stream.set(keySerializer.getId());
      stream.setCustom(valueSerializer.getName());

      if (streamKeySerializer != null)
        stream.setCustom(streamKeySerializer.getName());
      else
        stream.setCustom("");

      final byte[] result = stream.toByteArray();
      record.fromStream(result);
      return result;

    } finally {
      profiler.stopChrono(profiler.getProcessMetric("mvrbtree.toStream"), "Serialize a MVRBTree", timer);
    }
  }
View Full Code Here

Examples of com.orientechnologies.common.profiler.OProfilerMBean

    }
  }

  @SuppressWarnings("unchecked")
  public OSerializableStream fromStream(final byte[] iStream) throws OSerializationException {
    final OProfilerMBean profiler = Orient.instance().getProfiler();
    final long timer = profiler.startChrono();

    try {
      stream.setSource(iStream);
      byte protocolVersion = stream.peek();
      if (protocolVersion != -1) {
        // @COMPATIBILITY BEFORE 0.9.25
        stream.getAsByte();
        if (protocolVersion != CURRENT_PROTOCOL_VERSION)
          OLogManager
              .instance()
              .debug(
                  this,
                  "Found tree %s created with MVRBTree protocol version %d while current one supports the version %d. The tree will be migrated transparently",
                  getRecord().getIdentity(), protocolVersion, CURRENT_PROTOCOL_VERSION);
      }

      root = new ORecordId();
      root.fromStream(stream.getAsByteArrayFixed(ORecordId.PERSISTENT_SIZE));

      size = stream.getAsInteger();
      if (protocolVersion == -1)
        // @COMPATIBILITY BEFORE 0.9.25
        pageSize = stream.getAsShort();
      else
        pageSize = stream.getAsInteger();

      // @COMPATIBILITY BEFORE 1.0
      if (protocolVersion < 1) {
        keySize = 1;
        OLogManager.instance().warn(this,
            "Previous index version was found, partial composite index queries may do not work if you " + "do not recreate index.");
      } else
        keySize = stream.getAsInteger();

      // @COMPATIBILITY BEFORE 1.0
      if (protocolVersion < 3) {
        streamKeySerializer = OStreamSerializerFactory.get(stream.getAsStringCustom());
        valueSerializer = OStreamSerializerFactory.get(stream.getAsStringCustom());

        keySerializer = createRelatedSerializer(streamKeySerializer);
      } else {
        keySerializer = (OBinarySerializer<K>) OBinarySerializerFactory.getInstance().getObjectSerializer(stream.getAsByte());
        valueSerializer = OStreamSerializerFactory.get(stream.getAsStringCustom());

        final String oldKeySerializerName = stream.getAsStringCustom();
        if (oldKeySerializerName != null && oldKeySerializerName.length() > 0)
          streamKeySerializer = OStreamSerializerFactory.get(oldKeySerializerName);
      }
    } catch (Exception e) {
      OLogManager.instance().error(this, "Error on unmarshalling OMVRBTreeMapProvider object from record: %s", e,
          OSerializationException.class, root);
    } finally {
      profiler.stopChrono(profiler.getProcessMetric("mvrbtree.fromStream"), "Deserialize a MVRBTree", timer);
    }
    return this;
  }
View Full Code Here

Examples of com.orientechnologies.common.profiler.OProfilerMBean

   * @param index
   *          which usage is registering.
   */
  private void updateStatistic(OIndex<?> index) {

    final OProfilerMBean profiler = Orient.instance().getProfiler();
    if (profiler.isRecording()) {
      Orient.instance().getProfiler()
          .updateCounter(profiler.getDatabaseMetric(index.getDatabaseName(), "query.indexUsed"), "Used index in query", +1);

      final int paramCount = index.getDefinition().getParamCount();
      if (paramCount > 1) {
        final String profiler_prefix = profiler.getDatabaseMetric(index.getDatabaseName(), "query.compositeIndexUsed");
        profiler.updateCounter(profiler_prefix, "Used composite index in query", +1);
        profiler.updateCounter(profiler_prefix + "." + paramCount, "Used composite index in query with " + paramCount + " params",
            +1);
      }
    }
  }
View Full Code Here

Examples of com.orientechnologies.common.profiler.OProfilerMBean

  protected void updateProfiler(final OCommandContext iContext, final OIndex<?> index, final List<Object> keyParams,
      final OIndexDefinition indexDefinition) {
    if (iContext.isRecordingMetrics())
      iContext.updateMetric("compositeIndexUsed", +1);

    final OProfilerMBean profiler = Orient.instance().getProfiler();
    if (profiler.isRecording()) {
      profiler.updateCounter(profiler.getDatabaseMetric(index.getDatabaseName(), "query.indexUsed"), "Used index in query", +1);

      int params = indexDefinition.getParamCount();
      if (params > 1) {
        final String profiler_prefix = profiler.getDatabaseMetric(index.getDatabaseName(), "query.compositeIndexUsed");

        profiler.updateCounter(profiler_prefix, "Used composite index in query", +1);
        profiler.updateCounter(profiler_prefix + "." + params, "Used composite index in query with " + params + " params", +1);
        profiler.updateCounter(profiler_prefix + "." + params + '.' + keyParams.size(), "Used composite index in query with "
            + params + " params and " + keyParams.size() + " keys", +1);
      }
    }
  }
View Full Code Here

Examples of com.orientechnologies.common.profiler.OProfilerMBean

  public boolean isOpen(long fileId) {
    return writeCache.isOpen(fileId);
  }

  private UpdateCacheResult updateCache(final long fileId, final long pageIndex) throws IOException {
    final OProfilerMBean profiler = storageName != null ? Orient.instance().getProfiler() : null;
    final long startTime = storageName != null ? System.currentTimeMillis() : 0;

    OCacheEntry cacheEntry = am.get(fileId, pageIndex);

    if (cacheEntry != null) {
      am.putToMRU(cacheEntry);

      if (profiler != null && profiler.isRecording())
        profiler.stopChrono(METRIC_HITS, "Requested item was found in Disk Cache", startTime, METRIC_HITS_METADATA);

      return new UpdateCacheResult(false, cacheEntry);
    }

    if (profiler != null && profiler.isRecording())
      profiler.stopChrono(METRIC_MISSED, "Requested item was not found in Disk Cache", startTime, METRIC_MISSED_METADATA);

    cacheEntry = a1out.remove(fileId, pageIndex);
    if (cacheEntry != null) {

      OCachePointer dataPointer = writeCache.load(fileId, pageIndex);
View Full Code Here

Examples of com.orientechnologies.common.profiler.OProfilerMBean

    }
  }

  public void initProfiler() {
    if (storageName != null) {
      final OProfilerMBean profiler = Orient.instance().getProfiler();

      METRIC_HITS = profiler.getDatabaseMetric(storageName, "diskCache.hits");
      METRIC_HITS_METADATA = profiler.getDatabaseMetric(null, "diskCache.hits");
      METRIC_MISSED = profiler.getDatabaseMetric(storageName, "diskCache.missed");
      METRIC_MISSED_METADATA = profiler.getDatabaseMetric(null, "diskCache.missed");

      profiler.registerHookValue(profiler.getDatabaseMetric(storageName, "diskCache.totalMemory"),
          "Total memory used by Disk Cache", METRIC_TYPE.SIZE, new OProfilerHookValue() {
            @Override
            public Object getValue() {
              return (am.size() + a1in.size()) * pageSize;
            }
          }, profiler.getDatabaseMetric(null, "diskCache.totalMemory"));

      profiler.registerHookValue(profiler.getDatabaseMetric(storageName, "diskCache.maxMemory"),
          "Maximum memory used by Disk Cache", METRIC_TYPE.SIZE, new OProfilerHookValue() {
            @Override
            public Object getValue() {
              return maxSize * pageSize;
            }
          }, profiler.getDatabaseMetric(null, "diskCache.maxMemory"));
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.