{"action":"created","issue":{"url":"https://api.github.com/repos/marklogic/data-movement/issues/54","repository_url":"https://api.github.com/repos/marklogic/data-movement","labels_url":"https://api.github.com/repos/marklogic/data-movement/issues/54/labels{/name}","comments_url":"https://api.github.com/repos/marklogic/data-movement/issues/54/comments","events_url":"https://api.github.com/repos/marklogic/data-movement/issues/54/events","html_url":"https://github.com/marklogic/data-movement/issues/54","id":151544999,"number":54,"title":"Discrepancy in behavior of flush() method when app server is disabled","user":{"login":"srinathgit","id":5034960,"avatar_url":"https://avatars.githubusercontent.com/u/5034960?v=3","gravatar_id":"","url":"https://api.github.com/users/srinathgit","html_url":"https://github.com/srinathgit","followers_url":"https://api.github.com/users/srinathgit/followers","following_url":"https://api.github.com/users/srinathgit/following{/other_user}","gists_url":"https://api.github.com/users/srinathgit/gists{/gist_id}","starred_url":"https://api.github.com/users/srinathgit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/srinathgit/subscriptions","organizations_url":"https://api.github.com/users/srinathgit/orgs","repos_url":"https://api.github.com/users/srinathgit/repos","events_url":"https://api.github.com/users/srinathgit/events{/privacy}","received_events_url":"https://api.github.com/users/srinathgit/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/marklogic/data-movement/labels/Bug","name":"Bug","color":"fc2929"},{"url":"https://api.github.com/repos/marklogic/data-movement/labels/minor","name":"minor","color":"0052cc"},{"url":"https://api.github.com/repos/marklogic/data-movement/labels/question","name":"question","color":"cc317c"},{"url":"https://api.github.com/repos/marklogic/data-movement/labels/verify","name":"verify","color":"eb6420"}],"state":"open","locked":false,"assignee":{"login":"sammefford","id":298950,"avatar_url":"https://avatars.githubusercontent.com/u/298950?v=3","gravatar_id":"","url":"https://api.github.com/users/sammefford","html_url":"https://github.com/sammefford","followers_url":"https://api.github.com/users/sammefford/followers","following_url":"https://api.github.com/users/sammefford/following{/other_user}","gists_url":"https://api.github.com/users/sammefford/gists{/gist_id}","starred_url":"https://api.github.com/users/sammefford/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sammefford/subscriptions","organizations_url":"https://api.github.com/users/sammefford/orgs","repos_url":"https://api.github.com/users/sammefford/repos","events_url":"https://api.github.com/users/sammefford/events{/privacy}","received_events_url":"https://api.github.com/users/sammefford/received_events","type":"User","site_admin":false},"assignees":[{"login":"sammefford","id":298950,"avatar_url":"https://avatars.githubusercontent.com/u/298950?v=3","gravatar_id":"","url":"https://api.github.com/users/sammefford","html_url":"https://github.com/sammefford","followers_url":"https://api.github.com/users/sammefford/followers","following_url":"https://api.github.com/users/sammefford/following{/other_user}","gists_url":"https://api.github.com/users/sammefford/gists{/gist_id}","starred_url":"https://api.github.com/users/sammefford/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sammefford/subscriptions","organizations_url":"https://api.github.com/users/sammefford/orgs","repos_url":"https://api.github.com/users/sammefford/repos","events_url":"https://api.github.com/users/sammefford/events{/privacy}","received_events_url":"https://api.github.com/users/sammefford/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/marklogic/data-movement/milestones/4","html_url":"https://github.com/marklogic/data-movement/milestones/data-movement-1.0-ea4","labels_url":"https://api.github.com/repos/marklogic/data-movement/milestones/4/labels","id":1900504,"number":4,"title":"data-movement-1.0-ea4","description":"","creator":{"login":"sammefford","id":298950,"avatar_url":"https://avatars.githubusercontent.com/u/298950?v=3","gravatar_id":"","url":"https://api.github.com/users/sammefford","html_url":"https://github.com/sammefford","followers_url":"https://api.github.com/users/sammefford/followers","following_url":"https://api.github.com/users/sammefford/following{/other_user}","gists_url":"https://api.github.com/users/sammefford/gists{/gist_id}","starred_url":"https://api.github.com/users/sammefford/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sammefford/subscriptions","organizations_url":"https://api.github.com/users/sammefford/orgs","repos_url":"https://api.github.com/users/sammefford/repos","events_url":"https://api.github.com/users/sammefford/events{/privacy}","received_events_url":"https://api.github.com/users/sammefford/received_events","type":"User","site_admin":false},"open_issues":49,"closed_issues":0,"state":"open","created_at":"2016-07-23T22:11:42Z","updated_at":"2016-09-13T17:18:42Z","due_on":null,"closed_at":null},"comments":3,"created_at":"2016-04-28T04:04:28Z","updated_at":"2016-10-10T17:10:35Z","closed_at":null,"body":"The two scenarios considered are\r\n\r\n1. Add files to WriteHostBatcher object using add(), disable the http server, call flush() method\r\n2. Add files to WriteHostBatcher object using add(), start insertion of documents by calling flush() and after insertion of few documents, disable http server. \r\n\r\nFor scenario 1,  the behavior is as expected . The request fails after a certain time number of retries\r\n\r\n```\r\ncom.marklogic.client.FailedRequestException: Service unavailable and maximum retry period elapsed: 121 seconds after 62 retries\r\n\tat com.marklogic.client.impl.JerseyServices.postResource(JerseyServices.java:3588)\r\n\tat com.marklogic.client.impl.JerseyServices.postBulkDocuments(JerseyServices.java:3677)\r\n\tat com.marklogic.client.impl.DocumentManagerImpl.write(DocumentManagerImpl.java:564)\r\n\tat com.marklogic.datamovement.impl.WriteHostBatcherImpl.flushBatch(WriteHostBatcherImpl.java:164)\r\n\tat com.marklogic.datamovement.impl.WriteHostBatcherImpl.flush(WriteHostBatcherImpl.java:147)\r\n\tat com.marklogic.datamovement.functionaltests.WriteHostBatcherTest.testInserttoDisabledAppServer(WriteHostBatcherTest.java:1577)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\r\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n\tat java.lang.reflect.Method.invoke(Method.java:498)\r\n\tat org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)\r\n\tat org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)\r\n\tat org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)\r\n\tat org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)\r\n\tat org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)\r\n\tat org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)\r\n\tat org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)\r\n\tat org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)\r\n\tat org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)\r\n\tat org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)\r\n\tat org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)\r\n\tat org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)\r\n\tat org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)\r\n\tat org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)\r\n\tat org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)\r\n\tat org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)\r\n\tat org.junit.runners.ParentRunner.run(ParentRunner.java:309)\r\n\tat org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)\r\n\tat org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)\r\n\tat org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)\r\n\tat org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)\r\n\tat org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)\r\n\tat org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)\r\n```\r\nFor scenario 2, even after 30 minutes, the request doesn't fail. I see the following in wire trace repeat continuously. Is there any other parameter in play in this scenario ?\r\n\r\n```\r\n19:12:45.356 [main] DEBUG c.m.client.impl.JerseyServices - Posting documents\r\n19:12:45.356 [main] DEBUG c.m.client.impl.JerseyServices - Sending multipart for /v1/documents\r\n19:12:45.357 [main] DEBUG o.a.h.i.c.t.ThreadSafeClientConnManager - Get connection: HttpRoute[{}->http://engrlab-129-132.engrlab.marklogic.com:9876], timeout = 0\r\n19:12:45.357 [main] DEBUG o.a.h.i.conn.tsccm.ConnPoolByRoute - [HttpRoute[{}->http://engrlab-129-132.engrlab.marklogic.com:9876]] total kept alive: 1, total issued: 0, total allocated: 1 out of 200\r\n19:12:45.357 [main] DEBUG o.a.h.i.conn.tsccm.ConnPoolByRoute - Getting free connection [HttpRoute[{}->http://engrlab-129-132.engrlab.marklogic.com:9876]][null]\r\n19:12:45.357 [main] DEBUG o.a.h.impl.client.DefaultHttpClient - Stale connection check\r\n19:12:45.367 [main] DEBUG o.a.h.c.protocol.RequestAddCookies - CookieSpec selected: ignoreCookies\r\n19:12:45.367 [main] DEBUG o.a.h.c.protocol.RequestAuthCache - Auth cache not set in the context\r\n19:12:45.367 [main] DEBUG o.a.h.impl.client.DefaultHttpClient - Attempt 1 to execute request\r\n19:12:45.367 [main] DEBUG o.a.h.i.conn.DefaultClientConnection - Sending request: POST /v1/documents HTTP/1.1\r\n19:12:45.367 [main] DEBUG org.apache.http.wire - >> \"POST /v1/documents HTTP/1.1[\\r][\\n]\"\r\n19:12:45.367 [main] DEBUG org.apache.http.wire - >> \"Content-Type: multipart/mixed; boundary=Boundary_213_1722570594_1461809565356[\\r][\\n]\"\r\n19:12:45.367 [main] DEBUG org.apache.http.wire - >> \"Authorization: Digest username=\"admin\",realm=\"public\",nonce=\"b663ca582f2f1fa0e84b5878c8bf768c\",opaque=\"11c2c5e9022d4a4e\",qop=auth,uri=\"/v1/documents\",cnonce=\"2b57bb6a\",nc=0000001f,response=\"75a515f3214c9ec95bc5abe654d46e4e\"[\\r][\\n]\"\r\n19:12:45.367 [main] DEBUG org.apache.http.wire - >> \"Transfer-Encoding: chunked[\\r][\\n]\"\r\n19:12:45.367 [main] DEBUG org.apache.http.wire - >> \"Host: engrlab-129-132.engrlab.marklogic.com:9876[\\r][\\n]\"\r\n19:12:45.367 [main] DEBUG org.apache.http.wire - >> \"Connection: Keep-Alive[\\r][\\n]\"\r\n19:12:45.367 [main] DEBUG org.apache.http.wire - >> \"[\\r][\\n]\"\r\n19:12:45.367 [main] DEBUG org.apache.http.headers - >> POST /v1/documents HTTP/1.1\r\n19:12:45.367 [main] DEBUG org.apache.http.headers - >> Content-Type: multipart/mixed; boundary=Boundary_213_1722570594_1461809565356\r\n19:12:45.367 [main] DEBUG org.apache.http.headers - >> Authorization: Digest username=\"admin\",realm=\"public\",nonce=\"b663ca582f2f1fa0e84b5878c8bf768c\",opaque=\"11c2c5e9022d4a4e\",qop=auth,uri=\"/v1/documents\",cnonce=\"2b57bb6a\",nc=0000001f,response=\"75a515f3214c9ec95bc5abe654d46e4e\"\r\n19:12:45.367 [main] DEBUG org.apache.http.headers - >> Transfer-Encoding: chunked\r\n19:12:45.367 [main] DEBUG org.apache.http.headers - >> Host: engrlab-129-132.engrlab.marklogic.com:9876\r\n19:12:45.367 [main] DEBUG org.apache.http.headers - >> Connection: Keep-Alive\r\n19:12:45.367 [main] DEBUG org.apache.http.wire - >> \"88[\\r][\\n]\"\r\n19:12:45.367 [main] DEBUG org.apache.http.wire - >> \"--Boundary_213_1722570594_1461809565356[\\r][\\n]\"\r\n19:12:45.367 [main] DEBUG org.apache.http.wire - >> \"Content-Disposition: attachment; filename=\"/local/json-325\"[\\r][\\n]\"\r\n19:12:45.367 [main] DEBUG org.apache.http.wire - >> \"Content-Type: application/json[\\r][\\n]\"\r\n19:12:45.367 [main] DEBUG org.apache.http.wire - >> \"[\\r][\\n]\"\r\n19:12:45.367 [main] DEBUG org.apache.http.wire - >> \"[\\r][\\n]\"\r\n19:12:45.377 [main] DEBUG org.apache.http.wire - >> \"be[\\r][\\n]\"\r\n19:12:45.377 [main] DEBUG org.apache.http.wire - >> \"{a:{b1:{c:\"jsonValue1\"}, b2:[\"b2 val1\", \"b2 val2\"]}}[\\r][\\n]\"\r\n19:12:45.377 [main] DEBUG org.apache.http.wire - >> \"--Boundary_213_1722570594_1461809565356[\\r][\\n]\"\r\n19:12:45.377 [main] DEBUG org.apache.http.wire - >> \"Content-Disposition: attachment; filename=\"/local/json-326\"[\\r][\\n]\"\r\n19:12:45.377 [main] DEBUG org.apache.http.wire - >> \"Content-Type: application/json[\\r][\\n]\"\r\n19:12:45.377 [main] DEBUG org.apache.http.wire - >> \"[\\r][\\n]\"\r\n19:12:45.377 [main] DEBUG org.apache.http.wire - >> \"[\\r][\\n]\"\r\n19:12:45.377 [main] DEBUG org.apache.http.wire - >> \"be[\\r][\\n]\"\r\n19:12:45.377 [main] DEBUG org.apache.http.wire - >> \"{a:{b1:{c:\"jsonValue1\"}, b2:[\"b2 val1\", \"b2 val2\"]}}[\\r][\\n]\"\r\n19:12:45.377 [main] DEBUG org.apache.http.wire - >> \"--Boundary_213_1722570594_1461809565356[\\r][\\n]\"\r\n19:12:45.377 [main] DEBUG org.apache.http.wire - >> \"Content-Disposition: attachment; filename=\"/local/json-327\"[\\r][\\n]\"\r\n19:12:45.377 [main] DEBUG org.apache.http.wire - >> \"Content-Type: application/json[\\r][\\n]\"\r\n19:12:45.377 [main] DEBUG org.apache.http.wire - >> \"[\\r][\\n]\"\r\n19:12:45.377 [main] DEBUG org.apache.http.wire - >> \"[\\r][\\n]\"\r\n19:12:45.377 [main] DEBUG org.apache.http.wire - >> \"be[\\r][\\n]\"\r\n19:12:45.377 [main] DEBUG org.apache.http.wire - >> \"{a:{b1:{c:\"jsonValue1\"}, b2:[\"b2 val1\", \"b2 val2\"]}}[\\r][\\n]\"\r\n19:12:45.377 [main] DEBUG org.apache.http.wire - >> \"--Boundary_213_1722570594_1461809565356[\\r][\\n]\"\r\n19:12:45.377 [main] DEBUG org.apache.http.wire - >> \"Content-Disposition: attachment; filename=\"/local/json-328\"[\\r][\\n]\"\r\n19:12:45.377 [main] DEBUG org.apache.http.wire - >> \"Content-Type: application/json[\\r][\\n]\"\r\n19:12:45.377 [main] DEBUG org.apache.http.wire - >> \"[\\r][\\n]\"\r\n19:12:45.377 [main] DEBUG org.apache.http.wire - >> \"[\\r][\\n]\"\r\n19:12:45.377 [main] DEBUG org.apache.http.wire - >> \"be[\\r][\\n]\"\r\n19:12:45.377 [main] DEBUG org.apache.http.wire - >> \"{a:{b1:{c:\"jsonValue1\"}, b2:[\"b2 val1\", \"b2 val2\"]}}[\\r][\\n]\"\r\n19:12:45.377 [main] DEBUG org.apache.http.wire - >> \"--Boundary_213_1722570594_1461809565356[\\r][\\n]\"\r\n19:12:45.377 [main] DEBUG org.apache.http.wire - >> \"Content-Disposition: attachment; filename=\"/local/json-329\"[\\r][\\n]\"\r\n19:12:45.377 [main] DEBUG org.apache.http.wire - >> \"Content-Type: application/json[\\r][\\n]\"\r\n19:12:45.377 [main] DEBUG org.apache.http.wire - >> \"[\\r][\\n]\"\r\n19:12:45.377 [main] DEBUG org.apache.http.wire - >> \"[\\r][\\n]\"\r\n19:12:45.377 [main] DEBUG org.apache.http.wire - >> \"61[\\r][\\n]\"\r\n19:12:45.377 [main] DEBUG org.apache.http.wire - >> \"{a:{b1:{c:\"jsonValue1\"}, b2:[\"b2 val1\", \"b2 val2\"]}}[\\r][\\n]\"\r\n19:12:45.377 [main] DEBUG org.apache.http.wire - >> \"--Boundary_213_1722570594_1461809565356--[\\r][\\n]\"\r\n19:12:45.377 [main] DEBUG org.apache.http.wire - >> \"[\\r][\\n]\"\r\n19:12:45.377 [main] DEBUG org.apache.http.wire - >> \"0[\\r][\\n]\"\r\n19:12:45.377 [main] DEBUG org.apache.http.wire - >> \"[\\r][\\n]\"\r\n19:12:45.387 [main] DEBUG org.apache.http.wire - << \"HTTP/1.1 503 Appserver Disabled[\\r][\\n]\"\r\n19:12:45.387 [main] DEBUG org.apache.http.wire - << \"Content-Type: text/html; charset=utf-8[\\r][\\n]\"\r\n19:12:45.387 [main] DEBUG org.apache.http.wire - << \"Server: MarkLogic[\\r][\\n]\"\r\n19:12:45.387 [main] DEBUG org.apache.http.wire - << \"Content-Length: 117[\\r][\\n]\"\r\n19:12:45.387 [main] DEBUG org.apache.http.wire - << \"Connection: Keep-Alive[\\r][\\n]\"\r\n19:12:45.387 [main] DEBUG org.apache.http.wire - << \"Keep-Alive: timeout=5[\\r][\\n]\"\r\n19:12:45.387 [main] DEBUG org.apache.http.wire - << \"[\\r][\\n]\"\r\n19:12:45.387 [main] DEBUG o.a.h.i.conn.DefaultClientConnection - Receiving response: HTTP/1.1 503 Appserver Disabled\r\n19:12:45.387 [main] DEBUG org.apache.http.headers - << HTTP/1.1 503 Appserver Disabled\r\n19:12:45.387 [main] DEBUG org.apache.http.headers - << Content-Type: text/html; charset=utf-8\r\n19:12:45.387 [main] DEBUG org.apache.http.headers - << Server: MarkLogic\r\n19:12:45.387 [main] DEBUG org.apache.http.headers - << Content-Length: 117\r\n19:12:45.387 [main] DEBUG org.apache.http.headers - << Connection: Keep-Alive\r\n19:12:45.387 [main] DEBUG org.apache.http.headers - << Keep-Alive: timeout=5\r\n19:12:45.387 [main] DEBUG o.a.h.impl.client.DefaultHttpClient - Connection can be kept alive for 5000 MILLISECONDS\r\n19:12:45.387 [main] DEBUG org.apache.http.wire - << \"{\"errorResponse\": [\\n]\"\r\n19:12:45.387 [main] DEBUG org.apache.http.wire - << \"  {\"statusCode\":503,[\\n]\"\r\n19:12:45.387 [main] DEBUG org.apache.http.wire - << \"   \"status\":\"Appserver Disabled\",[\\n]\"\r\n19:12:45.387 [main] DEBUG org.apache.http.wire - << \"   \"message\":\"503 Appserver Disabled\"[\\n]\"\r\n19:12:45.387 [main] DEBUG org.apache.http.wire - << \"  }[\\n]\"\r\n19:12:45.387 [main] DEBUG org.apache.http.wire - << \"}\"\r\n19:12:45.387 [main] DEBUG o.a.h.i.c.t.ThreadSafeClientConnManager - Released connection is reusable.\r\n19:12:45.387 [main] DEBUG o.a.h.i.conn.tsccm.ConnPoolByRoute - Releasing connection [HttpRoute[{}->http://engrlab-129-132.engrlab.marklogic.com:9876]][null]\r\n19:12:45.387 [main] DEBUG o.a.h.i.conn.tsccm.ConnPoolByRoute - Pooling connection [HttpRoute[{}->http://engrlab-129-132.engrlab.marklogic.com:9876]][null]; keep alive for 5000 MILLISECONDS\r\n19:12:45.387 [main] DEBUG o.a.h.i.conn.tsccm.ConnPoolByRoute - Notifying no-one, there are no waiting threads\r\n```\r\n\r\nScenario 2 code:\r\n```\r\n\t@Test\r\n\tpublic void testDisableAppServerDuringInsert() throws Exception{\r\n\t\t\r\n\t\tThread t1 = new Thread(new StopServerRunnable());\r\n     \tt1.setName(\"Status Check\");\r\n     \t  \t\r\n\t\tWriteHostBatcher ihb2 =  dmManager.newWriteHostBatcher();\r\n\t\tihb2.withBatchSize(5);\r\n\t\t\r\n\t\t\r\n\t\tihb2.onBatchSuccess(\r\n\t\t        (client, batch) -> {\r\n\t\t         \tSystem.out.println(\"Success Batch size \"+batch.getItems().length);\r\n\t\t        \tfor(WriteEvent w:batch.getItems()){\r\n\t\t        \t\tSystem.out.println(\"Success \"+w.getTargetUri());\r\n\t\t        \t}\r\n\t\t        \r\n\t\t        \t\r\n\t\t        \t}\r\n\t\t        )\r\n\t\t        .onBatchFailure(\r\n\t\t          (client, batch, throwable) -> {\r\n\t\t        \t  \tthrowable.printStackTrace();\r\n\t\t        \t \tSystem.out.println(\"Failure Batch size \"+batch.getItems().length);\r\n\t\t\t        \tfor(WriteEvent w:batch.getItems()){\r\n\t\t\t        \t\tSystem.out.println(\"Failure \"+w.getTargetUri());\r\n\t\t\t        \t}\r\n\t\t          });\r\n\t\t\r\n\t\tdmManager.startJob(ihb2);\r\n\t\tt1.start();\r\n\t\t\r\n\t\tfor (int j =0 ;j < 2000; j++){\r\n\t\t\tString uri =\"/local/json-\"+ j;\r\n\t\t\tihb2.add(uri, fileHandle);\r\n\t\t}\r\n\t\t\t\t\r\n\t\tihb2.flush();\r\n\t\tt1.join();\r\n    \t\r\n    \t\r\n\t}\r\n\tclass StopServerRunnable implements Runnable {\r\n\t  final String query1 = \"fn:count(fn:doc())\";\r\n\t  Map<String,String> properties = new HashMap<String,String>();\r\n\t\r\n   \t  @Override\r\n   \t  public void run() {\r\n   \t\t  properties.put(\"server-name\",dbName+\"-Server\");\r\n\t\t  properties.put(\"group-name\", \"Default\");\r\n\t\t  properties.put(\"enabled\", \"false\");\r\n   \t\t  boolean state = true;\r\n   \t\t  while (state){\r\n   \t\t\t int count =dbClient.newServerEval().xquery(query1).eval().next().getNumber().intValue();\r\n   \t\t\t System.out.println(\"Count is \"+count);\r\n   \t\t\t if(count >= 100){\r\n   \t\t\t// Disable the app server\t\r\n     \t\t\tchangeProperty(properties,\"/manage/v2/servers/\"+dbName+\"-Server/properties\");\r\n     \t\t\tstate=false;\r\n   \t\t\t }\r\n   \t\t\t\t\r\n   \t\t  }\r\n   \t  }  \r\n       \t\t\r\n  } \r\n\r\npublic void changeProperty(Map<String, String> properties, String endpoint)\t{\r\n\t\ttry{\r\n\t\t\tStringBuffer xmlBuff = new StringBuffer(); \t\r\n\t\t\t//xmlBuff.append(\"<forest-properties xmlns=\\\"http://marklogic.com/manage\\\">\"); \r\n\t\t\txmlBuff.append(\"{\");\r\n\t\t\t Iterator it = properties.entrySet().iterator();\r\n\t\t\t int size = properties.size();\r\n\t\t\t int j = 0;\r\n\t\t\t while (it.hasNext()) {\r\n\t\t         Map.Entry pair = (Map.Entry)it.next();\r\n\t\t         xmlBuff.append(\"\\\"\").append(pair.getKey()).append(\"\\\":\");\r\n\t\t         if (j == (size -1))\r\n\t\t        \t xmlBuff.append(\"\\\"\").append(pair.getValue()).append(\"\\\"\");\r\n\t\t         else\r\n\t\t        \t xmlBuff.append(\"\\\"\").append(pair.getValue()).append(\"\\\",\");\r\n\t\t        \t \r\n\t\t         j++;\r\n\t\t      \r\n\t\t\t}\r\n\t\t\txmlBuff.append(\"}\");\r\n\t\t\tDefaultHttpClient client = new DefaultHttpClient();\r\n\t\t\tclient.getCredentialsProvider().setCredentials(\r\n\t\t\t\t\tnew AuthScope(host, 8002),\r\n\t\t\t\t\tnew UsernamePasswordCredentials(\"admin\", \"admin\"));\r\n\r\n\t\t\tHttpPut post = new HttpPut(\"http://\"+host+\":8002\"+ endpoint); \r\n\t\t\tpost.addHeader(\"Content-type\", \"application/json\");\r\n\t\t\tpost.setEntity(new StringEntity(xmlBuff.toString()));\r\n\t\t\t\r\n\t\t\t\r\n\t\t\tHttpResponse response = client.execute(post);\r\n\t\t\tHttpEntity respEntity = response.getEntity();\r\n\r\n\t\t\tif (respEntity != null) {\r\n\t\t\t\t// EntityUtils to get the response content\r\n\t\t\t\tString content =  EntityUtils.toString(respEntity);\r\n\t\t\t\tSystem.out.println(content);\r\n\t\t\t}\r\n\t\t}catch (Exception e) {\r\n\t\t\t// writing error to Log\r\n\t\t\te.printStackTrace();\r\n\t\t}\r\n\t}\r\n```"},"comment":{"url":"https://api.github.com/repos/marklogic/data-movement/issues/comments/252681666","html_url":"https://github.com/marklogic/data-movement/issues/54#issuecomment-252681666","issue_url":"https://api.github.com/repos/marklogic/data-movement/issues/54","id":252681666,"user":{"login":"sammefford","id":298950,"avatar_url":"https://avatars.githubusercontent.com/u/298950?v=3","gravatar_id":"","url":"https://api.github.com/users/sammefford","html_url":"https://github.com/sammefford","followers_url":"https://api.github.com/users/sammefford/followers","following_url":"https://api.github.com/users/sammefford/following{/other_user}","gists_url":"https://api.github.com/users/sammefford/gists{/gist_id}","starred_url":"https://api.github.com/users/sammefford/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sammefford/subscriptions","organizations_url":"https://api.github.com/users/sammefford/orgs","repos_url":"https://api.github.com/users/sammefford/repos","events_url":"https://api.github.com/users/sammefford/events{/privacy}","received_events_url":"https://api.github.com/users/sammefford/received_events","type":"User","site_admin":false},"created_at":"2016-10-10T17:10:35Z","updated_at":"2016-10-10T17:10:35Z","body":"Ok, I dug into this and the behavior is expected as far as I can tell.  I see the repeated retries which last for even 30 minutes.  What's happening here is every single batch is retrying as instructed by the server (by the status 503 response) until it finally times out.  That takes two minutes for each batch.  So if just 15 batches are sent while the app server is disabled, it will take 30 minutes for them to all time out.  In this case many more than 15 batches are added.\r\n\r\nIf you look at the logs, you should see each batch fail with output like the following:\r\n\r\nFailure Batch size 5\r\nFailure /local/json-480\r\nFailure /local/json-481\r\nFailure /local/json-482\r\nFailure /local/json-483\r\nFailure /local/json-484\r\n\r\nNevertheless, when this was orignally reported, flush() was directly throwing the error, which I agree is inconsistent behavior.  Since then, flush() has been changed to throw errors through the failure listener registered with onBatchFailure, just like everything else.  Please let me know if you ever observe an error thrown directly by flush() rather than passed to the listener to handle.\r\n\r\nI'm going to mark this as fixed because the behavior of retry until timeout per batch is expected and the behavior or flush() throwing exceptions is no longer happening."}}
{"actor":{"display_login":"sammefford"}}