org.schemarepo.zookeeper
Class ZooKeeperRepository

java.lang.Object
  extended by org.schemarepo.BaseRepository
      extended by org.schemarepo.AbstractBackendRepository
          extended by org.schemarepo.zookeeper.ZooKeeperRepository
All Implemented Interfaces:
Closeable, Repository

public class ZooKeeperRepository
extends AbstractBackendRepository

This Repository implementation stores its state using Zookeeper.

It requires the schema-repo.zookeeper.ensemble configuration property. This is a comma-separated list of host:port addresses. Each address can also be suffixed by a namespace, i.e.: zk.1:2181/schemas,zk.2:2181/schemas,zk.3:2181/schemas

This Repository is meant to be highly available, meaning that multiple instances can share the same Zookeeper ensemble and synchronize their state through it.


Field Summary
 
Fields inherited from class org.schemarepo.AbstractBackendRepository
subjectCache, validators
 
Fields inherited from class org.schemarepo.BaseRepository
closed, logger
 
Constructor Summary
ZooKeeperRepository(String zkEnsemble, String zkPathPrefix, Integer zkSessionTimeout, Integer zkConnectionTimeout, Integer curatorSleepTimeBetweenRetries, Integer curatorNumberOfRetries, ValidatorFactory validators)
           
 
Method Summary
protected  boolean checkSubjectExistsInBackend(String subjectName)
           
 void close()
          Closes this stream and releases any system resources associated with it.
protected  Map<String,String> exposeConfiguration()
           
protected  Subject getSubjectInstance(String subjectName)
           
 void isValid()
           
protected  void registerSubjectInBackend(String subjectName, SubjectConfig config)
           
 Iterable<Subject> subjects()
           
 
Methods inherited from class org.schemarepo.AbstractBackendRepository
cacheSubject, getAndCacheSubject, lookup, register
 
Methods inherited from class org.schemarepo.BaseRepository
toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ZooKeeperRepository

@Inject
public ZooKeeperRepository(@Named(value="schema-repo.zookeeper.ensemble")
                                  String zkEnsemble,
                                  @Named(value="schema-repo.zookeeper.path-prefix")
                                  String zkPathPrefix,
                                  @Named(value="schema-repo.zookeeper.session-timeout")
                                  Integer zkSessionTimeout,
                                  @Named(value="schema-repo.zookeeper.connection-timeout")
                                  Integer zkConnectionTimeout,
                                  @Named(value="schema-repo.zookeeper.curator.sleep-time-between-retries")
                                  Integer curatorSleepTimeBetweenRetries,
                                  @Named(value="schema-repo.zookeeper.curator.number-of-retries")
                                  Integer curatorNumberOfRetries,
                                  ValidatorFactory validators)
Method Detail

getSubjectInstance

protected Subject getSubjectInstance(String subjectName)
Specified by:
getSubjectInstance in class AbstractBackendRepository

registerSubjectInBackend

protected void registerSubjectInBackend(String subjectName,
                                        SubjectConfig config)
Specified by:
registerSubjectInBackend in class AbstractBackendRepository

checkSubjectExistsInBackend

protected boolean checkSubjectExistsInBackend(String subjectName)
Overrides:
checkSubjectExistsInBackend in class AbstractBackendRepository

subjects

public Iterable<Subject> subjects()
Specified by:
subjects in interface Repository
Overrides:
subjects in class AbstractBackendRepository

close

public void close()
           throws IOException
Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.

Specified by:
close in interface Closeable
Overrides:
close in class BaseRepository
Throws:
IOException - if an I/O error occurs

isValid

public void isValid()
Overrides:
isValid in class BaseRepository

exposeConfiguration

protected Map<String,String> exposeConfiguration()
Overrides:
exposeConfiguration in class BaseRepository


Copyright © 2015. All rights reserved.