This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
proxy: | |
secretToken: 3cfc2a39118d182c5f5a4f7206ff5bf158e72bbfac83e8e8b97a4bc908032c7d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void saveToCache(Movie movie) { | |
List<String> cacheableModel = new ArrayList<>(); | |
String cacheKey; | |
for (Field field : movie.class.getDeclaredFields()) { | |
if (field.isAnnotationPresent(Cached.class)) { | |
field.setAccessible(true); | |
cacheableModel.add(field.get(movie)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HystrixHook extends HystrixCommandExecutionHook { | |
private HystrixRequestVariableDefault<Integer> hrv = new HystrixRequestVariableDefault<>(); | |
@Override | |
public <T> void onStart(HystrixInvokable<T> commandInstance) { | |
HystrixRequestContext.initializeContext(); | |
getThreadLocals(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Buggy code | |
public class HystrixHook extends HystrixCommandExecutionHook { | |
private Integer id; | |
@Override | |
public <T> void onStart(HystrixInvokable<T> commandInstance) { | |
getThreadLocals(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ThreadLocalUtil { | |
private static ThreadLocal<Integer> idTL = new ThreadLocal<>(); | |
public static void setId(Integer id) { | |
idTL.set(id); | |
} | |
public static void getId() { | |
idTL.get(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Reason | Fallback running thread | |
---|---|---|
Fallback from exception | On hystrix-thread | |
Fallback from timeout | On hystrix-timer-thread | |
Fallback on open circuit | On calling thread |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BookMyMovie { | |
public static void main (String[] args) throws Exception { | |
// List<Movie> movies = List of movies | |
Filter horrorMovieFilter = (movie) -> movie.getGenre().equals(MovieType.HORROR); | |
for (Movie movie : movies) { | |
System.out.println("Movie: " + movie.getName() + " is Horror? " + horrorMovieFilter.isApplicable(movie)); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Movie { | |
private MovieType genre; | |
private Double price; | |
public MovieType getGenre() { return genre; } | |
public void setGenre(MovieType genre) { this.genre = genre; } | |
public Double getPrice() { return price; } | |
public void setPrice(Double price) { this.price = price; } | |
enum MovieType { |