forked from Netflix/Hystrix
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3bf3126
commit 206d2a2
Showing
10 changed files
with
285 additions
and
6 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Wed Dec 02 15:47:21 PST 2015 | ||
#Thu May 19 16:56:49 PDT 2016 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip |
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
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
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
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
8 changes: 8 additions & 0 deletions
8
...-stream/src/test/java/com/netflix/hystrix/contrib/reactivesocket/EventStreamEnumTest.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.netflix.hystrix.contrib.reactivesocket; | ||
|
||
|
||
public class EventStreamEnumTest { | ||
public void test() { | ||
|
||
} | ||
} |
111 changes: 111 additions & 0 deletions
111
...c/test/java/com/netflix/hystrix/contrib/reactivesocket/EventStreamRequestHandlerTest.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
package com.netflix.hystrix.contrib.reactivesocket; | ||
|
||
|
||
import com.netflix.hystrix.HystrixCommand; | ||
import com.netflix.hystrix.HystrixCommandGroupKey; | ||
import io.reactivesocket.Frame; | ||
import io.reactivesocket.Payload; | ||
import org.agrona.BitUtil; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.reactivestreams.Publisher; | ||
import org.reactivestreams.Subscriber; | ||
import org.reactivestreams.Subscription; | ||
import rx.schedulers.Schedulers; | ||
|
||
import java.nio.ByteBuffer; | ||
import java.util.concurrent.CountDownLatch; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.concurrent.atomic.AtomicReference; | ||
|
||
public class EventStreamRequestHandlerTest { | ||
@Test | ||
public void testEventStream() throws Exception { | ||
Payload payload = new Payload() { | ||
@Override | ||
public ByteBuffer getData() { | ||
return ByteBuffer | ||
.allocate(BitUtil.SIZE_OF_INT) | ||
.putInt(EventStreamEnum.METRICS_STREAM.getTypeId()); | ||
} | ||
|
||
@Override | ||
public ByteBuffer getMetadata() { | ||
return Frame.NULL_BYTEBUFFER; | ||
} | ||
}; | ||
|
||
Schedulers | ||
.io() | ||
.createWorker() | ||
.schedulePeriodically(() -> { | ||
TestCommand testCommand = new TestCommand(); | ||
testCommand.execute(); | ||
}, 0, 1, TimeUnit.MILLISECONDS); | ||
|
||
CountDownLatch latch = new CountDownLatch(1); | ||
CountDownLatch latch1 = new CountDownLatch(5); | ||
CountDownLatch latch2 = new CountDownLatch(15); | ||
|
||
AtomicReference<Subscription> subscriptionAtomicReference = new AtomicReference<>(); | ||
|
||
EventStreamRequestHandler handler = new EventStreamRequestHandler(); | ||
Publisher<Payload> payloadPublisher = handler.handleSubscription(payload); | ||
|
||
payloadPublisher | ||
.subscribe(new Subscriber<Payload>() { | ||
@Override | ||
public void onSubscribe(Subscription s) { | ||
subscriptionAtomicReference.set(s); | ||
latch.countDown(); | ||
} | ||
|
||
@Override | ||
public void onNext(Payload payload) { | ||
ByteBuffer data = payload.getData(); | ||
String s = new String(data.array()); | ||
|
||
System.out.println(s); | ||
|
||
latch1.countDown(); | ||
latch2.countDown(); | ||
} | ||
|
||
@Override | ||
public void onError(Throwable t) { | ||
|
||
} | ||
|
||
@Override | ||
public void onComplete() { | ||
|
||
} | ||
}); | ||
|
||
latch.await(); | ||
|
||
Subscription subscription = subscriptionAtomicReference.get(); | ||
subscription.request(5); | ||
|
||
latch1.await(); | ||
|
||
long count = latch2.getCount(); | ||
Assert.assertTrue(count < 15); | ||
|
||
subscription.request(100); | ||
|
||
latch2.await(); | ||
|
||
} | ||
|
||
class TestCommand extends HystrixCommand<Boolean> { | ||
protected TestCommand() { | ||
super(HystrixCommandGroupKey.Factory.asKey("HystrixMetricsPollerTest")); | ||
} | ||
|
||
@Override | ||
protected Boolean run() throws Exception { | ||
return true; | ||
} | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
...com/netflix/hystrix/contrib/reactivesocket/metrics/HystrixCollasperMetricsStreamTest.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.netflix.hystrix.contrib.reactivesocket.metrics; | ||
|
||
import com.netflix.hystrix.HystrixCommand; | ||
import com.netflix.hystrix.HystrixCommandGroupKey; | ||
import org.junit.Test; | ||
|
||
import java.nio.ByteBuffer; | ||
import java.util.concurrent.CountDownLatch; | ||
|
||
public class HystrixCollasperMetricsStreamTest { | ||
|
||
@Test | ||
public void test() throws Exception { | ||
CountDownLatch latch = new CountDownLatch(21); | ||
HystrixCommandMetricsStream | ||
.getInstance() | ||
.get() | ||
.subscribe(payload -> { | ||
ByteBuffer data = payload.getData(); | ||
String s = new String(data.array()); | ||
|
||
System.out.println(s); | ||
latch.countDown(); | ||
}); | ||
|
||
|
||
for (int i = 0; i < 20; i++) { | ||
TestCommand test = new TestCommand(); | ||
|
||
test.execute(); | ||
latch.countDown(); | ||
} | ||
|
||
latch.await(); | ||
} | ||
|
||
class TestCommand extends HystrixCommand<Boolean> { | ||
protected TestCommand() { | ||
super(HystrixCommandGroupKey.Factory.asKey("HystrixMetricsPollerTest")); | ||
} | ||
|
||
@Override | ||
protected Boolean run() throws Exception { | ||
return true; | ||
} | ||
} | ||
|
||
|
||
} |
51 changes: 51 additions & 0 deletions
51
...a/com/netflix/hystrix/contrib/reactivesocket/metrics/HystrixCommandMetricsStreamTest.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.netflix.hystrix.contrib.reactivesocket.metrics; | ||
|
||
import com.netflix.hystrix.HystrixCommand; | ||
import com.netflix.hystrix.HystrixCommandGroupKey; | ||
import org.junit.Test; | ||
|
||
import java.nio.ByteBuffer; | ||
import java.util.concurrent.CountDownLatch; | ||
|
||
/** | ||
* Created by rroeser on 5/19/16. | ||
*/ | ||
public class HystrixCommandMetricsStreamTest { | ||
@Test | ||
public void test() throws Exception { | ||
CountDownLatch latch = new CountDownLatch(23); | ||
HystrixCommandMetricsStream | ||
.getInstance() | ||
.get() | ||
.subscribe(payload -> { | ||
ByteBuffer data = payload.getData(); | ||
String s = new String(data.array()); | ||
|
||
System.out.println(s); | ||
latch.countDown(); | ||
}); | ||
|
||
for (int i = 0; i < 20; i++) { | ||
TestCommand test = new TestCommand(latch); | ||
|
||
test.execute(); | ||
} | ||
|
||
latch.await(); | ||
} | ||
|
||
class TestCommand extends HystrixCommand<Boolean> { | ||
CountDownLatch latch; | ||
protected TestCommand(CountDownLatch latch) { | ||
super(HystrixCommandGroupKey.Factory.asKey("HystrixMetricsPollerTest")); | ||
this.latch = latch; | ||
} | ||
|
||
@Override | ||
protected Boolean run() throws Exception { | ||
latch.countDown(); | ||
return true; | ||
} | ||
} | ||
|
||
} |
50 changes: 50 additions & 0 deletions
50
.../test/java/com/netflix/hystrix/contrib/reactivesocket/sample/HystrixConfigStreamTest.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.netflix.hystrix.contrib.reactivesocket.sample; | ||
|
||
import com.netflix.hystrix.HystrixCommand; | ||
import com.netflix.hystrix.HystrixCommandGroupKey; | ||
import com.netflix.hystrix.contrib.reactivesocket.metrics.HystrixCommandMetricsStream; | ||
import org.junit.Test; | ||
|
||
import java.nio.ByteBuffer; | ||
import java.util.concurrent.CountDownLatch; | ||
|
||
/** | ||
* Created by rroeser on 5/19/16. | ||
*/ | ||
public class HystrixConfigStreamTest { | ||
@Test | ||
public void test() throws Exception { | ||
CountDownLatch latch = new CountDownLatch(1); | ||
HystrixCommandMetricsStream | ||
.getInstance() | ||
.get() | ||
.subscribe(payload -> { | ||
ByteBuffer data = payload.getData(); | ||
String s = new String(data.array()); | ||
|
||
System.out.println(s); | ||
latch.countDown(); | ||
}); | ||
|
||
|
||
for (int i = 0; i < 20; i++) { | ||
TestCommand test = new TestCommand(); | ||
|
||
test.execute(); | ||
} | ||
|
||
latch.await(); | ||
} | ||
|
||
class TestCommand extends HystrixCommand<Boolean> { | ||
protected TestCommand() { | ||
super(HystrixCommandGroupKey.Factory.asKey("HystrixMetricsPollerTest")); | ||
} | ||
|
||
@Override | ||
protected Boolean run() throws Exception { | ||
System.out.println("IM A HYSTRIX COMMAND!!!!!"); | ||
return true; | ||
} | ||
} | ||
} |