Search in sources :

Example 1 with Stopwatch

use of com.netflix.servo.monitor.Stopwatch in project eureka by Netflix.

the class DiscoveryClient method fetchRegistry.

/**
     * Fetches the registry information.
     *
     * <p>
     * This method tries to get only deltas after the first fetch unless there
     * is an issue in reconciling eureka server and client registry information.
     * </p>
     *
     * @param forceFullRegistryFetch Forces a full registry fetch.
     *
     * @return true if the registry was fetched
     */
private boolean fetchRegistry(boolean forceFullRegistryFetch) {
    Stopwatch tracer = FETCH_REGISTRY_TIMER.start();
    try {
        // If the delta is disabled or if it is the first time, get all
        // applications
        Applications applications = getApplications();
        if (clientConfig.shouldDisableDelta() || (!Strings.isNullOrEmpty(clientConfig.getRegistryRefreshSingleVipAddress())) || forceFullRegistryFetch || (applications == null) || (applications.getRegisteredApplications().size() == 0) || //Client application does not have latest library supporting delta
        (applications.getVersion() == -1)) {
            logger.info("Disable delta property : {}", clientConfig.shouldDisableDelta());
            logger.info("Single vip registry refresh property : {}", clientConfig.getRegistryRefreshSingleVipAddress());
            logger.info("Force full registry fetch : {}", forceFullRegistryFetch);
            logger.info("Application is null : {}", (applications == null));
            logger.info("Registered Applications size is zero : {}", (applications.getRegisteredApplications().size() == 0));
            logger.info("Application version is -1: {}", (applications.getVersion() == -1));
            getAndStoreFullRegistry();
        } else {
            getAndUpdateDelta(applications);
        }
        applications.setAppsHashCode(applications.getReconcileHashCode());
        logTotalInstances();
    } catch (Throwable e) {
        logger.error(PREFIX + appPathIdentifier + " - was unable to refresh its cache! status = " + e.getMessage(), e);
        return false;
    } finally {
        if (tracer != null) {
            tracer.stop();
        }
    }
    // Notify about cache refresh before updating the instance remote status
    onCacheRefreshed();
    // Update remote status based on refreshed data held in the cache
    updateInstanceRemoteStatus();
    // registry was fetched successfully, so return true
    return true;
}
Also used : Applications(com.netflix.discovery.shared.Applications) Stopwatch(com.netflix.servo.monitor.Stopwatch)

Example 2 with Stopwatch

use of com.netflix.servo.monitor.Stopwatch in project eureka by Netflix.

the class AwsAsgUtil method isASGEnabledinAWS.

/**
     * Queries AWS to see if the load balancer flag is suspended.
     *
     * @param asgAccountid the accountId this asg resides in, if applicable (null will use the default accountId)
     * @param asgName the name of the asg
     * @return true, if the load balancer flag is not suspended, false otherwise.
     */
private Boolean isASGEnabledinAWS(String asgAccountid, String asgName) {
    try {
        Stopwatch t = this.loadASGInfoTimer.start();
        boolean returnValue = !isAddToLoadBalancerSuspended(asgAccountid, asgName);
        t.stop();
        return returnValue;
    } catch (Throwable e) {
        logger.error("Could not get ASG information from AWS: ", e);
    }
    return Boolean.TRUE;
}
Also used : Stopwatch(com.netflix.servo.monitor.Stopwatch)

Example 3 with Stopwatch

use of com.netflix.servo.monitor.Stopwatch in project eureka by Netflix.

the class ResponseCacheImpl method generatePayload.

/*
     * Generate pay load for the given key.
     */
private Value generatePayload(Key key) {
    Stopwatch tracer = null;
    try {
        String payload;
        switch(key.getEntityType()) {
            case Application:
                boolean isRemoteRegionRequested = key.hasRegions();
                if (ALL_APPS.equals(key.getName())) {
                    if (isRemoteRegionRequested) {
                        tracer = serializeAllAppsWithRemoteRegionTimer.start();
                        payload = getPayLoad(key, registry.getApplicationsFromMultipleRegions(key.getRegions()));
                    } else {
                        tracer = serializeAllAppsTimer.start();
                        payload = getPayLoad(key, registry.getApplications());
                    }
                } else if (ALL_APPS_DELTA.equals(key.getName())) {
                    if (isRemoteRegionRequested) {
                        tracer = serializeDeltaAppsWithRemoteRegionTimer.start();
                        versionDeltaWithRegions.incrementAndGet();
                        versionDeltaWithRegionsLegacy.incrementAndGet();
                        payload = getPayLoad(key, registry.getApplicationDeltasFromMultipleRegions(key.getRegions()));
                    } else {
                        tracer = serializeDeltaAppsTimer.start();
                        versionDelta.incrementAndGet();
                        versionDeltaLegacy.incrementAndGet();
                        payload = getPayLoad(key, registry.getApplicationDeltas());
                    }
                } else {
                    tracer = serializeOneApptimer.start();
                    payload = getPayLoad(key, registry.getApplication(key.getName()));
                }
                break;
            case VIP:
            case SVIP:
                tracer = serializeViptimer.start();
                payload = getPayLoad(key, getApplicationsForVip(key, registry));
                break;
            default:
                logger.error("Unidentified entity type: " + key.getEntityType() + " found in the cache key.");
                payload = "";
                break;
        }
        return new Value(payload);
    } finally {
        if (tracer != null) {
            tracer.stop();
        }
    }
}
Also used : Stopwatch(com.netflix.servo.monitor.Stopwatch)

Example 4 with Stopwatch

use of com.netflix.servo.monitor.Stopwatch in project ribbon by Netflix.

the class NamedConnectionPool method createEntry.

@Override
protected BasicPoolEntry createEntry(RouteSpecificPool rospl, ClientConnectionOperator op) {
    createEntryCounter.increment();
    Stopwatch stopWatch = creationTimer.start();
    try {
        return super.createEntry(rospl, op);
    } finally {
        stopWatch.stop();
    }
}
Also used : Stopwatch(com.netflix.servo.monitor.Stopwatch)

Example 5 with Stopwatch

use of com.netflix.servo.monitor.Stopwatch in project eureka by Netflix.

the class NamedConnectionPool method createEntry.

@Override
protected BasicPoolEntry createEntry(RouteSpecificPool rospl, ClientConnectionOperator op) {
    createEntryCounter.increment();
    Stopwatch stopWatch = creationTimer.start();
    try {
        return super.createEntry(rospl, op);
    } finally {
        stopWatch.stop();
    }
}
Also used : Stopwatch(com.netflix.servo.monitor.Stopwatch)

Aggregations

Stopwatch (com.netflix.servo.monitor.Stopwatch)9 Server (com.netflix.loadbalancer.Server)2 ClientException (com.netflix.client.ClientException)1 Applications (com.netflix.discovery.shared.Applications)1 ServerStats (com.netflix.loadbalancer.ServerStats)1 AbortExecutionException (com.netflix.loadbalancer.reactive.ExecutionListener.AbortExecutionException)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Observable (rx.Observable)1 Func1 (rx.functions.Func1)1