Skip to content

Commit

Permalink
Merge pull request Netflix#671 from qiangdavidliu/feature/di-friendly…
Browse files Browse the repository at this point in the history
…-server

Feature/di friendly server
  • Loading branch information
qiangdavidliu committed Oct 2, 2015
2 parents 8f40dc4 + 201cfc6 commit 6b18edc
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ext {
apacheHttpClientVersion='4.3.4'
guiceVersion='4.0'
servoVersion='0.9.4'
governatorVersion='1.10.3'
governatorVersion='1.10.4'
archaiusVersion='0.7.1'
archaius2Version='2.0.0-rc.32'
blitzVersion='1.34'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.netflix.appinfo.InstanceInfo.InstanceStatus;
import com.netflix.discovery.shared.EurekaHttpClient.HttpResponse;
import com.netflix.eureka.EurekaServerConfig;
import com.netflix.eureka.lease.Lease;
import com.netflix.eureka.registry.PeerAwareInstanceRegistry;
import com.netflix.eureka.registry.PeerAwareInstanceRegistryImpl.Action;
import com.netflix.eureka.resources.ASGResource.ASGStatus;
Expand Down Expand Up @@ -131,7 +132,7 @@ public PeerEurekaNode(PeerAwareInstanceRegistry registry, String targetHost, Str
* @throws Exception
*/
public void register(final InstanceInfo info) throws Exception {
long expiryTime = System.currentTimeMillis() + info.getLeaseInfo().getRenewalIntervalInSecs() * 1000;
long expiryTime = System.currentTimeMillis() + getLeaseRenewalOf(info);
batchingDispatcher.process(
taskId("register", info),
new InstanceReplicationTask(targetHost, Action.Register, info, null, true) {
Expand Down Expand Up @@ -222,7 +223,7 @@ public void handleFailure(int statusCode, Object responseEntity) throws Throwabl
}
}
};
long expiryTime = System.currentTimeMillis() + info.getLeaseInfo().getRenewalIntervalInSecs() * 1000;
long expiryTime = System.currentTimeMillis() + getLeaseRenewalOf(info);
batchingDispatcher.process(taskId("heartbeat", info), replicationTask, expiryTime);
}

Expand Down Expand Up @@ -388,4 +389,8 @@ private static String taskId(String requestType, String appName, String id) {
private static String taskId(String requestType, InstanceInfo info) {
return taskId(requestType, info.getAppName(), info.getId());
}

private static int getLeaseRenewalOf(InstanceInfo info) {
return (info.getLeaseInfo() == null ? Lease.DEFAULT_DURATION_IN_SECS : info.getLeaseInfo().getRenewalIntervalInSecs()) * 1000;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import static java.util.Arrays.asList;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.timeout;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
Expand Down Expand Up @@ -82,7 +83,7 @@ public void testSingleItemProcessingWithTransientError() throws Exception {

// Verify that transient task is be re-scheduled
processor.expectTransientErrors(1);
verify(acceptorExecutor, times(1)).reprocess(taskHolder, ProcessingResult.TransientError);
verify(acceptorExecutor, timeout(500).times(1)).reprocess(taskHolder, ProcessingResult.TransientError);
}

@Test
Expand All @@ -94,7 +95,7 @@ public void testBatchProcessingWithTransientError() throws Exception {

// Verify that transient task is be re-scheduled
processor.expectTransientErrors(2);
verify(acceptorExecutor, times(1)).reprocess(taskHolderBatch, ProcessingResult.TransientError);
verify(acceptorExecutor, timeout(500).times(1)).reprocess(taskHolderBatch, ProcessingResult.TransientError);
}

@Test
Expand Down
3 changes: 3 additions & 0 deletions eureka-server-karyon3/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ dependencies {
runtime 'org.codehaus.jettison:jettison:1.2'
providedCompile "javax.servlet:servlet-api:${servletVersion}"

// for now to keep governator and karyon3 in sync until karyon3 stabilize
compile "com.netflix.governator:governator-jetty:${governatorVersion}"

testCompile project(':eureka-test-utils')
testCompile 'org.mockito:mockito-core:1.10.19'
testCompile "org.eclipse.jetty:jetty-server:${jetty_version}"
Expand Down

0 comments on commit 6b18edc

Please sign in to comment.