All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.netflix.eureka2.server.registry.Source Maven / Gradle / Ivy

The newest version!
package com.netflix.eureka2.server.registry;

import java.util.UUID;

/**
 * @author David Liu
 */
public final class Source {
    /**
     * Each entry in a registry is associated with exactly one origin:
     * 
    *
  • {@link #LOCAL}
  • - there is an opened registration client connection to the write local server *
  • {@link #REPLICATED}
  • - replicated entry from another server *
  • {@link #INTERESTED}
  • - entry from a source server specified as an interest *
*/ public enum Origin { LOCAL, REPLICATED, INTERESTED } private final Origin origin; private final String id; private Source(Origin origin, String id) { this.origin = origin; this.id = id; } public Origin getOrigin() { return origin; } public String getId() { return id; } @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof Source)) return false; Source source = (Source) o; if (id != null ? !id.equals(source.id) : source.id != null) return false; if (origin != source.origin) return false; return true; } @Override public int hashCode() { int result = origin != null ? origin.hashCode() : 0; result = 31 * result + (id != null ? id.hashCode() : 0); return result; } @Override public String toString() { return "Source{" + "origin=" + origin + ", id='" + id + '\'' + '}'; } private static final Source LOCAL_SOURCE = new Source(Origin.LOCAL, UUID.randomUUID().toString()); public static Source localSource() { return LOCAL_SOURCE; } public static Source replicationSource(String id) { return new Source(Origin.REPLICATED, id); } public static Source interestSource(String id) { return new Source(Origin.INTERESTED, id); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy