Skip to content

Commit

Permalink
Merge pull request #12 from mattrjacobs/upgrade_jars
Browse files Browse the repository at this point in the history
Updated RxJava/Hystrix/RxNetty jars
  • Loading branch information
mattrjacobs committed Feb 25, 2015
2 parents 952362b + b55da20 commit f9b70f5
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 27 deletions.
6 changes: 3 additions & 3 deletions reactive-lab-gateway/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

dependencies {
compile 'io.reactivex:rxnetty:0.4.0'
compile 'io.reactivex:rxjava:1.0.0'
compile 'io.reactivex:rxnetty:0.4.6'
compile 'io.reactivex:rxjava:1.0.7'
compile "com.netflix.eureka2:eureka-client:2.0.0-DP2"
compile "com.netflix.ocelli:ocelli-rxnetty:0.0.5"
compile "com.netflix.ocelli:ocelli-eureka:0.0.5"
compile('com.netflix.hystrix:hystrix-core:1.4.0-RC5') {
compile('com.netflix.hystrix:hystrix-core:1.4.0-rc.9') {
exclude group: 'com.netflix.rxjava', module: 'rxjava-core'
}
compile 'org.codehaus.jackson:jackson-core-asl:1.9.13'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public BookmarksCommand(List<Video> videos, LoadBalancer<HttpClientHolder<ByteBu
}

@Override
public Observable<Bookmark> run() {
public Observable<Bookmark> construct() {
HttpClientRequest<ByteBuf> request = HttpClientRequest.createGet("/bookmarks?" + UrlGenerator.generate("videoId", videos));
return loadBalancer.choose()
.map(holder -> holder.getClient())
Expand All @@ -44,7 +44,7 @@ public Observable<Bookmark> run() {
.retry(1);
}

protected Observable<Bookmark> getFallback() {
protected Observable<Bookmark> resumeWithFallback() {
List<Bookmark> bs = new ArrayList<>();
for (Video v : videos) {
Map<String, Object> data = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public GeoCommand(List<String> ips) {
}

@Override
protected Observable<GeoIP> run() {
protected Observable<GeoIP> construct() {
HttpClientRequest<ByteBuf> request = HttpClientRequest.createGet("/geo?" + UrlGenerator.generate("ip", ips));
return loadBalancer.choose()
.map(holder -> holder.getClient())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,22 @@ public MockServiceCommand(long id, int numItems, int itemSize, int delay) {
.andCommandKey(HystrixCommandKey.Factory.asKey("MiddleTier"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withExecutionIsolationSemaphoreMaxConcurrentRequests(5)
.withExecutionIsolationThreadTimeoutInMilliseconds(200))); // change this timeout to <= 80 to see fallbacks
.withExecutionTimeoutInMilliseconds(200))); // change this timeout to <= 80 to see fallbacks
this.id = id;
this.numItems = numItems;
this.itemSize = itemSize;
this.delay = delay;
}

@Override
protected Observable<BackendResponse> run() {
protected Observable<BackendResponse> construct() {
return RxNetty.createHttpClient("localhost", 9100)
.submit(HttpClientRequest.createGet("/mock.json?numItems=" + numItems + "&itemSize=" + itemSize + "&delay=" + delay + "&id=" + id))
.flatMap((HttpClientResponse<ByteBuf> r) -> r.getContent().map(b -> BackendResponse.fromJson(new ByteBufInputStream(b))));
}

protected Observable<BackendResponse> getFallback() {
@Override
protected Observable<BackendResponse> resumeWithFallback() {
return Observable.just(new BackendResponse(0, delay, numItems, itemSize, new String[] {}));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public PersonalizedCatalogCommand(List<User> users) {
}

@Override
protected Observable<Catalog> run() {
protected Observable<Catalog> construct() {
HttpClientRequest<ByteBuf> request = HttpClientRequest.createGet("/catalog?" + UrlGenerator.generate("userId", users));
return loadBalancer.choose()
.map(holder -> holder.getClient())
Expand All @@ -47,7 +47,7 @@ protected Observable<Catalog> run() {
}

@Override
protected Observable<Catalog> getFallback() {
protected Observable<Catalog> resumeWithFallback() {
return Observable.from(users).<Catalog>map(u -> {
try {
Map<String, Object> userData = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public RatingsCommand(List<Video> videos) {
}

@Override
protected Observable<Rating> run() {
protected Observable<Rating> construct() {
HttpClientRequest<ByteBuf> request = HttpClientRequest.createGet("/ratings?" + UrlGenerator.generate("videoId", videos));
return loadBalancer.choose()
.map(holder -> holder.getClient())
Expand All @@ -46,7 +46,7 @@ protected Observable<Rating> run() {
}

@Override
protected Observable<Rating> getFallback() {
protected Observable<Rating> resumeWithFallback() {
Map<String, Object> video = new HashMap<>();
video.put("videoId", videos.get(0).getId());
video.put("estimated_user_rating", 3.5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public SocialCommand(List<User> users) {
}

@Override
protected Observable<Social> run() {
protected Observable<Social> construct() {
HttpClientRequest<ByteBuf> request = HttpClientRequest.createGet("/social?" + UrlGenerator.generate("userId", users));
return loadBalancer.choose().map(holder -> holder.getClient())
.<Social>flatMap(client -> client.submit(request)
Expand All @@ -49,7 +49,7 @@ protected Observable<Social> run() {
}

@Override
protected Observable<Social> getFallback() {
protected Observable<Social> resumeWithFallback() {
Map<String, Object> user = new HashMap<>();
user.put("userId", users.get(0).getId());
user.put("friends", Collections.emptyList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public UserCommand(List<String> userIds) {
}

@Override
protected Observable<User> run() {
protected Observable<User> construct() {
HttpClientRequest<ByteBuf> request = HttpClientRequest.createGet("/user?" + UrlGenerator.generate("userId", userIds));
return loadBalancer.choose().map(holder -> holder.getClient())
.<User>flatMap(client -> client.submit(request)
Expand All @@ -42,7 +42,7 @@ protected Observable<User> run() {
}

@Override
protected Observable<User> getFallback() {
protected Observable<User> resumeWithFallback() {
return Observable.from(userIds).map(id -> {
Map<String, Object> fallback = new HashMap<>();
fallback.put("userId", id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public VideoMetadataCommand(List<Video> videos) {
}

@Override
protected Observable<VideoMetadata> run() {
protected Observable<VideoMetadata> construct() {
HttpClientRequest<ByteBuf> request = HttpClientRequest.createGet("/metadata?" + UrlGenerator.generate("videoId",
videos));
return loadBalancer.choose()
Expand All @@ -48,7 +48,7 @@ protected Observable<VideoMetadata> run() {
}

@Override
protected Observable<VideoMetadata> getFallback() {
protected Observable<VideoMetadata> resumeWithFallback() {
Map<String, Object> video = new HashMap<>();
video.put("videoId", videos.get(0).getId());
video.put("title", "Fallback Video Title");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ static String toJson(HystrixCommandMetrics commandMetrics) throws IOException {
json.writeBooleanField("propertyValue_circuitBreakerEnabled", commandProperties.circuitBreakerEnabled().get());

json.writeStringField("propertyValue_executionIsolationStrategy", commandProperties.executionIsolationStrategy().get().name());
json.writeNumberField("propertyValue_executionIsolationThreadTimeoutInMilliseconds", commandProperties.executionIsolationThreadTimeoutInMilliseconds().get());
json.writeNumberField("propertyValue_executionTimeoutInMilliseconds", commandProperties.executionTimeoutInMilliseconds().get());
json.writeBooleanField("propertyValue_executionIsolationThreadInterruptOnTimeout", commandProperties.executionIsolationThreadInterruptOnTimeout().get());
json.writeStringField("propertyValue_executionIsolationThreadPoolKeyOverride", commandProperties.executionIsolationThreadPoolKeyOverride().get());
json.writeNumberField("propertyValue_executionIsolationSemaphoreMaxConcurrentRequests", commandProperties.executionIsolationSemaphoreMaxConcurrentRequests().get());
Expand Down
4 changes: 2 additions & 2 deletions reactive-lab-services/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

dependencies {
compile 'io.reactivex:rxnetty:0.4.0'
compile 'io.reactivex:rxjava:1.0.0'
compile 'io.reactivex:rxnetty:0.4.6'
compile 'io.reactivex:rxjava:1.0.7'
compile('com.netflix.eureka2:eureka-write-server:2.0.0-DP2') {
exclude group: 'com.netflix.rxnetty', module: 'rx-netty'
}
Expand Down
6 changes: 3 additions & 3 deletions reactive-lab-tutorial/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ dependencies {
}
compile "com.netflix.ocelli:ocelli-rxnetty:0.0.5"
compile "com.netflix.ocelli:ocelli-eureka:0.0.5"
compile('com.netflix.hystrix:hystrix-core:1.4.0-RC5') {
compile('com.netflix.hystrix:hystrix-core:1.4.0-rc.9') {
exclude group: 'com.netflix.rxjava', module: 'rxjava-core'
}

compile 'io.reactivex:rxnetty:0.4.0'
compile 'io.reactivex:rxjava:1.0.0'
compile 'io.reactivex:rxnetty:0.4.6'
compile 'io.reactivex:rxjava:1.0.7'
compile 'org.codehaus.jackson:jackson-core-asl:1.9.13'
compile 'org.codehaus.jackson:jackson-mapper-asl:1.9.13'
testCompile 'junit:junit-dep:4.10'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public MyCommand(Observable<MembershipEvent<Host>> eurekaHostSource) {
}

@Override
protected Observable<String> run() {
protected Observable<String> construct() {
return ClientServerWithLoadBalancer.createRequestFromLB(eurekaHostSource)
/**
* Artificial delay to demonstrate hystrix timeouts and fallbacks.
Expand All @@ -92,7 +92,7 @@ protected Observable<String> run() {
}

@Override
protected Observable<String> getFallback() {
protected Observable<String> resumeWithFallback() {
return Observable.just("Fallback from Hystrix.");
}
}
Expand Down

0 comments on commit f9b70f5

Please sign in to comment.