## org.apache.hadoop.contrib.index.example
Class RoundRobinDistributionPolicy

    java.lang.Object
      org.apache.hadoop.contrib.index.example.RoundRobinDistributionPolicy

All Implemented Interfaces:
  IDistributionPolicy

    public class RoundRobinDistributionPolicy

extends Object
implements IDistributionPolicy

Choose a shard for each insert in a round-robin fashion. Choose all the shards for each delete because we don't know where it is stored.

Constructor Summary
`RoundRobinDistributionPolicy()`

Method Summary
`int` `chooseShardForDelete(DocumentID key)` Choose a shard or all shards to send a delete request.
`int` `chooseShardForInsert(DocumentID key)` Choose a shard to send an insert request.
`void` `init(Shard[] shards)` Initialization.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### RoundRobinDistributionPolicy

    public RoundRobinDistributionPolicy()

Method Detail

### init

    public void init(Shard[] shards)

  Description copied from interface: `IDistributionPolicy`
  Initialization. It must be called before any chooseShard() is called.

  Specified by:
    `init` in interface `IDistributionPolicy`

### chooseShardForInsert

    public int chooseShardForInsert(DocumentID key)

  Description copied from interface: `IDistributionPolicy`
  Choose a shard to send an insert request.

  Specified by:
    `chooseShardForInsert` in interface `IDistributionPolicy`
  Returns:
    the index of the chosen shard

### chooseShardForDelete

    public int chooseShardForDelete(DocumentID key)

  Description copied from interface: `IDistributionPolicy`
  Choose a shard or all shards to send a delete request. E.g. a round-robin distribution policy would send a delete request to all the shards. -1 represents all the shards.

  Specified by:
    `chooseShardForDelete` in interface `IDistributionPolicy`
  Returns:
    the index of the chosen shard, -1 if all the shards are chosen

Copyright © 2009 The Apache Software Foundation