2014-12-23 43 views
0

我正在使用spring批處理評估ArangoDB。ArangoDB批處理模式不適用於Java驅動程序

我試圖插入一些數據,並且沒有批處理模式,它按預期工作。

但是,如果批處理模式打開,程序的執行會掛起。

我使用阿朗戈2.3.3com.arangodb:arangodb-Java的應用程序:2.2快照2.2]

arangoDriver.startBatchMode(); 

    for(Account acc : items){ 
     acc.getRecordHash(); 
     acc.getIdHash(); 
     arangoDriver.createDocument("AccountCollection", acc); 
    } 

    arangoDriver.executeBatch(); 

任何想法我做錯了嗎?

+0

@mchacki任何想法? – btiernay

回答

1

我試圖重現你所嘗試的,首先是集合「AccountCollection」存在嗎?如果沒有,你會得到批處理結果的錯誤,但仍然不應該掛起程序。我創建了一個單元測試:

@Test 
    public void test_StartCancelExecuteBatchMode() throws ArangoException { 

    driver.startBatchMode(); 

    ArrayList<Account> items = new ArrayList<Account>(); 
    items.add(new Account()); 
    items.add(new Account()); 
    items.add(new Account()); 
    items.add(new Account()); 

    for(Account acc : items){ 
     acc.getRecordHash(); 
     acc.getIdHash(); 
     driver.createDocument("AccountCollection", acc, true, false); 
    } 

    driver.executeBatch(); 

    } 

這工作完全和回報:

EOB 16:47:01.862 [主要] DEBUG com.arangodb.http.HttpManager - [RES] HTTP- POST:statusCode = 200 16:47:01.862 [main] DEBUG com.arangodb.http.HttpManager - [RES] http-POST:text = - dlmtrMLTPRT Content-Type:application/x-arango-batchpart Content- Id:request1

HTTP/1.1 202 Accepted Location:/ _db/unitTestDatabase/_api/document/AccountCollection/48033214501 Content-Type:application/json;字符集= UTF-8 的Etag: 「48033214501」 的Content-Length:95

{ 「錯誤」:假​​, 「_ ID」: 「AccountCollection/48033214501」, 「_ REV」: 「48033214501」, 「_按鍵」: 「48033214501」} --dlmtrMLTPRT 內容類型:應用程序/ x-阿朗戈-batchpart 的Content-Id:請求2

HTTP/1.1 202接受 位置:/ _db/unitTestDatabase/_api /文件/ AccountCollection/48033411109 Content-Type:application/json;字符集= UTF-8 的Etag: 「48033411109」 的Content-Length:95

{ 「錯誤」:假​​, 「_ ID」: 「AccountCollection/48033411109」, 「_ REV」: 「48033411109」, 「_按鍵」: 「48033411109」} --dlmtrMLTPRT 內容類型:應用程序/ x-阿朗戈-batchpart 的Content-Id:request3

HTTP/1.1 202接受 位置:/ _db/unitTestDatabase/_api /文件/ AccountCollection/48033607717 Content-Type:application/json;字符集= UTF-8 的Etag: 「48033607717」 的Content-Length:95

{ 「錯誤」:假​​, 「_ ID」: 「AccountCollection/48033607717」, 「_ REV」: 「48033607717」, 「_按鍵」: 「48033607717」} --dlmtrMLTPRT 內容類型:應用程序/ x-阿朗戈-batchpart 的Content-Id:request4

HTTP/1。1 202 Accepted Location:/ _db/unitTestDatabase/_api/document/AccountCollection/48033804325 Content-Type:application/json;字符集= UTF-8 的Etag: 「48033804325」 的Content-Length:95

{ 「錯誤」:假​​, 「_ ID」: 「AccountCollection/48033804325」, 「_ REV」: 「48033804325」, 「_按鍵」: 「48033804325」} --dlmtrMLTPRT--

但即使當我創建故意錯誤,應用程序永遠不會「掛起」。 弗蘭克剛給我發送你的源代碼,我看看它。你能試着找出程序掛在哪裏嗎?是「executeBatch」達成了嗎?

0

我已經用你的代碼導入了1.6Mio文檔,而且還是一切正常。 我想可能有必要在導入過程中監控您的系統資源,如果有什麼不尋常的事情發生,讓我們現在。一般來說,使用java api執行像這樣的一次性批量導入似乎並不是最佳實踐。我會建議使用arangoimp將數據直接導入到數據庫中,這會更快。它被記錄爲here

0

您需要增加打開文件描述符的數量。 Mac有一個非常低的限制(256)。 ArangoDB將數據存儲在特定塊大小的數據文件中。對於大型數據集,需要更多文件(並且一些fd已用於通信和其他內容)。

當ArangoDB用完文件描述符時,它既不能擴展數據集也不能回答新問題。因此導入過程將掛起。

相關問題