APISonar


org.apache.usergrid.persistence.core.metrics.ObservableTimer.time

> org > apache > usergrid > persistence > core > metrics > ObservableTimer > time
org APIs apache APIs usergrid APIs persistence APIs core APIs metrics APIs ObservableTimer APIs time APIs

Example 1
public Observable<String> getEdgeTypesToTarget( final SearchEdgeType search ) {
        final Observable<String> edgeTypes =
            Observable.create( new ObservableIterator<String>( "getEdgeTypesToTarget" ) {
                    @Override
                    protected Iterator<String> getIterator() {
                        return edgeMetadataSerialization.getEdgeTypesToTarget( scope, search );
                    }
                } );

        return ObservableTimer.time( edgeTypes, getEdgeTypesToTargetTimer );
    }
Example 2
public Observable<Id> getIdField( final String type, final Field field ) {
        final List<Field> fields = Collections.singletonList( field );
        final Observable<Id> idObservable = Observable.from( fields ).map( field1 -> {

            final UniqueValueSet set = uniqueValueSerializationStrategy.load( applicationScope, type, fields );
            final UniqueValue value = set.getValue( field1.getName() );
            return value == null ? null : value.getEntityId();

        } );

        return ObservableTimer.time( idObservable, fieldIdTimer );
    }
Example 3
public Observable<MarkedEdge> loadEdgesToTargetByType( final SearchByIdType search ) {
        final Observable<MarkedEdge> edges =
            Observable.create( new ObservableIterator<MarkedEdge>( "loadEdgesToTargetByType" ) {
                @Override
                protected Iterator<MarkedEdge> getIterator() {
                    return storageEdgeSerialization.getEdgesToTargetBySourceType( scope, search );
                }
            } ).buffer( graphFig.getScanPageSize() )
                      .compose( new EdgeBufferFilter(  search.filterMarked() ) );

        return ObservableTimer.time( edges, loadEdgesToTargetByTypeTimer );
    }
Example 4
public Observable<MarkedEdge> compactNode( final Id inputNode ) {

        final UUID startTime = UUIDGenerator.newTimeUUID();

        final Observable<MarkedEdge> nodeObservable =
            Observable.just( inputNode )
                .map( node -> nodeSerialization.getMaxVersion( scope, node ) )
                //.doOnNext(maxTimestamp -> logger.info("compactNode maxTimestamp={}", maxTimestamp.toString()))
                .takeWhile(maxTimestamp -> maxTimestamp.isPresent() )
                //map our delete listener
                .flatMap( timestamp -> nodeDeleteListener.receive( scope, inputNode, startTime ) );

        return ObservableTimer.time( nodeObservable, this.deleteNodeTimer );
    }
Example 5
public long getApplicationSize(ApplicationScope applicationScope) {
        final IndexLocationStrategy indexLocationStrategy = indexLocationStrategyFactory.getIndexLocationStrategy(applicationScope);
        EntityIndex entityIndex = entityIndexFactory.createEntityIndex(indexLocationStrategy);
        GraphManager graphManager = graphManagerFactory.createEdgeManager(applicationScope);
        Long sum = ObservableTimer.time(
            MathObservable.sumLong(
                graphManager.getEdgeTypesFromSource(new SimpleSearchEdgeType(applicationScope.getApplication(), CpNamingUtils.EDGE_COLL_PREFIX, Optional.<String>absent()))
                    .map(type -> CpNamingUtils.createCollectionSearchEdge(applicationScope.getApplication(), type))
                    .map(edge -> entityIndex.getTotalEntitySizeInBytes(edge))
            ), sumTimer).toBlocking().last();

        return sum.longValue();
    }
Example 6
public Observable<Id> mark(final Id entityId, String region) {

        Preconditions.checkNotNull( entityId, "Entity id is required in this stage" );
        Preconditions.checkNotNull( entityId.getUuid(), "Entity id is required in this stage" );
        Preconditions.checkNotNull( entityId.getType(), "Entity type is required in this stage" );

        Observable<Id> o = Observable.just( new CollectionIoEvent<>( applicationScope, entityId, region ) )
            .map( markStart ).doOnNext( markCommit ).compose( uniqueCleanup ).map(
                entityEvent -> entityEvent.getEvent().getId() );

        return ObservableTimer.time( o, deleteTimer );
    }