当前位置: 首页>>代码示例>>Java>>正文


Java CouchDbClient.shutdown方法代码示例

本文整理汇总了Java中org.lightcouch.CouchDbClient.shutdown方法的典型用法代码示例。如果您正苦于以下问题:Java CouchDbClient.shutdown方法的具体用法?Java CouchDbClient.shutdown怎么用?Java CouchDbClient.shutdown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.lightcouch.CouchDbClient的用法示例。


在下文中一共展示了CouchDbClient.shutdown方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import org.lightcouch.CouchDbClient; //导入方法依赖的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();
}
 
开发者ID:slauber,项目名称:Crawcial,代码行数:30,代码来源:DatabaseService.java

示例2: bench

import org.lightcouch.CouchDbClient; //导入方法依赖的package包/类
/**
 * Inserts defined amount of fake Tweets.
 *
 * @param amount amount of fake Tweets
 * @return duration in milliseconds
 */
long bench(int amount) {
    // Open database connection and take a timestamp
    CouchDbClient dbClient = new CouchDbCloneClient(properties);
    long startTime = System.currentTimeMillis();

    // Send generated JSON samples in bulk to database
    dbClient.bulk(generateSampleData(amount), true);

    // Take a second timestamp and perform some cleanup
    long duration = System.currentTimeMillis() - startTime;
    dbClient.context().ensureFullCommit();
    dbClient.context().deleteDB(properties.getDbName(), "delete database");
    dbClient.shutdown();
    return duration;
}
 
开发者ID:slauber,项目名称:Crawcial,代码行数:22,代码来源:DbPerfTest.java

示例3: verifyCredentials

import org.lightcouch.CouchDbClient; //导入方法依赖的package包/类
/**
 * Verifies the given credentials and updates the session in the database. Returns a session cookie.
 *
 * @param sc       the servlet context
 * @param username username
 * @param password password
 * @return new session cookie
 * @throws IOException if an error occurred during access
 */
protected static Cookie verifyCredentials(ServletContext sc, String username, String password) throws IOException {
    CouchDbClient dbClient = new CouchDbClient(CrawcialWebUtils.getCouchDbProperties(sc, Constants.CONFIGDB));
    try {
        CrawcialUser u = dbClient.find(CrawcialUser.class, Constants.USER_PREFIX + username);
        if (validatePassword(password, u.getPasshash())) {
            dbClient.shutdown();
            return setSessionCookie(sc, username);
        }
    } catch (Exception e) {
        dbClient.shutdown();
        return null;
    }
    return null;
}
 
开发者ID:slauber,项目名称:Crawcial,代码行数:24,代码来源:UserServlet.java

示例4: setSessionCookie

import org.lightcouch.CouchDbClient; //导入方法依赖的package包/类
/**
 * Updates the session cookie in the database.
 *
 * @param sc       the servlet context
 * @param username username
 * @return new session cookie
 * @throws InvalidKeySpecException  if an error occurred during access
 * @throws NoSuchAlgorithmException if an error occurred during access
 * @throws IOException              if an error occurred during access
 */
protected static Cookie setSessionCookie(ServletContext sc, String username) throws InvalidKeySpecException, NoSuchAlgorithmException, IOException {
    CouchDbClient dbClient = new CouchDbClient(CrawcialWebUtils.getCouchDbProperties(sc, Constants.CONFIGDB));
    try {
        CrawcialUser u = dbClient.find(CrawcialUser.class, Constants.USER_PREFIX + username);
        Cookie sessionCookie = new Cookie(Constants.COOKIE_NAME, username + "|" +
                generateStrongPasswordHash(String.valueOf(Math.random())));
        u.setCrawcialsession(sessionCookie.getValue());
        dbClient.update(u);
        dbClient.shutdown();
        return sessionCookie;
    } catch (Exception e) {
        return null;
    }
}
 
开发者ID:slauber,项目名称:Crawcial,代码行数:25,代码来源:UserServlet.java

示例5: destroy

import org.lightcouch.CouchDbClient; //导入方法依赖的package包/类
/**
 * @see Servlet#destroy()
 */
public void destroy() {
	// Close all connections to CouchDb
	for (CouchDbClient client : allClients.values())
		client.shutdown();
	// Clear client list
	allClients.clear();
}
 
开发者ID:SmartSearch,项目名称:Edge-Node,代码行数:11,代码来源:RetrieveXML.java


注:本文中的org.lightcouch.CouchDbClient.shutdown方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。