All Implemented Interfaces:
Serializable, DataStructure

public class MetaLeaseextends Lease
Implementation of MetaLease as specified in Proposal 123: New NetDb Entries.

MetaLease extends the Lease concept to reference other LeaseSets rather than tunnel endpoints:

  • Points to another LeaseSet via its hash instead of a gateway router
  • Enables advanced routing and load balancing strategies
  • Includes cost and type information for selection algorithms
  • Fixed length of 40 bytes for consistency with Lease2

Structure:

  • LeaseSet Hash: 32-byte hash of the target LeaseSet (available via Lease.getGateway())
  • Cost: 4-byte cost value for routing decisions
  • Type: 4-byte type identifier for the referenced LeaseSet

Key Differences from Lease:

  • Reference: Points to LeaseSet hash, not gateway router
  • TunnelId: Not supported (throws UnsupportedOperationException)
  • Metadata: Includes cost and type for intelligent selection
  • Usage: Used within MetaLeaseSet for indirect routing

Usage Scenarios:

  • Load Balancing: Distribute traffic across multiple LeaseSets
  • Geographic Routing: Select LeaseSets based on location or performance
  • Fallback Strategies: Provide alternative LeaseSets for redundancy
  • Service Aggregation: Combine multiple services under one destination

Selection Criteria:

  • Cost: Lower values indicate preferred routes
  • Type: Application-specific categorization
  • Hash: Uniquely identifies the target LeaseSet

Implementation Status: PRELIMINARY - Subject to change as proposal evolves.

See Also:
  • Field Details

    • LENGTH

      public static final int LENGTH
      MetaLease length in bytes.
      See Also:
    • _cost

      private int _cost
      Cost value for this meta lease.
    • _type

      private int _type
      Type identifier for this meta lease.
  • Constructor Details

    • MetaLease

      public MetaLease()
      Required for deserialization: readBytes(InputStream) fills the inherited and own fields.
  • Method Details

    • getCost

      public int getCost()
      Cost value for this lease.
      Returns:
      the cost value, a raw int with no unit of its own
    • setCost

      public void setCost(int cost)
      Set the cost of this lease.
      Parameters:
      cost - the cost value recorded in the LeaseSet for this tunnel, stored and compared as a raw int
    • getType

      public int getType()
      Type identifier for this lease.
      Returns:
      the tunnel type identifier, a raw int
    • setType

      public void setType(int type)
      Set the type of this lease.
      Parameters:
      type - the tunnel type identifier recorded in the LeaseSet, stored and compared as a raw int
    • getTunnelId

      public TunnelId getTunnelId()
      UnsupportedOperationException always.
      Overrides:
      getTunnelId in class Lease
      Returns:
      the tunnel id
      Throws:
      UnsupportedOperationException - always, as a meta lease has no tunnel of its own
    • setTunnelId

      public void setTunnelId(TunnelId id)
      UnsupportedOperationException always.
      Overrides:
      setTunnelId in class Lease
      Parameters:
      id - the tunnel on the gateway to communicate with; null clears it
      Throws:
      UnsupportedOperationException - always, as a meta lease has no tunnel of its own
    • readBytes

      public void readBytes(InputStream in) throws DataFormatException, IOException
      Reads the lease from an input stream.
      Specified by:
      readBytes in interface DataStructure
      Overrides:
      readBytes in class Lease
      Parameters:
      in - stream to read from
      Throws:
      DataFormatException - if the data is improperly formatted
      IOException - if there was a problem reading the stream
    • writeBytes

      public void writeBytes(OutputStream out) throws DataFormatException, IOException
      Writes the lease to an output stream.
      Specified by:
      writeBytes in interface DataStructure
      Overrides:
      writeBytes in class Lease
      Parameters:
      out - stream to write to
      Throws:
      DataFormatException - if the data was incomplete or not yet ready to be written
      IOException - if there was a problem writing to the stream
    • equals

      public boolean equals(Object object)
      Compares this Lease with another object for equality.
      Overrides:
      equals in class Lease
    • hashCode

      public int hashCode()
      Hash code based on end time, gateway, and tunnel ID.
      Overrides:
      hashCode in class Lease
    • toString

      public String toString()
      Returns a string representation of this Lease.
      Overrides:
      toString in class Lease