/** * Factory for Lock instances. * * @deprecated use the lock factory methods in {@link com.moz.fiji.schema.zookeeper.ZooKeeperUtils}. */ @ApiAudience.Private @Inheritance.Sealed @Deprecated public interface LockFactory { /** * Creates a new lock in the specified directory. Locks within a directory are exclusive; no two * locks may be taken out from the same directory at the same time. * * @param directory identifying an exclusive lock location (e.g. a ZooKeeper ZNode path). * @return a lock which is exclusive in the specified directory. * @throws IOException on unrecoverable error. */ Lock create(String directory) throws IOException; }
/** * A {@link ZooKeeperFactory} which assumes a FijiURI is pointing to an existing, remote, ZooKeeper * ensemble. This {@link ZooKeeperFactory} implementation will be used in all non-unit-test * situations. */ @ApiAudience.Private @Inheritance.Sealed public class DefaultZooKeeperFactory implements ZooKeeperFactory { /** {@inheritDoc}. */ @Override public String getZooKeeperEnsemble(FijiURI uri) { final List<String> zkHosts = Lists.newArrayList(); for (String host : uri.getZookeeperQuorum()) { zkHosts.add(String.format("%s:%s", host, uri.getZookeeperClientPort())); } return Joiner.on(",").join(zkHosts); } @Override public int getPriority(Map<String, String> runtimeHints) { // Default priority; should be used unless overridden by a higher priority test provider. return Priority.NORMAL; } }
/** * A callback interface which classes can override in order to be registered to receive * notifications through calls to {@link #update(FijiTableLayout)} that a new * {@link FijiTableLayout} is available for the table. * <p> * The preferred style of using this callback is to have a private inner class which implements * {@code LayoutConsumer} in order to not pollute the public facing API. */ @ApiAudience.Private public interface LayoutConsumer { /** * Called when the table layout changes. * * @param layout the most recent layout of the Fiji table. * @throws IOException in case of an error updating. */ void update(FijiTableLayout layout) throws IOException; /** * A registration resource that should be closed to signal a user no longer needs to receive * layout updates. Should be returned upon registering a {@link LayoutConsumer}. */ public interface Registration extends Closeable { } }
/** * Synthesizes random words from a dictionary. */ @ApiAudience.Private public class WordSynthesizer implements Synthesizer<String> { /** A random number generator. */ private Random mRandom; /** A word dictionary. */ private List<String> mDictionary; /** * Constructs a word synthesizer. * * @param random A random number generator. * @param dictionary A vocabulary of words to use when synthesizing. */ public WordSynthesizer(Random random, List<String> dictionary) { mRandom = random; mDictionary = dictionary; } @Override public String synthesize() { return mDictionary.get(mRandom.nextInt(mDictionary.size())); } }
/** * An InputFormat for MapReduce jobs over HBase HTables. * * <p>HBase ships with a <code>TableInputFormat</code>, but it doesn't clean up its * HTable/Zookeeper connections correctly, so we've extended it here and fixed the bug. * Otherwise, it behaves exactly like the HBase TableInputFormat.</p> */ @ApiAudience.Private public final class HTableInputFormat extends TableInputFormat { /** {@inheritDoc} */ @Override public List<InputSplit> getSplits(JobContext context) throws IOException { List<InputSplit> splits = super.getSplits(context); // TableInputFormat opens an HTable within its setConf() method, since it is // required during getSplits(). HTableInterface openedTable = getHTable(); assert null != openedTable; // After getSplits(), it is no longer necessary, so let's close it. openedTable.close(); setHTable(null); return splits; } }
/** Utility methods for working with <code>FijiMapper</code>. */ @ApiAudience.Private public final class FijiMappers { /** Utility class, cannot be instantiated. */ private FijiMappers() {} /** * Loads a FijiMapper class by name. * * @param className Fully qualified name of the class to load. * @return the loaded class. * @throws ClassNotFoundException if the class is not found. * @throws ClassCastException if the class is not a FijiBulkImporter. */ @SuppressWarnings("rawtypes") public static Class<? extends FijiMapper> forName(String className) throws ClassNotFoundException { return Class.forName(className).asSubclass(FijiMapper.class); } }
/** Utility methods for working with <code>FijiGatherer</code>. */ @ApiAudience.Private public final class FijiGatherers { /** Utility class, cannot be instantiated. */ private FijiGatherers() {} /** * Loads a FijiGatherer class by name. * * @param className Fully qualified name of the class to load. * @return the loaded class. * @throws ClassNotFoundException if the class is not found. * @throws ClassCastException if the class is not a FijiBulkImporter. */ @SuppressWarnings("rawtypes") public static Class<? extends FijiGatherer> forName(String className) throws ClassNotFoundException { return Class.forName(className).asSubclass(FijiGatherer.class); } }
/** Factory for constructing instances of HBaseFiji. */ @ApiAudience.Private public final class HBaseFijiFactory implements FijiFactory { /** {@inheritDoc} */ @Override public Fiji open(FijiURI uri) throws IOException { return open(uri, HBaseConfiguration.create()); } /** {@inheritDoc} */ @Override public Fiji open(FijiURI uri, Configuration conf) throws IOException { return new HBaseFiji(uri, conf, HBaseFactory.Provider.get().getHTableInterfaceFactory(uri)); } /** {@inheritDoc} */ @Override public int getPriority(Map<String, String> runtimeHints) { // Default priority; should be used unless overridden by tests. return Priority.NORMAL; } }
/** Factory for HBaseAdmin that creates concrete HBaseAdmin instances. */ @ApiAudience.Private public final class DefaultHBaseAdminFactory implements HBaseAdminFactory { /** Singleton. */ private static final HBaseAdminFactory DEFAULT = new DefaultHBaseAdminFactory(); /** @return an instance of the default factory. */ public static HBaseAdminFactory get() { return DEFAULT; } /** Disallow new instances, enforce singleton. */ private DefaultHBaseAdminFactory() { } /** {@inheritDoc} */ @Override public HBaseAdmin create(Configuration conf) throws IOException { return new HBaseAdmin(conf); } }
/** Factory for HTableInterface that creates concrete HTable instances. */ @ApiAudience.Private public final class DefaultHTableInterfaceFactory implements HTableInterfaceFactory { /** Singleton. */ private static final HTableInterfaceFactory DEFAULT = new DefaultHTableInterfaceFactory(); /** @return the default factory singleton. */ public static HTableInterfaceFactory get() { return DEFAULT; } /** Disallow new instances, enforce singleton. */ private DefaultHTableInterfaceFactory() { } /** {@inheritDoc} */ @Override public HTableInterface create(Configuration conf, String hbaseTableName) throws IOException { return new HTable(conf, hbaseTableName); } }
/** Utility methods for working with <code>FijiReducer</code>. */ @ApiAudience.Private public final class FijiReducers { /** Utility class, cannot be instantiated. */ private FijiReducers() {} /** * Loads a FijiReducer class by name. * * @param className Fully qualified name of the class to load. * @return the loaded class. * @throws ClassNotFoundException if the class is not found. * @throws ClassCastException if the class is not a FijiBulkImporter. */ @SuppressWarnings("rawtypes") public static Class<? extends FijiReducer> forName(String className) throws ClassNotFoundException { return Class.forName(className).asSubclass(FijiReducer.class); } }
/** * Factory for HTableInterface instances. * * This interface exists because the HBase HTableInstanceFactory doesn't throw IOException. */ @ApiAudience.Private public interface HTableInterfaceFactory { /** * Creates a new HTableInterface instance. * * @param conf The configuration for the HBase cluster. * @param hbaseTableName The name of the HBase table to create a connection to. * @return a new HTableInterface for the specified table. * @throws IOException on I/O error. */ HTableInterface create(Configuration conf, String hbaseTableName) throws IOException; }
/** * Factory for HBaseAdmin. * * Note: there is no interface for HBaseAdmin :( */ @ApiAudience.Private public interface HBaseAdminFactory { /** * Creates a new HBaseAdmin instance. * * @param conf Configuration. * @return a new HBaseAdmin. * @throws IOException on I/O error. */ HBaseAdmin create(Configuration conf) throws IOException; }
/** * Synthesizers create objects from nothing. * * @param <T> The type of data to be synthesized. */ @ApiAudience.Private @Inheritance.Sealed public interface Synthesizer<T> { /** * Synthesizes a piece of data. * * @return The synthesized data. */ T synthesize(); }
/** * A comparator that sorts Longs in reverse chronological order. */ @ApiAudience.Private public final class TimestampComparator implements Comparator<Long> { /** A singleton instance. */ public static final TimestampComparator INSTANCE = new TimestampComparator(); /** Use TimestampComparator.INSTANCE instead. */ private TimestampComparator() {} @Override public int compare(Long left, Long right) { return right.compareTo(left); } }
/** * Creates a new schema entry. * * @param id the schema ID * @param hash the schema hash * @param schema the Avro schema object */ @ApiAudience.Private public SchemaEntry(long id, BytesKey hash, Schema schema) { this.mId = id; this.mHash = hash; this.mSchema = schema; }
/** Raised when decoding some data fails (eg. a variable-length integer). */ @ApiAudience.Private public static final class EncodingException extends IOException { }
/** * Thrown when fiji encounters a column name that is not valid. */ @ApiAudience.Private public final class InvalidColumnNameException extends RuntimeException { /** * Creates a new <code>InvalidColumnNameException</code> with the specified detail message. * * @param message The exception message. */ public InvalidColumnNameException(String message) { super(message); } }
/** * A default implementation of a wall clock that returns the system time (milliseconds since the * unix epoch). */ @ApiAudience.Private final class DefaultClock extends Clock { /** {@inheritDoc} */ @Override public long getTime() { return System.currentTimeMillis(); } }
/** Interface for functions that resolve AvroSchema descriptors into Schema objects. */ @ApiAudience.Private public interface AvroSchemaResolver extends Function<AvroSchema, Schema> { /** * Resolves an Avro schema descriptor into a Schema object. * * @param avroSchema Avro schema descriptor to resolve. * @return the resolved Schema object. */ @Override Schema apply(AvroSchema avroSchema); }