com.netflix.eureka2.server.service.RegistrationChannelImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of eureka-server Show documentation
Show all versions of eureka-server Show documentation
eureka-server developed by Netflix
package com.netflix.eureka2.server.service;
import com.netflix.eureka2.protocol.EurekaProtocolError;
import com.netflix.eureka2.protocol.registration.Register;
import com.netflix.eureka2.protocol.registration.Unregister;
import com.netflix.eureka2.protocol.registration.Update;
import com.netflix.eureka2.registry.Delta;
import com.netflix.eureka2.registry.InstanceInfo;
import com.netflix.eureka2.server.registry.EurekaServerRegistry;
import com.netflix.eureka2.server.registry.EurekaServerRegistry.Status;
import com.netflix.eureka2.server.registry.EvictionQueue;
import com.netflix.eureka2.server.registry.Source;
import com.netflix.eureka2.service.RegistrationChannel;
import com.netflix.eureka2.transport.MessageConnection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import rx.Observable;
import rx.Subscriber;
import rx.functions.Action1;
import java.util.Set;
/**
* @author Nitesh Kant
*/
public class RegistrationChannelImpl extends AbstractChannel implements RegistrationChannel {
private static final Logger logger = LoggerFactory.getLogger(RegistrationChannelImpl.class);
private static final IllegalStateException INSTANCE_ALREADY_REGISTERED_EXCEPTION =
new IllegalStateException("An instance is already registered. You must update instance instead.");
private static final IllegalStateException INSTANCE_NOT_REGISTERED_EXCEPTION =
new IllegalStateException("Instance is not registered yet.");
private final RegistrationChannelMetrics metrics;
private volatile InstanceInfo currentInfo;
private volatile long currentVersion;
protected enum STATES {Idle, Registered, Closed}
public RegistrationChannelImpl(EurekaServerRegistry registry,
final EvictionQueue evictionQueue,
MessageConnection transport,
RegistrationChannelMetrics metrics) {
super(STATES.Idle, transport, registry);
this.metrics = metrics;
metrics.incrementStateCounter(STATES.Idle);
currentVersion = System.currentTimeMillis();
subscribeToTransportInput(new Action1