1 /* 2 * Copyright 2013 The Netty Project 3 * 4 * The Netty Project licenses this file to you under the Apache License, 5 * version 2.0 (the "License"); you may not use this file except in compliance 6 * with the License. You may obtain a copy of the License at: 7 * 8 * https://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 * License for the specific language governing permissions and limitations 14 * under the License. 15 */ 16 17 package io.netty.channel; 18 19 import java.io.Serializable; 20 21 /** 22 * Represents the globally unique identifier of a {@link Channel}. 23 * <p> 24 * The identifier is generated from various sources listed in the following: 25 * <ul> 26 * <li>MAC address (EUI-48 or EUI-64) or the network adapter, preferably a globally unique one,</li> 27 * <li>the current process ID,</li> 28 * <li>{@link System#currentTimeMillis()},</li> 29 * <li>{@link System#nanoTime()},</li> 30 * <li>a random 32-bit integer, and</li> 31 * <li>a sequentially incremented 32-bit integer.</li> 32 * </ul> 33 * </p> 34 * <p> 35 * The global uniqueness of the generated identifier mostly depends on the MAC address and the current process ID, 36 * which are auto-detected at the class-loading time in best-effort manner. If all attempts to acquire them fail, 37 * a warning message is logged, and random values will be used instead. Alternatively, you can specify them manually 38 * via system properties: 39 * <ul> 40 * <li>{@code io.netty.machineId} - hexadecimal representation of 48 (or 64) bit integer, 41 * optionally separated by colon or hyphen.</li> 42 * <li>{@code io.netty.processId} - an integer between 0 and 65535</li> 43 * </ul> 44 * </p> 45 */ 46 public interface ChannelId extends Serializable, Comparable<ChannelId> { 47 /** 48 * Returns the short but globally non-unique string representation of the {@link ChannelId}. 49 */ 50 String asShortText(); 51 52 /** 53 * Returns the long yet globally unique string representation of the {@link ChannelId}. 54 */ 55 String asLongText(); 56 }