All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.netflix.hystrix.metric.HystrixCommandEvent Maven / Gradle / Ivy

There is a newer version: 1.5.18
Show newest version
/**
 * Copyright 2015 Netflix, Inc.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.netflix.hystrix.metric;

import com.netflix.hystrix.HystrixCommandKey;
import com.netflix.hystrix.HystrixThreadPoolKey;
import rx.functions.Func1;

/**
 * Data class that comprises the event stream for Hystrix command executions.
 * As of 1.5.0-RC1, this is only {@link HystrixCommandCompletion}s.
 */
public abstract class HystrixCommandEvent implements HystrixEvent {
    private final HystrixCommandKey commandKey;
    private final HystrixThreadPoolKey threadPoolKey;

    protected HystrixCommandEvent(HystrixCommandKey commandKey, HystrixThreadPoolKey threadPoolKey) {
        this.commandKey = commandKey;
        this.threadPoolKey = threadPoolKey;
    }

    public HystrixCommandKey getCommandKey() {
        return commandKey;
    }

    public HystrixThreadPoolKey getThreadPoolKey() {
        return threadPoolKey;
    }

    public abstract boolean isExecutionStart();

    public abstract boolean isExecutedInThread();

    public abstract boolean isResponseThreadPoolRejected();

    public abstract boolean isCommandCompletion();

    public abstract boolean didCommandExecute();

    public static final Func1 filterCompletionsOnly = new Func1() {
        @Override
        public Boolean call(HystrixCommandEvent commandEvent) {
            return commandEvent.isCommandCompletion();
        }
    };

    public static final Func1 filterActualExecutions = new Func1() {
        @Override
        public Boolean call(HystrixCommandEvent commandEvent) {
            return commandEvent.didCommandExecute();
        }
    };
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy