本文整理汇总了Java中org.lightcouch.CouchDbProperties类的典型用法代码示例。如果您正苦于以下问题:Java CouchDbProperties类的具体用法?Java CouchDbProperties怎么用?Java CouchDbProperties使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CouchDbProperties类属于org.lightcouch包,在下文中一共展示了CouchDbProperties类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.lightcouch.CouchDbProperties; //导入依赖的package包/类
/**
* Configures the DatabaseService singleton, must be called before the crawling process starts.
*
* @param downloadMedia true, if media downloader enabled, false to disable media downloads
* @param dbProperties CouchDB properties for the Crawcial Twitter Database
* @param imgSize requested image size (thumb, small, medium, large)
* @param mediaHttps true if https should be used for media downloads
*/
public synchronized void init(boolean downloadMedia, CouchDbProperties dbProperties, String imgSize, boolean mediaHttps) {
DatabaseService.downloadMedia = downloadMedia;
this.mediaHttps = mediaHttps;
this.imgSize = imgSize;
warningCnt = 0;
this.dbProperties = dbProperties;
CouchDbClient dbClient = new CouchDbCloneClient(dbProperties);
DesignDocument designDoc = dbClient.design().getFromDesk("crawcial");
dbClient.design().synchronizeWithDb(designDoc);
dbClient.shutdown();
attachmentExecutors = new LinkedBlockingQueue<>();
if (downloadMedia) {
es = new ThreadPoolExecutor(Runtime.getRuntime().availableProcessors(),
Runtime.getRuntime().availableProcessors() * 2, 30, TimeUnit.SECONDS, attachmentExecutors);
}
writeExecutor = new WriteExecutor(jsonObjectVector, bufferLimit);
writeExecutorThread = new Thread(writeExecutor);
writeExecutorThread.setName("writer-executor-thread-0");
writeExecutorThread.start();
}
示例2: setConfig
import org.lightcouch.CouchDbProperties; //导入依赖的package包/类
/**
* Sets the configuration for this TwitterStreaming instance, is required to be called in order to run a TwitterStreamer.
*
* @param auth OAuth authentication data
* @param terms List of filter terms
* @param downloadMedia true, if media downloader enabled, false to disable media downloads
* @param properties CouchDB properties for the Crawcial Twitter Database
* @param imgSize requested imgSize (thumb, small, medium, large)
* @param mediaHttps true if https should be used for media downloads
* @param location A geo location filter (optional)
* @throws IllegalArgumentException If your configuration is invalid
*/
public void setConfig(Authentication auth, List<String> terms, boolean downloadMedia,
CouchDbProperties properties, String imgSize, boolean mediaHttps, Location location) throws IllegalArgumentException {
if (!downloadMedia ^ Arrays.asList(imgSizes).contains(imgSize)) {
// Receive OAuth params
this.auth = auth;
if (location != null) {
locations = Arrays.asList(location);
} else {
locations = null;
}
// Reset DatabaseService & set download mode
ds.init(downloadMedia, properties, imgSize, mediaHttps);
// Terms for filtering
this.terms = terms;
logger.info("Filtering tweets with terms {}", terms.toString());
lowMemory = false;
configSet = true;
} else {
configSet = false;
throw new IllegalArgumentException("Invalid imgSize");
}
}
示例3: performMapReduce
import org.lightcouch.CouchDbProperties; //导入依赖的package包/类
private Stream<JsonObject> performMapReduce(String dbIP, String tableName, String mapRedDir)
{
MapReduceSources mrs = MapReduceSources.fromDir(mapRedDir);
CouchDbProperties properties = new CouchDbProperties(tableName.toLowerCase(), true, "http", dbIP, 5984, null, null);
CouchDbClient dbClient = new CouchDbClient(properties);
MapReduce mapRedObj = new MapReduce();
mapRedObj.setMap(mrs.getMapJSCode());
mapRedObj.setReduce(mrs.getReduceJSCode());
List<JsonObject> list = dbClient.view("_temp_view").tempView(mapRedObj).group(true)
.includeDocs(false).reduce(true).query(JsonObject.class);
// This step will apply some custom rules to the elements...
return adapter.adaptStream(list);
}
示例4: createDBProperties
import org.lightcouch.CouchDbProperties; //导入依赖的package包/类
private CouchDbProperties createDBProperties(String path) throws MalformedURLException
{
String localDBUrl = getInternalLocalDBURL();
ISecurePreferences secPrefs = SecurePreferencesFactory.getDefault().node("org.bbaw.bts.app");
ISecurePreferences auth = secPrefs.node("auth");
String username = null;
String password = null;
try {
username = auth.get("username", null);
password = auth.get("password", null);
} catch (StorageException e) {
logger.error(e);
}
URL url = new URL(localDBUrl + "/");
logger.info("CouchDbProperties createDBProperties: " + localDBUrl);
CouchDbProperties properties = new CouchDbProperties().setDbName(path).setCreateDbIfNotExist(true)
.setProtocol(url.getProtocol()).setHost(url.getHost()).setPort(url.getPort());
if (username != null && password != null)
{
properties.setUsername(username).setPassword(password);
}
properties.setMaxConnections(100).setConnectionTimeout(0);
return properties;
}
示例5: getCouchDbProperties
import org.lightcouch.CouchDbProperties; //导入依赖的package包/类
/**
* Returns the current database properties from a properties file with a specified database name.
*
* @param sc the servlet context
* @param dbName the database name
* @return current database properties with a specified database name
*/
@SuppressWarnings("ConstantConditions")
public static CouchDbProperties getCouchDbProperties(ServletContext sc, String dbName) {
try {
return new CouchDbProperties(dbName, false, getProperty(sc, "dbprotocol"), getProperty(sc, "dbhost"),
Integer.valueOf(getProperty(sc, "dbport")), getProperty(sc, "dbusername"), getProperty(sc, "dbpassword"));
} catch (NumberFormatException | NullPointerException e) {
return null;
}
}
示例6: cloneProperties
import org.lightcouch.CouchDbProperties; //导入依赖的package包/类
/**
* This works around an issue with the LightCouch client, CouchDbProperties are mutable and cannot be reused safely.
*
* @param src CouchDbProperties to be cloned
* @return cloned CouchDbProperties
*/
public static CouchDbProperties cloneProperties(CouchDbProperties src) {
// (String dbName, boolean createDbIfNotExist, String protocol, String host, int port, String username, String password)
CouchDbProperties ret = new CouchDbProperties(src.getDbName(), src.isCreateDbIfNotExist(), src.getProtocol(), src.getHost(), src.getPort(), src.getUsername(), src.getPassword());
ret.setPath(src.getPath());
ret.setSocketTimeout(src.getSocketTimeout());
ret.setConnectionTimeout(src.getConnectionTimeout());
ret.setMaxConnections(src.getMaxConnections());
ret.setProxyHost(src.getProxyHost());
ret.setProxyPort(src.getProxyPort());
return ret;
}
示例7: CouchDBDHCalcDatabase
import org.lightcouch.CouchDbProperties; //导入依赖的package包/类
private CouchDBDHCalcDatabase() {
this.dbName = DHCalcProperties.getInstance().getDbName();
try {
CouchDbProperties props = new CouchDbProperties()
.setDbName(dbName)
.setCreateDbIfNotExist(true)
.setProtocol("http")
.setHost(DHCalcProperties.getInstance().getDb())
.setPort(5984).setMaxConnections(100)
.setConnectionTimeout(0);
dbClient = new CouchDbClient(props);
DesignDocument designDoc = dbClient.design().getFromDesk(dbName);
dbClient.design().synchronizeWithDb(designDoc);
String old = this
.getParameter(CouchDBDHCalcParameters.SCHEMA_VERSION);
if (old == null)
old = "0";
int oldVersion = Integer.parseInt(old);
log.info("Database Version = " + oldVersion);
if (oldVersion != VERSION) {
log.info("Migrating Database to Version = " + VERSION);
migrateSchema(oldVersion);
}
}
catch (Exception e) {
log.log(Level.SEVERE, e.getMessage(), e);
}
}
示例8: couchDbClient
import org.lightcouch.CouchDbProperties; //导入依赖的package包/类
@Bean(destroyMethod = "shutdown")
public CouchDbClient couchDbClient() {
CouchDbProperties properties = new CouchDbProperties();
properties.setProtocol("http");
properties.setHost("localhost");
properties.setPort(5984);
properties.setDbName("lightcouch-integration-tests");
CouchDbClient client = new CouchDbClient(properties);
// we adjust the date format so that it is equal to the format used by Ektorp
client.setGsonBuilder(new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"));
return client;
}
示例9: getCommonConfig
import org.lightcouch.CouchDbProperties; //导入依赖的package包/类
private CouchDbProperties getCommonConfig(String dbName) {
CouchDbProperties config = new CouchDbProperties();
config.setHost(host)
.setPort(port)
.setProtocol(protocol)
.setDbName(dbPrefix + "-" + dbName)
.setCreateDbIfNotExist(createDbIfNotExist);
if (!path.isEmpty())
config.setPath(path);
if (!username.isEmpty()) {
config.setUsername(username)
.setPassword(password);
}
return config;
}
示例10: couchDbSessionClient
import org.lightcouch.CouchDbProperties; //导入依赖的package包/类
@Bean(destroyMethod = "shutdown")
public CouchDbClient couchDbSessionClient(){
CouchDbProperties couchDbProperties = new CouchDbProperties();
couchDbProperties.setHost(couchDbHostname);
couchDbProperties.setPort(couchDbHostPort);
couchDbProperties.setCreateDbIfNotExist(couchDbCreateIfNotExist);
couchDbProperties.setProtocol(couchDbProtocol);
couchDbProperties.setMaxConnections(couchDbMaxConnections);
couchDbProperties.setDbName(sessionDatabaseName);
couchDbProperties.setUsername(couchDbAdminUser);
couchDbProperties.setPassword(couchDbAdminPassword);
return new CouchDbClient(couchDbProperties);
}
示例11: getLib
import org.lightcouch.CouchDbProperties; //导入依赖的package包/类
@Override
public Object getLib(Datastore datastore) {
CouchDbProperties properties = new CouchDbProperties();
properties.setDbName(datastore.getDataUnit());
properties.setHost(datastore.getHost());
properties.setPort(datastore.getPort());
properties.setCreateDbIfNotExist(false);
properties.setProtocol(DatastoreProperties.DEFAULT_PROTOCOL_TYPE.toString());
return new CouchDbClient(properties);
}
示例12: getDBProperties
import org.lightcouch.CouchDbProperties; //导入依赖的package包/类
@Override
protected CouchDbProperties getDBProperties() {
return new CouchDbProperties("sitemap-data-anime_flv_last_series",
false, "http", "104.155.73.101" , 5984, "admin", "cCx5pnv0" );
}
示例13: getEntityPersistenceConfig
import org.lightcouch.CouchDbProperties; //导入依赖的package包/类
public CouchDbProperties getEntityPersistenceConfig() {
return getCommonConfig("entity");
}
示例14: getEntityTypePersistenceConfig
import org.lightcouch.CouchDbProperties; //导入依赖的package包/类
public CouchDbProperties getEntityTypePersistenceConfig() {
return getCommonConfig("entity_type");
}
示例15: initDatabase
import org.lightcouch.CouchDbProperties; //导入依赖的package包/类
private void initDatabase(CouchDbProperties config) {
openEntityDatabase(config);
syncEntityDesignDocs();
}