在沙发基础客户端上运行时间超时异常

时间:2015-07-28 18:31:28

标签: java couchbase

在更新(Upsert)文档时,我们一直在获取超时异常。

沙发基础服务器版本:3.0.3企业版

沙发基础客户端 - 2.1.2

配置:

connectTimeout: 10000
viewTimeout: 75000
queryTimeout: 75000

环境:

// Create couchbase cluster client
CouchbaseEnvironment couchEnv = DefaultCouchbaseEnvironment.builder()
.connectTimeout(configuration.getCouchbase().getConnectTimeout())    //10000ms = 10s, default is 5s
.viewTimeout(configuration.getCouchbase().getViewTimeout())
.queryTimeout(configuration.getCouchbase().getQueryTimeout())
.autoreleaseAfter(5000)
.build();

cluster =  CouchbaseCluster.create(couchEnv,configuration.getCouchbase().getHosts());
bucket = cluster.openBucket(configuration.getCouchbase().getBucket(), configuration.getCouchbase().getPassword());

代码:

public UserDocument updateUserDocument(UserDocument userDocument)
throws Exception {
    userDocument.setLastUpdatedTime(Calendar.getInstance().getTime());
    JsonObject userDocObject = JsonObject.fromJson(gson
.toJson(userDocument));
    JsonDocument userDocumentJson = JsonDocument.create(
    String.valueOf(userDocument.getUserId()), userDocObject);
    //Getting Timeout Exception here
    JsonDocument responseDoc = bucket.upsert(userDocumentJson);

    // update device mappings in redis
    if (userDocument.getUserDevices() != null &&  userDocument.getUserDevices().size() > 0) {
        for (UserDevice userDevice : userDocument.getUserDevices())
        { 
            redisClientService.putDeviceMappingInCache( userDevice.getDeviceId(), userDocument.getPartnerId(), userDocument); 
        }
    }

    return gson.fromJson(responseDoc.content() != null ? responseDoc.content().toString() : null, UserDocument.class);
}

错误:

ERROR [2015-07-28 12:16:59,120] com.personagraph.dropwizard.resource.UserManagementResource: Internal Error in gettting user details
! java.util.concurrent.TimeoutException: null
! Causing: java.lang.RuntimeException: java.util.concurrent.TimeoutException
! at com.couchbase.client.java.util.Blocking.blockForSingle(Blocking.java:93) ~[pgweb-usermanagement-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
! at com.couchbase.client.java.view.DefaultViewRow.document(DefaultViewRow.java:44) ~[pgweb-usermanagement-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
! at com.couchbase.client.java.view.DefaultViewRow.document(DefaultViewRow.java:39) ~[pgweb-usermanagement-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]

如果我需要任何设置或代码更改,任何人都可以告诉我

0 个答案:

没有答案