getExecutionEvents();
63 |
64 | int getNumberEmissions();
65 |
66 | int getNumberFallbackEmissions();
67 |
68 | int getNumberCollapsed();
69 |
70 | int getExecutionTimeInMilliseconds();
71 |
72 | long getCommandRunStartTimeInNanos();
73 |
74 | ExecutionResult.EventCounts getEventCounts();
75 | }
--------------------------------------------------------------------------------
/hystrix-core/src/main/java/com/netflix/hystrix/HystrixKey.java:
--------------------------------------------------------------------------------
1 | package com.netflix.hystrix;
2 |
3 | /**
4 | * Basic class for hystrix keys
5 | */
6 | public interface HystrixKey {
7 | /**
8 | * The word 'name' is used instead of 'key' so that Enums can implement this interface and it work natively.
9 | *
10 | * @return String
11 | */
12 | String name();
13 |
14 | /**
15 | * Default implementation of the interface
16 | */
17 | abstract class HystrixKeyDefault implements HystrixKey {
18 | private final String name;
19 |
20 | public HystrixKeyDefault(String name) {
21 | this.name = name;
22 | }
23 |
24 | @Override
25 | public String name() {
26 | return name;
27 | }
28 |
29 | @Override
30 | public String toString() {
31 | return name;
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/hystrix-core/src/main/java/com/netflix/hystrix/HystrixMetrics.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.netflix.hystrix;
17 |
18 | import com.netflix.hystrix.util.HystrixRollingNumber;
19 | import com.netflix.hystrix.util.HystrixRollingNumberEvent;
20 |
21 | /**
22 | * Abstract base class for Hystrix metrics
23 | */
24 | public abstract class HystrixMetrics {
25 |
26 | protected final HystrixRollingNumber counter;
27 |
28 | protected HystrixMetrics(HystrixRollingNumber counter) {
29 | this.counter = counter;
30 | }
31 | /**
32 | * Get the cumulative count since the start of the application for the given {@link HystrixRollingNumberEvent}.
33 | *
34 | * @param event
35 | * {@link HystrixRollingNumberEvent} of the event to retrieve a sum for
36 | * @return long cumulative count
37 | */
38 | public long getCumulativeCount(HystrixRollingNumberEvent event) {
39 | return counter.getCumulativeSum(event);
40 | }
41 |
42 | /**
43 | * Get the rolling count for the given {@link HystrixRollingNumberEvent}.
44 | *
45 | * The rolling window is defined by {@link HystrixCommandProperties#metricsRollingStatisticalWindowInMilliseconds()}.
46 | *
47 | * @param event
48 | * {@link HystrixRollingNumberEvent} of the event to retrieve a sum for
49 | * @return long rolling count
50 | */
51 | public long getRollingCount(HystrixRollingNumberEvent event) {
52 | return counter.getRollingSum(event);
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/hystrix-core/src/main/java/com/netflix/hystrix/collapser/CollapserTimer.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.netflix.hystrix.collapser;
17 |
18 | import java.lang.ref.Reference;
19 |
20 | import com.netflix.hystrix.util.HystrixTimer.TimerListener;
21 |
22 | /**
23 | * Timer used for trigger batch execution.
24 | */
25 | public interface CollapserTimer {
26 |
27 | public Reference addListener(TimerListener collapseTask);
28 | }
--------------------------------------------------------------------------------
/hystrix-core/src/main/java/com/netflix/hystrix/collapser/HystrixCollapserBridge.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.netflix.hystrix.collapser;
17 |
18 | import java.util.Collection;
19 |
20 | import rx.Observable;
21 |
22 | import com.netflix.hystrix.HystrixCollapser.CollapsedRequest;
23 | import com.netflix.hystrix.HystrixCollapserKey;
24 |
25 | /**
26 | * Bridge between HystrixCollapser and RequestCollapser to expose 'protected' and 'private' functionality across packages.
27 | *
28 | * @param
29 | * @param
30 | * @param
31 | */
32 | public interface HystrixCollapserBridge {
33 |
34 | Collection>> shardRequests(Collection> requests);
35 |
36 | Observable createObservableCommand(Collection> requests);
37 |
38 | Observable mapResponseToRequests(Observable batchResponse, Collection> requests);
39 |
40 | HystrixCollapserKey getCollapserKey();
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/hystrix-core/src/main/java/com/netflix/hystrix/collapser/README.txt:
--------------------------------------------------------------------------------
1 | ====
2 | Copyright 2016 Netflix, Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ====
16 |
17 | This package is not part of the public API and can change at any time. Do not rely upon any classes in this package.
18 |
19 | The public API is com.netflix.hystrix.HystrixCollapser
--------------------------------------------------------------------------------
/hystrix-core/src/main/java/com/netflix/hystrix/collapser/RealCollapserTimer.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.netflix.hystrix.collapser;
17 |
18 | import java.lang.ref.Reference;
19 |
20 | import com.netflix.hystrix.util.HystrixTimer;
21 | import com.netflix.hystrix.util.HystrixTimer.TimerListener;
22 |
23 | /**
24 | * Actual CollapserTimer implementation for triggering batch execution that uses HystrixTimer.
25 | */
26 | public class RealCollapserTimer implements CollapserTimer {
27 | /* single global timer that all collapsers will schedule their tasks on */
28 | private final static HystrixTimer timer = HystrixTimer.getInstance();
29 |
30 | @Override
31 | public Reference addListener(TimerListener collapseTask) {
32 | return timer.addTimerListener(collapseTask);
33 | }
34 |
35 | }
--------------------------------------------------------------------------------
/hystrix-core/src/main/java/com/netflix/hystrix/exception/ExceptionNotWrappedByHystrix.java:
--------------------------------------------------------------------------------
1 | package com.netflix.hystrix.exception;
2 |
3 | /**
4 | * Exceptions can implement this interface to prevent Hystrix from wrapping detected exceptions in a HystrixRuntimeException
5 | */
6 | public interface ExceptionNotWrappedByHystrix {
7 |
8 | }
9 |
--------------------------------------------------------------------------------
/hystrix-core/src/main/java/com/netflix/hystrix/exception/HystrixBadRequestException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.netflix.hystrix.exception;
17 |
18 | import com.netflix.hystrix.HystrixCommand;
19 |
20 | /**
21 | * An exception representing an error with provided arguments or state rather than an execution failure.
22 | *
23 | * Unlike all other exceptions thrown by a {@link HystrixCommand} this will not trigger fallback, not count against failure metrics and thus not trigger the circuit breaker.
24 | *
25 | * NOTE: This should only be used when an error is due to user input such as {@link IllegalArgumentException} otherwise it defeats the purpose of fault-tolerance and fallback behavior.
26 | */
27 | public class HystrixBadRequestException extends RuntimeException {
28 |
29 | private static final long serialVersionUID = -8341452103561805856L;
30 |
31 | public HystrixBadRequestException(String message) {
32 | super(message);
33 | }
34 |
35 | public HystrixBadRequestException(String message, Throwable cause) {
36 | super(message, cause);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/hystrix-core/src/main/java/com/netflix/hystrix/exception/HystrixTimeoutException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.netflix.hystrix.exception;
17 |
18 | import com.netflix.hystrix.HystrixCommand;
19 | import com.netflix.hystrix.HystrixObservableCommand;
20 |
21 | /**
22 | * An exception representing an error where the provided execution method took longer than the Hystrix timeout.
23 | *
24 | * Hystrix will trigger an exception of this type if it times out an execution. This class is public, so
25 | * user-defined execution methods ({@link HystrixCommand#run()} / {@link HystrixObservableCommand#construct()) may also
26 | * throw this error. If you want some types of failures to be counted as timeouts, you may wrap those failures in
27 | * a HystrixTimeoutException. See https://github.com/Netflix/Hystrix/issues/920 for more discussion.
28 | */
29 | public class HystrixTimeoutException extends Exception {
30 |
31 | private static final long serialVersionUID = -5085623652043595962L;
32 |
33 | }
34 |
35 |
--------------------------------------------------------------------------------
/hystrix-core/src/main/java/com/netflix/hystrix/exception/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * Custom exception implementations.
18 | *
19 | * @since 1.0.0
20 | */
21 | package com.netflix.hystrix.exception;
--------------------------------------------------------------------------------
/hystrix-core/src/main/java/com/netflix/hystrix/metric/HystrixEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.netflix.hystrix.metric;
17 |
18 | /**
19 | * Marker interface for events which may appear in an event stream
20 | */
21 | public interface HystrixEvent {
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/hystrix-core/src/main/java/com/netflix/hystrix/metric/HystrixEventStream.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.netflix.hystrix.metric;
17 |
18 | import rx.Observable;
19 |
20 | /**
21 | * Base interface for a stream of {@link com.netflix.hystrix.HystrixEventType}s. Allows consumption by individual
22 | * {@link com.netflix.hystrix.HystrixEventType} or by time-based bucketing of events
23 | */
24 | public interface HystrixEventStream {
25 |
26 | Observable observe();
27 | }
28 |
--------------------------------------------------------------------------------
/hystrix-core/src/main/java/com/netflix/hystrix/metric/HystrixRequestEventsStream.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.netflix.hystrix.metric;
17 |
18 | import com.netflix.hystrix.HystrixInvokableInfo;
19 | import rx.Observable;
20 | import rx.subjects.PublishSubject;
21 | import rx.subjects.Subject;
22 |
23 | import java.util.Collection;
24 |
25 | /**
26 | * Stream of requests, each of which contains a series of command executions
27 | */
28 | public class HystrixRequestEventsStream {
29 | private final Subject writeOnlyRequestEventsSubject;
30 | private final Observable readOnlyRequestEvents;
31 |
32 | /* package */ HystrixRequestEventsStream() {
33 | writeOnlyRequestEventsSubject = PublishSubject.create();
34 | readOnlyRequestEvents = writeOnlyRequestEventsSubject.onBackpressureBuffer(1024);
35 | }
36 |
37 | private static final HystrixRequestEventsStream INSTANCE = new HystrixRequestEventsStream();
38 |
39 | public static HystrixRequestEventsStream getInstance() {
40 | return INSTANCE;
41 | }
42 |
43 | public void shutdown() {
44 | writeOnlyRequestEventsSubject.onCompleted();
45 | }
46 |
47 | public void write(Collection> executions) {
48 | HystrixRequestEvents requestEvents = new HystrixRequestEvents(executions);
49 | writeOnlyRequestEventsSubject.onNext(requestEvents);
50 | }
51 |
52 | public Observable observe() {
53 | return readOnlyRequestEvents;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/hystrix-core/src/main/java/com/netflix/hystrix/metric/sample/HystrixCommandUtilization.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.netflix.hystrix.metric.sample;
17 |
18 | import com.netflix.hystrix.HystrixCommandMetrics;
19 |
20 | public class HystrixCommandUtilization {
21 | private final int concurrentCommandCount;
22 |
23 | public HystrixCommandUtilization(int concurrentCommandCount) {
24 | this.concurrentCommandCount = concurrentCommandCount;
25 | }
26 |
27 | public static HystrixCommandUtilization sample(HystrixCommandMetrics commandMetrics) {
28 | return new HystrixCommandUtilization(commandMetrics.getCurrentConcurrentExecutionCount());
29 | }
30 |
31 | public int getConcurrentCommandCount() {
32 | return concurrentCommandCount;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/hystrix-core/src/main/java/com/netflix/hystrix/metric/sample/HystrixUtilization.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.netflix.hystrix.metric.sample;
17 |
18 | import com.netflix.hystrix.HystrixCommandKey;
19 | import com.netflix.hystrix.HystrixThreadPoolKey;
20 |
21 | import java.util.Map;
22 |
23 | public class HystrixUtilization {
24 | private final Map commandUtilizationMap;
25 | private final Map threadPoolUtilizationMap;
26 |
27 | public HystrixUtilization(Map commandUtilizationMap, Map threadPoolUtilizationMap) {
28 | this.commandUtilizationMap = commandUtilizationMap;
29 | this.threadPoolUtilizationMap = threadPoolUtilizationMap;
30 | }
31 |
32 | public static HystrixUtilization from(Map commandUtilizationMap,
33 | Map threadPoolUtilizationMap) {
34 | return new HystrixUtilization(commandUtilizationMap, threadPoolUtilizationMap);
35 | }
36 |
37 | public Map getCommandUtilizationMap() {
38 | return commandUtilizationMap;
39 | }
40 |
41 | public Map getThreadPoolUtilizationMap() {
42 | return threadPoolUtilizationMap;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/hystrix-core/src/main/java/com/netflix/hystrix/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * Core functionality of Hystrix including the HystrixCommand and HystrixCollapser to be extended from.
18 | *
19 | * @since 1.0.0
20 | */
21 | package com.netflix.hystrix;
--------------------------------------------------------------------------------
/hystrix-core/src/main/java/com/netflix/hystrix/strategy/concurrency/HystrixConcurrencyStrategyDefault.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.netflix.hystrix.strategy.concurrency;
17 |
18 | /**
19 | * Default implementation of {@link HystrixConcurrencyStrategy} using standard java.util.concurrent.* implementations.
20 | *
21 | * @ExcludeFromJavadoc
22 | */
23 | public class HystrixConcurrencyStrategyDefault extends HystrixConcurrencyStrategy {
24 |
25 | private static HystrixConcurrencyStrategyDefault INSTANCE = new HystrixConcurrencyStrategyDefault();
26 |
27 | public static HystrixConcurrencyStrategy getInstance() {
28 | return INSTANCE;
29 | }
30 |
31 | private HystrixConcurrencyStrategyDefault() {
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/hystrix-core/src/main/java/com/netflix/hystrix/strategy/concurrency/HystrixRequestVariable.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.netflix.hystrix.strategy.concurrency;
17 |
18 | import com.netflix.hystrix.strategy.HystrixPlugins;
19 |
20 | /**
21 | * Interface for a variable similar to {@link ThreadLocal} but scoped at the user request level.
22 | *
23 | * Default implementation is {@link HystrixRequestVariableDefault} managed by {@link HystrixRequestContext}.
24 | *
25 | * Custom implementations can be injected using {@link HystrixPlugins} and {@link HystrixConcurrencyStrategy#getRequestVariable}.
26 | *
27 | * See JavaDoc of {@link HystrixRequestContext} for more information about functionality this enables and how to use the default implementation.
28 | *
29 | * @param
30 | * Type to be stored on the HystrixRequestVariable
31 | */
32 | public interface HystrixRequestVariable extends HystrixRequestVariableLifecycle {
33 |
34 | /**
35 | * Retrieve current value or initialize and then return value for this variable for the current request scope.
36 | *
37 | * @return T value of variable for current request scope.
38 | */
39 | public T get();
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/hystrix-core/src/main/java/com/netflix/hystrix/strategy/concurrency/HystrixRequestVariableLifecycle.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.netflix.hystrix.strategy.concurrency;
17 |
18 | /**
19 | * Interface for lifecycle methods that are then executed by an implementation of {@link HystrixRequestVariable}.
20 | *
21 | * @param
22 | */
23 | public interface HystrixRequestVariableLifecycle {
24 |
25 | /**
26 | * Invoked when {@link HystrixRequestVariable#get()} is first called.
27 | *
28 | * When using the default implementation this is invoked when {@link HystrixRequestVariableDefault#get()} is called.
29 | *
30 | * @return T with initial value or null if none.
31 | */
32 | public T initialValue();
33 |
34 | /**
35 | * Invoked when request scope is shutdown to allow for cleanup.
36 | *
37 | * When using the default implementation this is invoked when {@link HystrixRequestContext#shutdown()} is called.
38 | *
39 | * The {@link HystrixRequestVariable#get()} method should not be called from within this method as it will result in {@link #initialValue()} being called again.
40 | *
41 | * @param value
42 | * of request variable to allow cleanup activity.
43 | *
44 | * If nothing needs to be cleaned up then nothing needs to be done in this method.
45 | */
46 | public void shutdown(T value);
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/hystrix-core/src/main/java/com/netflix/hystrix/strategy/concurrency/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * Strategy definition for concurrency related behavior and default implementation.
18 | *
19 | * @since 1.0.0
20 | */
21 | package com.netflix.hystrix.strategy.concurrency;
--------------------------------------------------------------------------------
/hystrix-core/src/main/java/com/netflix/hystrix/strategy/eventnotifier/HystrixEventNotifierDefault.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.netflix.hystrix.strategy.eventnotifier;
17 |
18 |
19 | /**
20 | * Default implementations of {@link HystrixEventNotifier} that does nothing.
21 | *
22 | * @ExcludeFromJavadoc
23 | */
24 | public class HystrixEventNotifierDefault extends HystrixEventNotifier {
25 |
26 | private static HystrixEventNotifierDefault INSTANCE = new HystrixEventNotifierDefault();
27 |
28 | private HystrixEventNotifierDefault() {
29 |
30 | }
31 |
32 | public static HystrixEventNotifier getInstance() {
33 | return INSTANCE;
34 | }
35 |
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/hystrix-core/src/main/java/com/netflix/hystrix/strategy/eventnotifier/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * Strategy definition for event notification.
18 | *
19 | * @since 1.0.0
20 | */
21 | package com.netflix.hystrix.strategy.eventnotifier;
--------------------------------------------------------------------------------
/hystrix-core/src/main/java/com/netflix/hystrix/strategy/executionhook/HystrixCommandExecutionHookDefault.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.netflix.hystrix.strategy.executionhook;
17 |
18 | /**
19 | * Default implementations of {@link HystrixCommandExecutionHook} that does nothing.
20 | *
21 | * @ExcludeFromJavadoc
22 | */
23 | public class HystrixCommandExecutionHookDefault extends HystrixCommandExecutionHook {
24 |
25 | private static HystrixCommandExecutionHookDefault INSTANCE = new HystrixCommandExecutionHookDefault();
26 |
27 | private HystrixCommandExecutionHookDefault() {
28 |
29 | }
30 |
31 | public static HystrixCommandExecutionHook getInstance() {
32 | return INSTANCE;
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/hystrix-core/src/main/java/com/netflix/hystrix/strategy/executionhook/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * Strategy definition for execution hook.
18 | *
19 | * @since 1.2.0
20 | */
21 | package com.netflix.hystrix.strategy.executionhook;
--------------------------------------------------------------------------------
/hystrix-core/src/main/java/com/netflix/hystrix/strategy/metrics/HystrixMetricsPublisherCollapser.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.netflix.hystrix.strategy.metrics;
17 |
18 | import com.netflix.hystrix.HystrixCollapser;
19 |
20 | /**
21 | * Metrics publisher for a {@link HystrixCollapser} that will be constructed by an implementation of {@link HystrixMetricsPublisher}.
22 | *
23 | * Instantiation of implementations of this interface should NOT allocate resources that require shutdown, register listeners or other such global state changes.
24 | *
25 | * The initialize()
method will be called once-and-only-once to indicate when this instance can register with external services, start publishing metrics etc.
26 | *
27 | * Doing this logic in the constructor could result in memory leaks, double-publishing and other such behavior because this can be optimistically constructed more than once and "extras" discarded with
28 | * only one actually having initialize()
called on it.
29 | */
30 | public interface HystrixMetricsPublisherCollapser {
31 |
32 | // TODO should the arguments be given via initialize rather than constructor so people can't accidentally do it wrong?
33 |
34 | public void initialize();
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/hystrix-core/src/main/java/com/netflix/hystrix/strategy/metrics/HystrixMetricsPublisherCollapserDefault.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.netflix.hystrix.strategy.metrics;
17 |
18 | import com.netflix.hystrix.HystrixCollapserKey;
19 | import com.netflix.hystrix.HystrixCollapserMetrics;
20 | import com.netflix.hystrix.HystrixCollapserProperties;
21 |
22 | /**
23 | * Default implementation of {@link HystrixMetricsPublisherCollapser} that does nothing.
24 | *
25 | * See Wiki docs about plugins for more information.
26 | *
27 | * @ExcludeFromJavadoc
28 | */
29 | public class HystrixMetricsPublisherCollapserDefault implements HystrixMetricsPublisherCollapser {
30 |
31 | public HystrixMetricsPublisherCollapserDefault(HystrixCollapserKey collapserKey, HystrixCollapserMetrics metrics, HystrixCollapserProperties properties) {
32 | // do nothing by default
33 | }
34 |
35 | @Override
36 | public void initialize() {
37 | // do nothing by default
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/hystrix-core/src/main/java/com/netflix/hystrix/strategy/metrics/HystrixMetricsPublisherCommand.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.netflix.hystrix.strategy.metrics;
17 |
18 | import com.netflix.hystrix.HystrixCommand;
19 |
20 | /**
21 | * Metrics publisher for a {@link HystrixCommand} that will be constructed by an implementation of {@link HystrixMetricsPublisher}.
22 | *
23 | * Instantiation of implementations of this interface should NOT allocate resources that require shutdown, register listeners or other such global state changes.
24 | *
25 | * The initialize()
method will be called once-and-only-once to indicate when this instance can register with external services, start publishing metrics etc.
26 | *
27 | * Doing this logic in the constructor could result in memory leaks, double-publishing and other such behavior because this can be optimistically constructed more than once and "extras" discarded with
28 | * only one actually having initialize()
called on it.
29 | */
30 | public interface HystrixMetricsPublisherCommand {
31 |
32 | // TODO should the arguments be given via initialize rather than constructor so they can't accidentally do it wrong?
33 |
34 | public void initialize();
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/hystrix-core/src/main/java/com/netflix/hystrix/strategy/metrics/HystrixMetricsPublisherCommandDefault.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.netflix.hystrix.strategy.metrics;
17 |
18 | import com.netflix.hystrix.HystrixCircuitBreaker;
19 | import com.netflix.hystrix.HystrixCommandGroupKey;
20 | import com.netflix.hystrix.HystrixCommandKey;
21 | import com.netflix.hystrix.HystrixCommandMetrics;
22 | import com.netflix.hystrix.HystrixCommandProperties;
23 |
24 | /**
25 | * Default implementation of {@link HystrixMetricsPublisherCommand} that does nothing.
26 | *
27 | * See Wiki docs about plugins for more information.
28 | *
29 | * @ExcludeFromJavadoc
30 | */
31 | public class HystrixMetricsPublisherCommandDefault implements HystrixMetricsPublisherCommand {
32 |
33 | public HystrixMetricsPublisherCommandDefault(HystrixCommandKey commandKey, HystrixCommandGroupKey commandGroupKey, HystrixCommandMetrics metrics, HystrixCircuitBreaker circuitBreaker, HystrixCommandProperties properties) {
34 | // do nothing by default
35 | }
36 |
37 | @Override
38 | public void initialize() {
39 | // do nothing by default
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/hystrix-core/src/main/java/com/netflix/hystrix/strategy/metrics/HystrixMetricsPublisherDefault.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.netflix.hystrix.strategy.metrics;
17 |
18 | /**
19 | * Default implementation of {@link HystrixMetricsPublisher}.
20 | *
21 | * See Wiki docs about plugins for more information.
22 | *
23 | * @ExcludeFromJavadoc
24 | */
25 | public class HystrixMetricsPublisherDefault extends HystrixMetricsPublisher {
26 |
27 | private static HystrixMetricsPublisherDefault INSTANCE = new HystrixMetricsPublisherDefault();
28 |
29 | public static HystrixMetricsPublisher getInstance() {
30 | return INSTANCE;
31 | }
32 |
33 | private HystrixMetricsPublisherDefault() {
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/hystrix-core/src/main/java/com/netflix/hystrix/strategy/metrics/HystrixMetricsPublisherThreadPool.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.netflix.hystrix.strategy.metrics;
17 |
18 | import com.netflix.hystrix.HystrixThreadPool;
19 |
20 | /**
21 | * Metrics publisher for a {@link HystrixThreadPool} that will be constructed by an implementation of {@link HystrixMetricsPublisher}.
22 | *
23 | * Instantiation of implementations of this interface should NOT allocate resources that require shutdown, register listeners or other such global state changes.
24 | *
25 | * The initialize()
method will be called once-and-only-once to indicate when this instance can register with external services, start publishing metrics etc.
26 | *
27 | * Doing this logic in the constructor could result in memory leaks, double-publishing and other such behavior because this can be optimistically constructed more than once and "extras" discarded with
28 | * only one actually having initialize()
called on it.
29 | */
30 | public interface HystrixMetricsPublisherThreadPool {
31 |
32 | // TODO should the arguments be given via initialize rather than constructor so people can't accidentally do it wrong?
33 |
34 | public void initialize();
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/hystrix-core/src/main/java/com/netflix/hystrix/strategy/metrics/HystrixMetricsPublisherThreadPoolDefault.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.netflix.hystrix.strategy.metrics;
17 |
18 | import com.netflix.hystrix.HystrixThreadPoolKey;
19 | import com.netflix.hystrix.HystrixThreadPoolMetrics;
20 | import com.netflix.hystrix.HystrixThreadPoolProperties;
21 |
22 | /**
23 | * Default implementation of {@link HystrixMetricsPublisherThreadPool} that does nothing.
24 | *
25 | * See Wiki docs about plugins for more information.
26 | *
27 | * @ExcludeFromJavadoc
28 | */
29 | public class HystrixMetricsPublisherThreadPoolDefault implements HystrixMetricsPublisherThreadPool {
30 |
31 | public HystrixMetricsPublisherThreadPoolDefault(HystrixThreadPoolKey threadPoolKey, HystrixThreadPoolMetrics metrics, HystrixThreadPoolProperties properties) {
32 | // do nothing by default
33 | }
34 |
35 | @Override
36 | public void initialize() {
37 | // do nothing by default
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/hystrix-core/src/main/java/com/netflix/hystrix/strategy/metrics/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * Strategy definition for publishing metrics and default implementation.
18 | *
19 | * @since 1.0.0
20 | */
21 | package com.netflix.hystrix.strategy.metrics;
--------------------------------------------------------------------------------
/hystrix-core/src/main/java/com/netflix/hystrix/strategy/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * Parent package of strategies and plugin management.
18 | *
19 | * @since 1.0.0
20 | */
21 | package com.netflix.hystrix.strategy;
--------------------------------------------------------------------------------
/hystrix-core/src/main/java/com/netflix/hystrix/strategy/properties/HystrixDynamicProperty.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.netflix.hystrix.strategy.properties;
17 |
18 | /**
19 | * Generic interface to represent a dynamic property value so Hystrix can consume
20 | * properties without being tied to any particular backing implementation.
21 | *
22 | * @author agentgt
23 | *
24 | * @param
25 | * Type of property value.
26 | * @see HystrixProperty
27 | * @see HystrixDynamicProperties
28 | */
29 | public interface HystrixDynamicProperty extends HystrixProperty{
30 |
31 | public String getName();
32 |
33 | /**
34 | * Register a callback to be run if the property is updated.
35 | * Backing implementations may choose to do nothing.
36 | * @param callback callback.
37 | */
38 | public void addCallback(Runnable callback);
39 |
40 | }
--------------------------------------------------------------------------------
/hystrix-core/src/main/java/com/netflix/hystrix/strategy/properties/HystrixPropertiesCollapserDefault.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.netflix.hystrix.strategy.properties;
17 |
18 | import com.netflix.hystrix.HystrixCollapserKey;
19 | import com.netflix.hystrix.HystrixCollapserProperties;
20 |
21 | /**
22 | * Default implementation of {@link HystrixCollapserProperties} using Archaius (https://github.com/Netflix/archaius)
23 | *
24 | * @ExcludeFromJavadoc
25 | */
26 | public class HystrixPropertiesCollapserDefault extends HystrixCollapserProperties {
27 |
28 | public HystrixPropertiesCollapserDefault(HystrixCollapserKey collapserKey, Setter builder) {
29 | super(collapserKey, builder);
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/hystrix-core/src/main/java/com/netflix/hystrix/strategy/properties/HystrixPropertiesCommandDefault.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.netflix.hystrix.strategy.properties;
17 |
18 | import com.netflix.hystrix.HystrixCommandKey;
19 | import com.netflix.hystrix.HystrixCommandProperties;
20 |
21 | /**
22 | * Default implementation of {@link HystrixCommandProperties} using Archaius (https://github.com/Netflix/archaius)
23 | *
24 | * @ExcludeFromJavadoc
25 | */
26 | public class HystrixPropertiesCommandDefault extends HystrixCommandProperties {
27 |
28 | public HystrixPropertiesCommandDefault(HystrixCommandKey key, Setter builder) {
29 | super(key, builder);
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/hystrix-core/src/main/java/com/netflix/hystrix/strategy/properties/HystrixPropertiesStrategyDefault.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.netflix.hystrix.strategy.properties;
17 |
18 | /**
19 | * Default implementation of {@link HystrixPropertiesStrategy}.
20 | *
21 | * @ExcludeFromJavadoc
22 | */
23 | public class HystrixPropertiesStrategyDefault extends HystrixPropertiesStrategy {
24 |
25 | private final static HystrixPropertiesStrategyDefault INSTANCE = new HystrixPropertiesStrategyDefault();
26 |
27 | private HystrixPropertiesStrategyDefault() {
28 | }
29 |
30 | public static HystrixPropertiesStrategy getInstance() {
31 | return INSTANCE;
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/hystrix-core/src/main/java/com/netflix/hystrix/strategy/properties/HystrixPropertiesThreadPoolDefault.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.netflix.hystrix.strategy.properties;
17 |
18 | import com.netflix.hystrix.HystrixThreadPoolKey;
19 | import com.netflix.hystrix.HystrixThreadPoolProperties;
20 |
21 | /**
22 | * Default implementation of {@link HystrixThreadPoolProperties} using Archaius (https://github.com/Netflix/archaius)
23 | *
24 | * @ExcludeFromJavadoc
25 | */
26 | public class HystrixPropertiesThreadPoolDefault extends HystrixThreadPoolProperties {
27 |
28 | protected HystrixPropertiesThreadPoolDefault(HystrixThreadPoolKey key, Setter builder) {
29 | super(key, builder);
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/hystrix-core/src/main/java/com/netflix/hystrix/strategy/properties/HystrixPropertiesTimerThreadPoolDefault.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.netflix.hystrix.strategy.properties;
17 |
18 | import com.netflix.hystrix.HystrixTimerThreadPoolProperties;
19 |
20 | /**
21 | * Default implementation of {@link HystrixTimerThreadPoolProperties} using Archaius (https://github.com/Netflix/archaius)
22 | *
23 | * @ExcludeFromJavadoc
24 | */
25 | public class HystrixPropertiesTimerThreadPoolDefault extends HystrixTimerThreadPoolProperties {
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/hystrix-core/src/main/java/com/netflix/hystrix/strategy/properties/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * Strategy definition for properties and configuration and default implementation.
18 | *
19 | * @since 1.0.0
20 | */
21 | package com.netflix.hystrix.strategy.properties;
--------------------------------------------------------------------------------
/hystrix-core/src/main/java/com/netflix/hystrix/util/ExceptionThreadingUtility.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.netflix.hystrix.util;
17 |
18 | @Deprecated
19 | public class ExceptionThreadingUtility {
20 |
21 | @Deprecated //this functionality is no longer supported
22 | public static void attachCallingThreadStack(Throwable e) {
23 | //no-op now
24 | }
25 |
26 | @Deprecated //this functionality is no longer supported
27 | public static void assignCallingThread(Thread callingThread) {
28 | //no-op now
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/hystrix-core/src/main/java/com/netflix/hystrix/util/Exceptions.java:
--------------------------------------------------------------------------------
1 | package com.netflix.hystrix.util;
2 |
3 | import java.util.LinkedList;
4 | import java.util.List;
5 |
6 | public class Exceptions {
7 | private Exceptions() {
8 | }
9 |
10 | /**
11 | * Throws the argument, return-type is RuntimeException so the caller can use a throw statement break out of the method
12 | */
13 | public static RuntimeException sneakyThrow(Throwable t) {
14 | return Exceptions.doThrow(t);
15 | }
16 |
17 | private static T doThrow(Throwable ex) throws T {
18 | throw (T) ex;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/hystrix-core/src/main/java/com/netflix/hystrix/util/InternMap.java:
--------------------------------------------------------------------------------
1 | package com.netflix.hystrix.util;
2 |
3 | import java.util.concurrent.ConcurrentHashMap;
4 | import java.util.concurrent.ConcurrentMap;
5 |
6 | /**
7 | * Utility to have 'intern' - like functionality, which holds single instance of wrapper for a given key
8 | */
9 | public class InternMap {
10 | private final ConcurrentMap storage = new ConcurrentHashMap();
11 | private final ValueConstructor valueConstructor;
12 |
13 | public interface ValueConstructor {
14 | V create(K key);
15 | }
16 |
17 | public InternMap(ValueConstructor valueConstructor) {
18 | this.valueConstructor = valueConstructor;
19 | }
20 |
21 | public V interned(K key) {
22 | V existingKey = storage.get(key);
23 | V newKey = null;
24 | if (existingKey == null) {
25 | newKey = valueConstructor.create(key);
26 | existingKey = storage.putIfAbsent(key, newKey);
27 | }
28 | return existingKey != null ? existingKey : newKey;
29 | }
30 |
31 | public int size() {
32 | return storage.size();
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/hystrix-core/src/main/java/com/netflix/hystrix/util/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * Common utility classes.
18 | *
19 | * @since 1.0.0
20 | */
21 | package com.netflix.hystrix.util;
--------------------------------------------------------------------------------
/hystrix-core/src/test/java/com/netflix/hystrix/NotWrappedByHystrixTestException.java:
--------------------------------------------------------------------------------
1 | package com.netflix.hystrix;
2 |
3 | import com.netflix.hystrix.exception.ExceptionNotWrappedByHystrix;
4 |
5 | public class NotWrappedByHystrixTestException extends Exception implements ExceptionNotWrappedByHystrix {
6 | private static final long serialVersionUID = 1L;
7 |
8 | }
9 |
--------------------------------------------------------------------------------
/hystrix-core/src/test/java/com/netflix/hystrix/NotWrappedByHystrixTestRuntimeException.java:
--------------------------------------------------------------------------------
1 | package com.netflix.hystrix;
2 |
3 | import com.netflix.hystrix.exception.ExceptionNotWrappedByHystrix;
4 |
5 | public class NotWrappedByHystrixTestRuntimeException extends RuntimeException implements ExceptionNotWrappedByHystrix {
6 | private static final long serialVersionUID = 1L;
7 |
8 | public NotWrappedByHystrixTestRuntimeException() {
9 | super("Raw exception for TestHystrixCommand");
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/hystrix-core/src/test/java/com/netflix/hystrix/TestHystrixObservableCommand.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.netflix.hystrix;
17 |
18 | abstract public class TestHystrixObservableCommand extends HystrixObservableCommand implements AbstractTestHystrixCommand {
19 |
20 | private final TestCommandBuilder builder;
21 |
22 | public TestHystrixObservableCommand(TestCommandBuilder builder) {
23 | super(builder.owner, builder.dependencyKey, builder.threadPoolKey, builder.circuitBreaker, builder.threadPool,
24 | builder.commandPropertiesDefaults, builder.threadPoolPropertiesDefaults, builder.metrics,
25 | builder.fallbackSemaphore, builder.executionSemaphore, TEST_PROPERTIES_FACTORY, builder.executionHook);
26 | this.builder = builder;
27 | }
28 |
29 | public TestCommandBuilder getBuilder() {
30 | return builder;
31 | }
32 |
33 | static TestCommandBuilder testPropsBuilder() {
34 | return new TestCommandBuilder(HystrixCommandProperties.ExecutionIsolationStrategy.SEMAPHORE);
35 | }
36 |
37 | static TestCommandBuilder testPropsBuilder(HystrixCircuitBreakerTest.TestCircuitBreaker circuitBreaker) {
38 | return new TestCommandBuilder(HystrixCommandProperties.ExecutionIsolationStrategy.SEMAPHORE).setCircuitBreaker(circuitBreaker);
39 | }
40 |
41 | static TestCommandBuilder testPropsBuilder(HystrixCommandProperties.ExecutionIsolationStrategy isolationStrategy, HystrixCircuitBreakerTest.TestCircuitBreaker circuitBreaker) {
42 | return new TestCommandBuilder(isolationStrategy).setCircuitBreaker(circuitBreaker);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/hystrix-core/src/test/java/com/netflix/hystrix/util/ExceptionsTest.java:
--------------------------------------------------------------------------------
1 | package com.netflix.hystrix.util;
2 |
3 | import org.junit.Assert;
4 | import org.junit.Test;
5 |
6 | import java.io.IOException;
7 |
8 | import static org.junit.Assert.assertTrue;
9 | import static org.junit.Assert.fail;
10 |
11 | public class ExceptionsTest {
12 |
13 | @Test
14 | public void testCastOfException(){
15 | Exception exception = new IOException("simulated checked exception message");
16 | try{
17 | Exceptions.sneakyThrow(exception);
18 | fail();
19 | } catch(Exception e){
20 | assertTrue(e instanceof IOException);
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/hystrix-core/src/test/resources/FAKE_META_INF_SERVICES/com.netflix.hystrix.strategy.properties.HystrixDynamicProperties:
--------------------------------------------------------------------------------
1 | com.netflix.hystrix.strategy.HystrixPluginsTest$MockHystrixDynamicPropertiesTest
--------------------------------------------------------------------------------
/hystrix-core/src/test/resources/FAKE_META_INF_SERVICES/com.netflix.hystrix.strategy.properties.HystrixDynamicPropertiesFail:
--------------------------------------------------------------------------------
1 | FAILDONOTWORK
--------------------------------------------------------------------------------
/hystrix-examples-webapp/README.md:
--------------------------------------------------------------------------------
1 | # hystrix-examples-webapp
2 |
3 | Web application that demonstrates functionality from [hystrix-examples](https://github.com/Netflix/Hystrix/tree/master/hystrix-examples) and functionality from [hystrix-request-servlet](https://github.com/Netflix/Hystrix/tree/master/hystrix-contrib/hystrix-request-servlet) and [hystrix-metrics-event-stream](https://github.com/Netflix/Hystrix/tree/master/hystrix-contrib/hystrix-metrics-event-stream).
4 |
5 | The [hystrix-dashboard](https://github.com/Netflix/Hystrix/tree/master/hystrix-dashboard) can be used on this example app to monitor its metrics.
6 |
7 | # Run via Gradle
8 |
9 | ```
10 | $ git clone git@github.com:Netflix/Hystrix.git
11 | $ cd Hystrix/hystrix-examples-webapp
12 | $ ../gradlew appRun
13 | > Building > :hystrix-examples-webapp:appRun > Running at http://localhost:8989/hystrix-examples-webapp
14 | ```
15 |
16 | Once running, open http://localhost:8989/hystrix-examples-webapp.
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/hystrix-examples-webapp/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories {
3 | maven {
4 | url "https://plugins.gradle.org/m2/"
5 | }
6 | }
7 | dependencies {
8 | classpath "org.gretty:gretty:3.0.5"
9 | }
10 | }
11 |
12 | apply plugin: "org.gretty"
13 | apply plugin: 'war'
14 |
15 |
16 | dependencies {
17 | api project(':hystrix-core')
18 | api project(':hystrix-examples')
19 | api project(':hystrix-request-servlet')
20 | api project(':hystrix-metrics-event-stream')
21 | }
22 |
23 | gretty {
24 | httpPort = 8989
25 | servletContainer = 'jetty9'
26 | }
27 |
--------------------------------------------------------------------------------
/hystrix-examples-webapp/src/main/webapp/WEB-INF/classes/log4j.properties:
--------------------------------------------------------------------------------
1 | log4j.rootLogger=INFO, FILE
2 | log4j.appender.FILE=org.apache.log4j.ConsoleAppender
3 | log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
4 | log4j.appender.FILE.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %p %C:%L [%C{1}] [%M]: %m%n
5 |
6 | log4j.appender.FILE.httpclient=ERROR
7 |
--------------------------------------------------------------------------------
/hystrix-examples/build.gradle:
--------------------------------------------------------------------------------
1 | dependencies {
2 | api project(':hystrix-core')
3 | compileOnly 'junit:junit-dep:4.10'
4 | }
5 |
6 | task(runDemo, dependsOn: 'classes', type: JavaExec) {
7 | main = 'com.netflix.hystrix.examples.demo.HystrixCommandDemo'
8 | classpath = sourceSets.main.runtimeClasspath
9 | }
10 |
--------------------------------------------------------------------------------
/hystrix-examples/src/main/java/com/netflix/hystrix/examples/basic/CommandUsingSemaphoreIsolation.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.netflix.hystrix.examples.basic;
17 |
18 | import com.netflix.hystrix.HystrixCommand;
19 | import com.netflix.hystrix.HystrixCommandGroupKey;
20 | import com.netflix.hystrix.HystrixCommandProperties;
21 | import com.netflix.hystrix.HystrixCommandProperties.ExecutionIsolationStrategy;
22 |
23 | /**
24 | * Example of {@link HystrixCommand} defaulting to use a semaphore isolation strategy
25 | * when its run() method will not perform network traffic.
26 | */
27 | public class CommandUsingSemaphoreIsolation extends HystrixCommand {
28 |
29 | private final int id;
30 |
31 | public CommandUsingSemaphoreIsolation(int id) {
32 | super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("ExampleGroup"))
33 | // since we're doing work in the run() method that doesn't involve network traffic
34 | // and executes very fast with low risk we choose SEMAPHORE isolation
35 | .andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
36 | .withExecutionIsolationStrategy(ExecutionIsolationStrategy.SEMAPHORE)));
37 | this.id = id;
38 | }
39 |
40 | @Override
41 | protected String run() {
42 | // a real implementation would retrieve data from in memory data structure
43 | // or some other similar non-network involved work
44 | return "ValueFromHashMap_" + id;
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/hystrix-examples/src/main/java/com/netflix/hystrix/examples/demo/Order.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.netflix.hystrix.examples.demo;
17 |
18 | import java.net.HttpCookie;
19 |
20 | /**
21 | * POJO
22 | */
23 | public class Order {
24 |
25 | private final int orderId;
26 | private UserAccount user;
27 |
28 | public Order(int orderId) {
29 | this.orderId = orderId;
30 |
31 | /* a contrived example of calling GetUserAccount again */
32 | user = new GetUserAccountCommand(new HttpCookie("mockKey", "mockValueFromHttpRequest")).execute();
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/hystrix-examples/src/main/java/com/netflix/hystrix/examples/demo/PaymentInformation.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.netflix.hystrix.examples.demo;
17 |
18 | /**
19 | * POJO
20 | */
21 | public class PaymentInformation {
22 |
23 | private final UserAccount user;
24 | private final String creditCardNumber;
25 | private final int expirationMonth;
26 | private final int expirationYear;
27 |
28 | public PaymentInformation(UserAccount user, String creditCardNumber, int expirationMonth, int expirationYear) {
29 | this.user = user;
30 | this.creditCardNumber = creditCardNumber;
31 | this.expirationMonth = expirationMonth;
32 | this.expirationYear = expirationYear;
33 | }
34 |
35 | public String getCreditCardNumber() {
36 | return creditCardNumber;
37 | }
38 |
39 | public int getExpirationMonth() {
40 | return expirationMonth;
41 | }
42 |
43 | public int getExpirationYear() {
44 | return expirationYear;
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/hystrix-examples/src/main/java/com/netflix/hystrix/examples/demo/UserAccount.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2012 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.netflix.hystrix.examples.demo;
17 |
18 | /**
19 | * Simple POJO to represent a user and their metadata.
20 | */
21 | public class UserAccount {
22 |
23 | private final int userId;
24 | private final String name;
25 | private final int accountType;
26 | private final boolean isFeatureXenabled;
27 | private final boolean isFeatureYenabled;
28 | private final boolean isFeatureZenabled;
29 |
30 | public UserAccount(int userId, String name, int accountType, boolean x, boolean y, boolean z) {
31 | this.userId = userId;
32 | this.name = name;
33 | this.accountType = accountType;
34 | this.isFeatureXenabled = x;
35 | this.isFeatureYenabled = y;
36 | this.isFeatureZenabled = z;
37 | }
38 |
39 | public int getUserId() {
40 | return userId;
41 | }
42 |
43 | public String getName() {
44 | return name;
45 | }
46 |
47 | public int getAccountType() {
48 | return accountType;
49 | }
50 |
51 | public boolean isFeatureXenabled() {
52 | return isFeatureXenabled;
53 | }
54 |
55 | public boolean isFeatureYenabled() {
56 | return isFeatureYenabled;
57 | }
58 |
59 | public boolean isFeatureZenabled() {
60 | return isFeatureZenabled;
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/hystrix-serialization/build.gradle:
--------------------------------------------------------------------------------
1 | repositories {
2 | mavenCentral()
3 | }
4 |
5 |
6 | dependencies {
7 | api project(':hystrix-core')
8 |
9 | //if we bump into the the 2.8.0 series, we are forced to use Java7
10 | api 'com.fasterxml.jackson.core:jackson-core:2.7.5'
11 | api 'com.fasterxml.jackson.core:jackson-databind:2.7.5'
12 | api 'com.fasterxml.jackson.core:jackson-annotations:2.7.5'
13 | implementation 'com.fasterxml.jackson.module:jackson-module-afterburner:2.7.5'
14 |
15 | testImplementation 'junit:junit-dep:4.10'
16 | testImplementation 'org.mockito:mockito-all:1.9.5'
17 | testImplementation project(':hystrix-core').sourceSets.test.output
18 | testImplementation project(':hystrix-junit')
19 | }
20 |
--------------------------------------------------------------------------------
/hystrix-serialization/src/main/java/com/netflix/hystrix/serial/SerialHystrixMetric.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.netflix.hystrix.serial;
17 |
18 | import com.fasterxml.jackson.core.JsonFactory;
19 | import com.fasterxml.jackson.databind.ObjectMapper;
20 | import org.slf4j.Logger;
21 | import org.slf4j.LoggerFactory;
22 |
23 | import java.nio.ByteBuffer;
24 |
25 | public class SerialHystrixMetric {
26 | protected final static JsonFactory jsonFactory = new JsonFactory();
27 | protected final static ObjectMapper mapper = new ObjectMapper();
28 | protected final static Logger logger = LoggerFactory.getLogger(SerialHystrixMetric.class);
29 |
30 | @Deprecated
31 | public static String fromByteBufferToString(ByteBuffer bb) {
32 | throw new UnsupportedOperationException("Not implemented anymore. Will be implemented in a new class shortly");
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name='hystrix'
2 | include 'hystrix-core', \
3 | 'hystrix-examples', \
4 | 'hystrix-examples-webapp', \
5 | 'hystrix-contrib/hystrix-clj', \
6 | 'hystrix-contrib/hystrix-request-servlet', \
7 | 'hystrix-contrib/hystrix-servo-metrics-publisher', \
8 | 'hystrix-contrib/hystrix-metrics-event-stream', \
9 | 'hystrix-contrib/hystrix-metrics-event-stream-jaxrs', \
10 | 'hystrix-contrib/hystrix-rx-netty-metrics-stream', \
11 | 'hystrix-contrib/hystrix-codahale-metrics-publisher', \
12 | 'hystrix-contrib/hystrix-yammer-metrics-publisher', \
13 | 'hystrix-contrib/hystrix-network-auditor-agent', \
14 | 'hystrix-contrib/hystrix-javanica', \
15 | 'hystrix-contrib/hystrix-junit', \
16 | 'hystrix-serialization'
17 |
18 | project(':hystrix-contrib/hystrix-clj').name = 'hystrix-clj'
19 | project(':hystrix-contrib/hystrix-request-servlet').name = 'hystrix-request-servlet'
20 | project(':hystrix-contrib/hystrix-servo-metrics-publisher').name = 'hystrix-servo-metrics-publisher'
21 | project(':hystrix-contrib/hystrix-metrics-event-stream').name = 'hystrix-metrics-event-stream'
22 | project(':hystrix-contrib/hystrix-metrics-event-stream-jaxrs').name = 'hystrix-metrics-event-stream-jaxrs'
23 | project(':hystrix-contrib/hystrix-rx-netty-metrics-stream').name = 'hystrix-rx-netty-metrics-stream'
24 | project(':hystrix-contrib/hystrix-codahale-metrics-publisher').name = 'hystrix-codahale-metrics-publisher'
25 | project(':hystrix-contrib/hystrix-yammer-metrics-publisher').name = 'hystrix-yammer-metrics-publisher'
26 | project(':hystrix-contrib/hystrix-network-auditor-agent').name = 'hystrix-network-auditor-agent'
27 | project(':hystrix-contrib/hystrix-javanica').name = 'hystrix-javanica'
28 | project(':hystrix-contrib/hystrix-junit').name = 'hystrix-junit'
29 |
--------------------------------------------------------------------------------