Skip to content
Lukas Schmelzeisen edited this page Sep 13, 2013 · 3 revisions

MUID (Metalcon Unique Identifier) are used to identify all metalcon internal entities.

Requirements

  • MUIDs need to be able to be generated from many machines without querying each other (each machine must be able to generate MUIDs individually).
  • MUIDs need to be unique across all machine that will generate MUIDs (if a MUID is generated on one machine, it must never be generated on any machine again).
  • Each MUIDs stores a type attribute, describing the type for the entity the MUID represents.

Numbers to determine

  • Amount of different Types we will need. 1 Byte = 256 might be enough, but for safety I'd say we need more.
  • Numbers of MUIDs that are reasonable to generate without an overlap. How many Entities will Metalcon ever have (including deleted ones)? We always used 1 Million, but for safety I'd say we go higher.

Format

It would be really nice if MUIDs would fit into 8 Byte since:

8 Bytes = 2^(8*8) ≈ (2^26 + 10)^11 = 11 Alphanumerics

which would allow us to have an easy translation from internal byte representation to URL representation.

resources: http://code.flickr.net/2010/02/08/ticket-servers-distributed-unique-primary-keys-on-the-cheap/

Functionality

Here is an proposed interface for all the functionality MUIDs need to support.

/**
 * Generates a MUID for a given EntityType.
 * @param type  The type the MUID should save.
 * @return A newly generated MUID.
 */
public static String genereateMuid(EntityType type) {
    // TODO
    return "b21d399ff7835a28"; 
}

/**
 * Checks for a given ID, whether its a valid MUID or not.
 * @param muid  The ID to check.
 * @return `true` if valid, `false` if not.
 */
public static boolean isValidMuid(String muid) {
    // TODO
    return true;
}

/**
 * Reads the EntityType out of a MUID.
 * @param muid  The MUID to read.
 * @return The EntityType of the MUID.
 */
public static EntityType getMuidType(String muid) {
    // TODO
    return EntityType.PERSON;
}
Clone this wiki locally