private static void createEurekaServerConfig() { eurekaServerConfig = mock(EurekaServerConfig.class); // Cluster management related when(eurekaServerConfig.getPeerEurekaNodesUpdateIntervalMs()).thenReturn(1000); // Replication logic related when(eurekaServerConfig.shouldSyncWhenTimestampDiffers()).thenReturn(true); when(eurekaServerConfig.getMaxTimeForReplication()).thenReturn(1000); when(eurekaServerConfig.getMaxElementsInPeerReplicationPool()).thenReturn(10); when(eurekaServerConfig.getMinThreadsForPeerReplication()).thenReturn(1); when(eurekaServerConfig.getMaxThreadsForPeerReplication()).thenReturn(1); when(eurekaServerConfig.shouldBatchReplication()).thenReturn(true); // Peer node connectivity (used by JerseyReplicationClient) when(eurekaServerConfig.getPeerNodeTotalConnections()).thenReturn(1); when(eurekaServerConfig.getPeerNodeTotalConnectionsPerHost()).thenReturn(1); when(eurekaServerConfig.getPeerNodeConnectionIdleTimeoutSeconds()).thenReturn(1000); } }
public static EurekaServerConfig newEurekaServerConfig() { EurekaServerConfig config = mock(EurekaServerConfig.class); // Cluster management related when(config.getPeerEurekaNodesUpdateIntervalMs()).thenReturn((int) EUREKA_NODES_UPDATE_INTERVAL_MS); // Replication logic related when(config.shouldSyncWhenTimestampDiffers()).thenReturn(true); when(config.getMaxTimeForReplication()).thenReturn((int) REPLICATION_EXPIRY_TIME_MS); when(config.getMaxElementsInPeerReplicationPool()).thenReturn(10); when(config.getMaxElementsInStatusReplicationPool()).thenReturn(10); when(config.getMaxThreadsForPeerReplication()).thenReturn(1); when(config.getMaxThreadsForStatusReplication()).thenReturn(1); return config; }
this.maxProcessingDelayMs = config.getMaxTimeForReplication(); this.batchingDispatcher = TaskDispatchers.createBatchingTaskDispatcher( batcherName, config.getMaxElementsInPeerReplicationPool(), batchSize, config.getMaxThreadsForPeerReplication(), maxBatchingDelayMs, serverUnavailableSleepTimeMs, this.nonBatchingDispatcher = TaskDispatchers.createNonBatchingTaskDispatcher( targetHost, config.getMaxElementsInStatusReplicationPool(), config.getMaxThreadsForStatusReplication(), maxBatchingDelayMs, serverUnavailableSleepTimeMs,
.withEncoderWrapper(serverCodecs.getFullJsonCodec()) .withDecoderWrapper(serverCodecs.getFullJsonCodec()) .withConnectionTimeout(config.getPeerNodeConnectTimeoutMs()) .withReadTimeout(config.getPeerNodeReadTimeoutMs()) .withMaxConnectionsPerHost(config.getPeerNodeTotalConnectionsPerHost()) .withMaxTotalConnections(config.getPeerNodeTotalConnections()) .withConnectionIdleTimeout(config.getPeerNodeConnectionIdleTimeoutSeconds());
if (lastDirtyTimestamp != null && serverConfig.shouldSyncWhenTimestampDiffers()) { response = this.validateDirtyTimestamp(Long.valueOf(lastDirtyTimestamp), isFromReplicaNode);
taskExecutor.scheduleWithFixedDelay( peersUpdateTask, serverConfig.getPeerEurekaNodesUpdateIntervalMs(), serverConfig.getPeerEurekaNodesUpdateIntervalMs(), TimeUnit.MILLISECONDS );
.withEncoderWrapper(serverCodecs.getFullJsonCodec()) .withDecoderWrapper(serverCodecs.getFullJsonCodec()) .withConnectionTimeout(config.getPeerNodeConnectTimeoutMs()) .withReadTimeout(config.getPeerNodeReadTimeoutMs()) .withMaxConnectionsPerHost(config.getPeerNodeTotalConnectionsPerHost()) .withMaxTotalConnections(config.getPeerNodeTotalConnections()) .withConnectionIdleTimeout(config.getPeerNodeConnectionIdleTimeoutSeconds());
this.maxProcessingDelayMs = config.getMaxTimeForReplication(); this.batchingDispatcher = TaskDispatchers.createBatchingTaskDispatcher( batcherName, config.getMaxElementsInPeerReplicationPool(), batchSize, config.getMaxThreadsForPeerReplication(), maxBatchingDelayMs, serverUnavailableSleepTimeMs, this.nonBatchingDispatcher = TaskDispatchers.createNonBatchingTaskDispatcher( targetHost, config.getMaxElementsInStatusReplicationPool(), config.getMaxThreadsForStatusReplication(), maxBatchingDelayMs, serverUnavailableSleepTimeMs,
@Override public void handleFailure(int statusCode, Object responseEntity) throws Throwable { super.handleFailure(statusCode, responseEntity); if (statusCode == 404) { logger.warn("{}: missing entry.", getTaskName()); if (info != null) { logger.warn("{}: cannot find instance id {} and hence replicating the instance with status {}", getTaskName(), info.getId(), info.getStatus()); register(info); } } else if (config.shouldSyncWhenTimestampDiffers()) { InstanceInfo peerInstanceInfo = (InstanceInfo) responseEntity; if (peerInstanceInfo != null) { syncInstancesIfTimestampDiffers(appName, id, info, peerInstanceInfo); } } } };
taskExecutor.scheduleWithFixedDelay( peersUpdateTask, serverConfig.getPeerEurekaNodesUpdateIntervalMs(), serverConfig.getPeerEurekaNodesUpdateIntervalMs(), TimeUnit.MILLISECONDS );
public static EurekaServerConfig newEurekaServerConfig() { EurekaServerConfig config = mock(EurekaServerConfig.class); // Cluster management related when(config.getPeerEurekaNodesUpdateIntervalMs()).thenReturn((int) EUREKA_NODES_UPDATE_INTERVAL_MS); // Replication logic related when(config.shouldSyncWhenTimestampDiffers()).thenReturn(true); when(config.getMaxTimeForReplication()).thenReturn((int) REPLICATION_EXPIRY_TIME_MS); when(config.getMaxElementsInPeerReplicationPool()).thenReturn(10); when(config.getMaxElementsInStatusReplicationPool()).thenReturn(10); when(config.getMaxThreadsForPeerReplication()).thenReturn(1); when(config.getMaxThreadsForStatusReplication()).thenReturn(1); return config; }
.withEncoderWrapper(serverCodecs.getFullJsonCodec()) .withDecoderWrapper(serverCodecs.getFullJsonCodec()) .withConnectionTimeout(config.getPeerNodeConnectTimeoutMs()) .withReadTimeout(config.getPeerNodeReadTimeoutMs()) .withMaxConnectionsPerHost(config.getPeerNodeTotalConnectionsPerHost()) .withMaxTotalConnections(config.getPeerNodeTotalConnections()) .withConnectionIdleTimeout(config.getPeerNodeConnectionIdleTimeoutSeconds());
if (lastDirtyTimestamp != null && serverConfig.shouldSyncWhenTimestampDiffers()) { response = this.validateDirtyTimestamp(Long.valueOf(lastDirtyTimestamp), isFromReplicaNode);
.withEncoderWrapper(serverCodecs.getFullJsonCodec()) .withDecoderWrapper(serverCodecs.getFullJsonCodec()) .withConnectionTimeout(config.getPeerNodeConnectTimeoutMs()) .withReadTimeout(config.getPeerNodeReadTimeoutMs()) .withMaxConnectionsPerHost(config.getPeerNodeTotalConnectionsPerHost()) .withMaxTotalConnections(config.getPeerNodeTotalConnections()) .withConnectionIdleTimeout(config.getPeerNodeConnectionIdleTimeoutSeconds());
@Override public void handleFailure(int statusCode, Object responseEntity) throws Throwable { super.handleFailure(statusCode, responseEntity); if (statusCode == 404) { logger.warn("{}: missing entry.", getTaskName()); if (info != null) { logger.warn("{}: cannot find instance id {} and hence replicating the instance with status {}", getTaskName(), info.getId(), info.getStatus()); register(info); } } else if (config.shouldSyncWhenTimestampDiffers()) { InstanceInfo peerInstanceInfo = (InstanceInfo) responseEntity; if (peerInstanceInfo != null) { syncInstancesIfTimestampDiffers(appName, id, info, peerInstanceInfo); } } } };